1、隐藏盘符:
//新建注册表,隐藏X盘符
int regeditme() { HKEY hkey; DWORD dwLastError= 8388608;//隐藏X盘2^25 J:2^9=512 X:盘符与挂载的盘符一一对应 DWORD dwordlength = sizeof(DWORD);//strlen("513")+1; ::RegOpenKey(HKEY_CURRENT_USER,"Software\Microsoft\Windows\CurrentVersion\Policies\Explorer",&hkey); if(ERROR_SUCCESS==::RegSetValueEx(hkey,"NoDrives",0,REG_DWORD,(LPBYTE)&dwLastError,dwordlength)) { //MessageBox(NULL,TEXT("更新注册表成功!"),TEXT("提示"),MB_OKCANCEL); ::RegCloseKey(hkey); return 0; } else { MessageBox(NULL,TEXT("更新注册表失败!"),TEXT("提示"),MB_OKCANCEL); ::RegCloseKey(hkey); return 1; } }
2:更新注册表:
注册表更新成功后需重启资源管理器exeplorer.exe使其生效。