本文整理汇总了C++中ActionStatus::ConvertToHResult方法的典型用法代码示例。如果您正苦于以下问题:C++ ActionStatus::ConvertToHResult方法的具体用法?C++ ActionStatus::ConvertToHResult怎么用?C++ ActionStatus::ConvertToHResult使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ActionStatus
的用法示例。
在下文中一共展示了ActionStatus::ConvertToHResult方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: holder
int WINAPI CALLBACK WinMain (
__in HINSTANCE hInstance,
__in_opt HINSTANCE hPrevInstance,
__in_opt LPSTR lpCmdLine,
__in int nShowCmd
)
{
TCHAR tszMainDir[MAX_PATH] = {0,};
GetModuleFileName(GetModuleHandle(NULL), tszMainDir, _countof(tszMainDir));
TCHAR *p = _tcsrchr(tszMainDir, '\\');
if (!p)
return 0;
p[0] = 0;
if (strstr(lpCmdLine, "/UPDATE"))
{
PrivilegeHolder holder(SE_TAKE_OWNERSHIP_NAME);
ActionStatus st = SetKeyOwnerRecursive(HKEY_LOCAL_MACHINE, _T("SYSTEM\\CurrentControlSet\\Enum\\BazisVirtualCDBus"), Sid::CurrentUserSid());
RegistryKey key(HKEY_LOCAL_MACHINE, _T("SYSTEM\\CurrentControlSet\\Enum\\BazisVirtualCDBus"));
if (st.Successful())
st = key.DeleteSubKeyRecursive(_T("StandardDevice"));
if (!st.Successful() && (st.ConvertToHResult() != HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND)))
MessageBox(0, String::sFormat(_T("Warning: could not cleanup registry key under SYSTEM\\CurrentControlSet\\Enum\\BazisVirtualCDBus - %s\nConsider removing it manually."), st.GetMostInformativeText().c_str()).c_str(), _T("Warning"), MB_ICONWARNING);
RemoveDiskEnumerator(_T("root\\bzsvdisk"));
String path(tszMainDir);
File::Delete(Path::Combine(path, _T("BazisVirtualCD.inf")));
File::Delete(Path::Combine(path, _T("BazisVirtualCD.cat")));
File::Delete(Path::Combine(path, _T("VirtDiskBus.inf")));
File::Delete(Path::Combine(path, _T("VirtDiskBus.cat")));
RemoveSelectLetterCommandKeys();
ShellExecute(HWND_DESKTOP, _T("open"), String::sFormat(L"%s\\x86\\VirtualAutorunDisabler.exe", tszMainDir).c_str(), _T("/RegServer"), NULL, SW_SHOW);
ShellExecute(HWND_DESKTOP, _T("open"), _T("regsvr32.exe"), String::sFormat(L"/s \"%s\\x86\\VirtualAutorunDisablerPS.dll\"", tszMainDir).c_str(), NULL, SW_SHOW);
ShellExecute(HWND_DESKTOP, _T("open"), _T("regsvr32.exe"), String::sFormat(L"/s \"%s\\x86\\WinCDEmuContextMenu.dll\"", tszMainDir).c_str(), NULL, SW_SHOW);
#ifdef _WIN64
ShellExecute(HWND_DESKTOP, _T("open"), String::sFormat(L"%s\\x64\\VirtualAutorunDisabler.exe", tszMainDir).c_str(), _T("/RegServer"), NULL, SW_SHOW);
ShellExecute(HWND_DESKTOP, _T("open"), _T("regsvr32.exe"), String::sFormat(L"/s \"%s\\x64\\VirtualAutorunDisablerPS.dll\"", tszMainDir).c_str(), NULL, SW_SHOW);
ShellExecute(HWND_DESKTOP, _T("open"), _T("regsvr32.exe"), String::sFormat(L"/s \"%s\\x64\\WinCDEmuContextMenu.dll\"", tszMainDir).c_str(), NULL, SW_SHOW);
#endif
return 0;
}
TCHAR *pszProgramDir = _tcsstr(GetCommandLine(), _T("/WINCDEMUDIR:"));
if (pszProgramDir)
pszProgramDir += 13;
else
{
if (!_tcsstr(GetCommandLine(), _T("/UNATTENDED")))
if (MessageBox(0, _T("Do you really want to uninstall WinCDEmu?"), _T("Question"), MB_ICONQUESTION | MB_YESNO) != IDYES)
return 0;
TCHAR tszTemp[MAX_PATH] = {0,}, tszThis[MAX_PATH] = {0,};
GetModuleFileName(0, tszThis, __countof(tszThis));
GetTempPath(__countof(tszTemp), tszTemp);
_tcsncat(tszTemp, _T("\\wcduninst.exe"), _countof(tszTemp));
String fpThis = tszThis;
if (CopyFile(tszThis, tszTemp, FALSE))
{
String cmdLine = String::sFormat(_T("%s /WINCDEMUDIR:%s"), tszTemp, Path::GetDirectoryName(fpThis).c_str());
ActionStatus st;
Win32::Process proc(cmdLine.c_str(), &st);
if (st.Successful())
return 0;
}
}
RemoveDiskEnumerator(_T("root\\BazisVirtualCDBus"));
RemoveDiskEnumerator(_T("root\\bzsvdisk"));
RemoveRegistryKeys();
BazisLib::Win32::Process::RunCommandLineSynchronously((LPTSTR)String::sFormat(L"%s\\x86\\VirtualAutorunDisabler.exe /UnregServer", pszProgramDir).c_str());
BazisLib::Win32::Process::RunCommandLineSynchronously((LPTSTR)String::sFormat(L"regsvr32.exe /s /u \"%s\\x86\\VirtualAutorunDisablerPS.dll\"", pszProgramDir).c_str());
BazisLib::Win32::Process::RunCommandLineSynchronously((LPTSTR)String::sFormat(L"regsvr32.exe /s /u \"%s\\x86\\WinCDEmuContextMenu.dll\"", pszProgramDir).c_str());
#ifdef _WIN64
BazisLib::Win32::Process::RunCommandLineSynchronously((LPTSTR)String::sFormat(L"%s\\x64\\VirtualAutorunDisabler.exe /UnregServer", pszProgramDir).c_str());
BazisLib::Win32::Process::RunCommandLineSynchronously((LPTSTR)String::sFormat(L"regsvr32.exe /s /u \"%s\\x64\\VirtualAutorunDisablerPS.dll\"", pszProgramDir).c_str());
BazisLib::Win32::Process::RunCommandLineSynchronously((LPTSTR)String::sFormat(L"regsvr32.exe /s /u \"%s\\x64\\WinCDEmuContextMenu.dll\"", pszProgramDir).c_str());
#endif
DeleteFiles(pszProgramDir);
MessageBox(0, _T("WinCDEmu was successfully uninstalled."), _T("Information"), MB_ICONINFORMATION);
return 0;
}