本文整理汇总了C++中atl::CRegKey::RecurseDeleteKey方法的典型用法代码示例。如果您正苦于以下问题:C++ CRegKey::RecurseDeleteKey方法的具体用法?C++ CRegKey::RecurseDeleteKey怎么用?C++ CRegKey::RecurseDeleteKey使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类atl::CRegKey
的用法示例。
在下文中一共展示了CRegKey::RecurseDeleteKey方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: UnregisterAddin
static HRESULT UnregisterAddin(const std::wstring& clsid)
{
HRESULT hr = S_OK;
ATL::CRegKey key;
//delete BHO
LSTATUS lStatus = key.Open(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Browser Helper Objects");
if (lStatus == ERROR_SUCCESS) {
lStatus = key.RecurseDeleteKey(clsid.c_str());
key.Close();
}
if (lStatus != ERROR_SUCCESS) {
hr = HRESULT_FROM_WIN32(lStatus);
}
//delete HKCR
lStatus = key.Open(HKEY_CLASSES_ROOT, L"CLSID");
if (lStatus == ERROR_SUCCESS) {
lStatus = key.RecurseDeleteKey(clsid.c_str());
key.Close();
}
if (lStatus != ERROR_SUCCESS) {
hr = HRESULT_FROM_WIN32(lStatus);
}
return hr;
}
示例2: UnregisterAddin
static HRESULT UnregisterAddin(const std::wstring& clsid)
{
HRESULT hr = S_OK;
ATL::CRegKey key;
//delete IconOverlay
LSTATUS lStatus = key.Open(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\ShellIconOverlayIdentifiers");
if (lStatus == ERROR_SUCCESS) {
lStatus = key.RecurseDeleteKey(L" DeskUpdateRemind");
key.Close();
}
if (lStatus != ERROR_SUCCESS) {
hr = HRESULT_FROM_WIN32(lStatus);
}
//delete CopyHook
lStatus = key.Open(HKEY_CLASSES_ROOT, L"Directory\\shellex\\CopyHookHandlers");
if (lStatus == ERROR_SUCCESS) {
lStatus = key.RecurseDeleteKey(L"AYBSharing");
key.Close();
}
if (lStatus != ERROR_SUCCESS) {
hr = HRESULT_FROM_WIN32(lStatus);
}
//delete BHO
//lStatus = key.Open(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Browser Helper Objects");
//if (lStatus == ERROR_SUCCESS) {
// lStatus = key.RecurseDeleteKey(clsid.c_str());
// key.Close();
//}
//if (lStatus != ERROR_SUCCESS) {
// hr = HRESULT_FROM_WIN32(lStatus);
//}
//delete HKCR
lStatus = key.Open(HKEY_CLASSES_ROOT, L"CLSID");
if (lStatus == ERROR_SUCCESS) {
lStatus = key.RecurseDeleteKey(clsid.c_str());
key.Close();
}
if (lStatus != ERROR_SUCCESS) {
hr = HRESULT_FROM_WIN32(lStatus);
}
return hr;
}
示例3: UninstallService
HRESULT UninstallService()
{
TSAUTO();
ATL::CRegKey key;
LSTATUS lRegResult = key.Open(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Svchost");
if(lRegResult == ERROR_SUCCESS) {
lRegResult = key.DeleteValue(L"ADCleanService");
if(lRegResult != ERROR_SUCCESS) {
TSWARN4CXX("Failed to delete reg value. Key: HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Svchost\\ADCleanService. Error: " << lRegResult);
}
key.Close();
}
else {
TSWARN4CXX("Failed to open reg key. Key: HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Svchost. Error: " << lRegResult);
}
lRegResult = key.Open(HKEY_LOCAL_MACHINE, L"SYSTEM\\CurrentControlSet\\services\\ADCleanService");
if(lRegResult == ERROR_SUCCESS) {
lRegResult = key.RecurseDeleteKey(L"Parameters");
if(lRegResult != ERROR_SUCCESS) {
TSWARN4CXX("Failed to delete reg key. Key: HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\services\\ADCleanService\\Parameters. Error: " << lRegResult);
}
key.Close();
}
else {
TSWARN4CXX("Failed to open reg key. Key: HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\services\\ADCleanService. Error: " << lRegResult);
}
SC_HANDLE schSCManager = ::OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
if(schSCManager == NULL) {
DWORD dwOpenError = ::GetLastError();
TSERROR4CXX("OpenSCManager failed. Error: " << dwOpenError);
return HRESULT_FROM_WIN32(dwOpenError);
}
ScopeResourceHandle<SC_HANDLE, BOOL (WINAPI*)(SC_HANDLE)> autoCloseSCManagerHandle(schSCManager, ::CloseServiceHandle);
SC_HANDLE schService = ::OpenService(schSCManager, szServiceName, DELETE | SERVICE_STOP | SERVICE_QUERY_STATUS);
if(schService == NULL) {
DWORD dwOpenError = ::GetLastError();
TSERROR4CXX("OpenSCManager failed. Error: " << dwOpenError);
return HRESULT_FROM_WIN32(dwOpenError);
}
ScopeResourceHandle<SC_HANDLE, BOOL (WINAPI*)(SC_HANDLE)> autoCloseServiceHandle(schService, ::CloseServiceHandle);
SERVICE_STATUS_PROCESS ssp;
DWORD dwBytesNeeded = 0;
if(!QueryServiceStatusEx(schService, SC_STATUS_PROCESS_INFO, (LPBYTE)&ssp, sizeof(SERVICE_STATUS_PROCESS), &dwBytesNeeded)) {
DWORD dwQueryServiceStatus = ::GetLastError();
TSERROR4CXX("QueryServiceStatusEx failed. Error: " << dwQueryServiceStatus);
return HRESULT_FROM_WIN32(dwQueryServiceStatus);
}
if(ssp.dwCurrentState != SERVICE_STOPPED) {
DWORD dwStartTime = GetTickCount();
DWORD dwTimeout = 30000;
while (ssp.dwCurrentState == SERVICE_STOP_PENDING) {
DWORD dwWaitTime = ssp.dwWaitHint / 10;
if( dwWaitTime < 1000 )
dwWaitTime = 1000;
else if ( dwWaitTime > 10000 )
dwWaitTime = 10000;
Sleep(dwWaitTime);
if(!QueryServiceStatusEx(schService, SC_STATUS_PROCESS_INFO, (LPBYTE)&ssp, sizeof(SERVICE_STATUS_PROCESS), &dwBytesNeeded)) {
DWORD dwQueryServiceStatus = ::GetLastError();
TSERROR4CXX("QueryServiceStatusEx failed. Error: " << dwQueryServiceStatus);
return HRESULT_FROM_WIN32(dwQueryServiceStatus);
}
if(ssp.dwCurrentState == SERVICE_STOPPED) {
TSINFO4CXX("Service Stop Success.");
goto AfterStopLabel;
}
if(GetTickCount() - dwStartTime > dwTimeout) {
TSERROR4CXX("Wait for service stop timeout.");
return E_FAIL;
}
}
if(!ControlService(schService, SERVICE_CONTROL_STOP, (LPSERVICE_STATUS)&ssp)) {
DWORD dwControlServiceError = ::GetLastError();
TSERROR4CXX("ControlService failed. Error: " << dwControlServiceError);
return HRESULT_FROM_WIN32(dwControlServiceError);
}
while ( ssp.dwCurrentState != SERVICE_STOPPED ) {
DWORD dwWaitTime = ssp.dwWaitHint;
if( dwWaitTime < 1000 )
dwWaitTime = 1000;
else if ( dwWaitTime > 10000 )
dwWaitTime = 10000;
//.........这里部分代码省略.........