DWORD HideDisk(char szDriver)
{
DWORD dwError = NOERROR;
TCHAR dsPath[MAX_PATH] = _T("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\policies\\Explorer");
DWORD dwHideMask = 0;
DWORD dwDiskIndex = szDriver - 'A';
DWORD dwMask = 0;
CRegKey dstKey;
dwMask |= ((1 << dwDiskIndex));
dwError = dstKey.Create(HKEY_LOCAL_MACHINE, dsPath);
if (ERROR_SUCCESS == dwError)
{
dwError = dstKey.QueryDWORDValue(_T("NoDrives"), dwHideMask);
dwHideMask |= dwMask;
dwError = dstKey.SetDWORDValue(_T("NoDrives"), dwHideMask);
dstKey.Close();
}
return dwError;
{
DWORD dwError = NOERROR;
TCHAR dsPath[MAX_PATH] = _T("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\policies\\Explorer");
DWORD dwHideMask = 0;
DWORD dwDiskIndex = szDriver - 'A';
DWORD dwMask = 0;
CRegKey dstKey;
dwMask |= ((1 << dwDiskIndex));
dwError = dstKey.Create(HKEY_LOCAL_MACHINE, dsPath);
if (ERROR_SUCCESS == dwError)
{
dwError = dstKey.QueryDWORDValue(_T("NoDrives"), dwHideMask);
dwHideMask |= dwMask;
dwError = dstKey.SetDWORDValue(_T("NoDrives"), dwHideMask);
dstKey.Close();
}
return dwError;
}
VOID RefreshPolicyAndCtrl()
{
DWORD dwResult = 0;
{
wstring wsMsgParam;
wsMsgParam.assign(L"Policy");
::SendMessage(HWND_BROADCAST, WM_SETTINGCHANGE, NULL, (LPARAM)wsMsgParam.c_str());
//wsMsgParam.assign( L"intl" );
//SendMessage( HWND_BROADCAST, WM_SETTINGCHANGE, NULL, (LPARAM)wsMsgParam.c_str() );
}
//需要刷新桌面,防止我的电脑等图片刷新不全
::SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST | SHCNF_FLUSH, 0, 0);
SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, NULL, NULL, SMTO_NORMAL, 1000, &dwResult);
}