简体   繁体   English

如何在 DeleteVolumeMountPoint 后恢复驱动器安装?

[英]How to restore drive mount after DeleteVolumeMountPoint?

After using DeleteVolumeMountPoint("E:\\") (for instance) in order to delete the mounting point of a DOK, i would like to restore it.在使用 DeleteVolumeMountPoint("E:\\") (例如)以删除 DOK 的安装点后,我想恢复它。 (make the drive letter usable again) (使驱动器号再次可用)

How would I do that?我该怎么做?

Looking at the MSDN documentation for DeleteVolumeMountPoint says that SetVolumeMountPoint would do the task.查看DeleteVolumeMountPoint的 MSDN 文档说SetVolumeMountPoint可以完成任务。

The documentation links to an example :文档链接到一个例子

#define _WIN32_WINNT 0x0501

#include <windows.h>
#include <tchar.h>
#include <stdio.h>

#define BUFSIZE MAX_PATH 

int _tmain( int argc, TCHAR *argv[] )
{
   BOOL bFlag;
   TCHAR Buf[BUFSIZE];     // temporary buffer for volume name

   if( argc != 3 ) 
   {
      _tprintf( TEXT("Usage: %s <mount_point> <volume>\n"), argv[0] );
      _tprintf( TEXT("For example, \"%s c:\\mnt\\fdrive\\ f:\\\"\n"), argv[0]);
      return( -1 );
   }

  // We should do some error checking on the inputs. Make sure there 
  // are colons and backslashes in the right places, and so on 

   bFlag = GetVolumeNameForVolumeMountPoint(
              argv[2], // input volume mount point or directory
                  Buf, // output volume name buffer
              BUFSIZE  // size of volume name buffer
           );

   if (bFlag != TRUE) 
   {
      _tprintf( TEXT("Retrieving volume name for %s failed.\n"), argv[2] );
      return (-2);
   }

   _tprintf( TEXT("Volume name of %s is %s\n"), argv[2], Buf );
   bFlag = SetVolumeMountPoint(
              argv[1], // mount point
                  Buf  // volume to be mounted
           );

   if (!bFlag)
     _tprintf (TEXT("Attempt to mount %s at %s failed.\n"), argv[2], argv[1]);

   return (bFlag);
}

只需以交互方式执行此操作,您可以打开“卷管理器”,右键单击卷并分配驱动器号。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM