Windows API 第20篇 SetVolumeMountPoint 设置卷挂载点参数错误

函数原型:
BOOL SetVolumeMountPoint
                                                 IN   LPCTSTR lpszVolumeMountPoint, // mount point
                                                 IN   LPCTSTR lpszVolumeName        // volume to be mounted
                                               );
参数:
lpszVolumeMountPoint:要设置的挂载点,如:“C:\\MyDrive\\DDrive\\”,  必须以反斜杠'\'结尾
lpszVolumeName  :指定的卷名,这个卷名必须为全局标志符(GUID),像
   \\?\Volume{fe04a016-a8fc-11e4-824b-806e6f6e6963}\      这种形式。得到GUID的方法有很多,调用GetVolumeName
GetVolumeNameForVolumeMountPoint 都可以得到。
下面为我的F盘设置一个挂载点:

int _tmain(int argc, _TCHAR* argv[])
{
	CHAR szVolumeName[MAX_PATH] = { 0 };
	BOOL bRet = GetVolumeNameForVolumeMountPointA("F:\\", szVolumeName, MAX_PATH);
       //这里要注意了,"C:\\share\\"目录一定要存在,而且必须为空的,否则会返回nErr = 0x57错误,为参数错误
	bRet = SetVolumeMountPointA("C:\\Share\\", szVolumeName);
	int nErr = GetLastError();
	return 0;
}

 就是这些话:

It is an error to attempt to mount a volume on a directory that has any files or subdirectories in it. This error occurs for system and hidden directories as well as other directories, and it occurs for system and hidden files.

转载于:https://www.cnblogs.com/priarieNew/p/9755483.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值