diff options
author | George Hazan <george.hazan@gmail.com> | 2013-08-25 13:28:00 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2013-08-25 13:28:00 +0000 |
commit | 200a4d0240089ceeeaf772ca74c224bd1851bd7e (patch) | |
tree | e246eae6a2421e3e7a481afbb88ad001437ad7c9 /plugins/ShellExt | |
parent | 0af561c5f6618bd5431e6ff15c00dd989ad3dc49 (diff) |
fix for error messages on registry items deletion
git-svn-id: http://svn.miranda-ng.org/main/trunk@5827 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/ShellExt')
-rw-r--r-- | plugins/ShellExt/src/main.cpp | 32 | ||||
-rw-r--r-- | plugins/ShellExt/src/shlcom.cpp | 40 |
2 files changed, 37 insertions, 35 deletions
diff --git a/plugins/ShellExt/src/main.cpp b/plugins/ShellExt/src/main.cpp index daf43b62a0..cfeba378d8 100644 --- a/plugins/ShellExt/src/main.cpp +++ b/plugins/ShellExt/src/main.cpp @@ -36,8 +36,8 @@ extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD miranda struct HRegKey
{
- HRegKey(HKEY hRoot, const TCHAR *ptszKey) : m_key(NULL)
- { RegCreateKeyEx(hRoot, ptszKey, 0, 0, 0, KEY_SET_VALUE | KEY_CREATE_SUB_KEY, 0, &m_key, 0);
+ HRegKey(HKEY hRoot, const char *ptszKey) : m_key(NULL)
+ { RegCreateKeyExA(hRoot, ptszKey, 0, 0, 0, KEY_SET_VALUE | KEY_CREATE_SUB_KEY, 0, &m_key, 0);
}
~HRegKey() { if (m_key) RegCloseKey(m_key); }
@@ -52,30 +52,28 @@ char str1[100]; char str2[] = "{72013A26-A94C-11d6-8540-A5E62932711D}";
char str3[] = "miranda.shlext";
char str4[] = "Apartment";
-
-TCHAR key1[] = _T("miranda.shlext\\{72013A26-A94C-11d6-8540-A5E62932711D}\\InprocServer32");
STDAPI DllRegisterServer()
{
- int str1len = sprintf_s(str1, sizeof(str1), "shlext %d.%d.%d.%d - shell context menu support for Miranda NG", __FILEVERSION_STRING);
- if ( RegSetValueA(HKEY_CLASSES_ROOT, "miranda.shlext", REG_SZ, str1, str1len))
+ HRegKey k1(HKEY_CLASSES_ROOT, "miranda.shlext");
+ if (k1 == NULL)
return E_FAIL;
- if ( RegSetValueA(HKEY_CLASSES_ROOT, "miranda.shlext\\CLSID", REG_SZ, str2, sizeof(str2)))
+
+ int str1len = sprintf_s(str1, sizeof(str1), "shlext %d.%d.%d.%d - shell context menu support for Miranda NG", __FILEVERSION_STRING);
+ if ( RegSetValueA(k1, NULL, REG_SZ, str1, str1len))
return E_FAIL;
- if ( RegSetValueA(HKEY_CLASSES_ROOT, "miranda.shlext\\{72013A26-A94C-11d6-8540-A5E62932711D}", REG_SZ, str3, sizeof(str3)))
+ if ( RegSetValueA(k1, "CLSID", REG_SZ, str2, sizeof(str2)))
return E_FAIL;
- if ( RegSetValueA(HKEY_CLASSES_ROOT, "miranda.shlext\\{72013A26-A94C-11d6-8540-A5E62932711D}\\ProgID", REG_SZ, str3, sizeof(str3)))
+ if ( RegSetValueA(k1, "{72013A26-A94C-11d6-8540-A5E62932711D}", REG_SZ, str3, sizeof(str3)))
return E_FAIL;
-
- TCHAR tszFileName[MAX_PATH];
- GetModuleFileName(hInst, tszFileName, SIZEOF(tszFileName));
- if ( RegSetValue(HKEY_CLASSES_ROOT, key1, REG_SZ, tszFileName, lstrlen(tszFileName)))
+ if ( RegSetValueA(k1, "{72013A26-A94C-11d6-8540-A5E62932711D}\\ProgID", REG_SZ, str3, sizeof(str3)))
return E_FAIL;
- HRegKey k1(HKEY_CLASSES_ROOT, key1);
- if (k1 == NULL)
+ char tszFileName[MAX_PATH];
+ GetModuleFileNameA(hInst, tszFileName, SIZEOF(tszFileName));
+ if ( RegSetValueA(k1, "{72013A26-A94C-11d6-8540-A5E62932711D}\\InprocServer32", REG_SZ, tszFileName, lstrlenA(tszFileName)))
return E_FAIL;
- if ( RegSetValueA(k1, "ThreadingModel", REG_SZ, str4, sizeof(str4)))
+ if ( RegSetValueA(k1, "{72013A26-A94C-11d6-8540-A5E62932711D}\\InprocServer32\\ThreadingModel", REG_SZ, str4, sizeof(str4)))
return E_FAIL;
if ( RegSetValueA(HKEY_CLASSES_ROOT, "*\\shellex\\ContextMenuHandlers\\miranda.shlext", REG_SZ, str2, sizeof(str2)))
@@ -83,7 +81,7 @@ STDAPI DllRegisterServer() if ( RegSetValueA(HKEY_CLASSES_ROOT, "Directory\\shellex\\ContextMenuHandlers\\miranda.shlext", REG_SZ, str2, sizeof(str2)))
return E_FAIL;
- HRegKey k2(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Shell Extensions\\Approved"));
+ HRegKey k2(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Shell Extensions\\Approved");
if (k2 == NULL)
return E_FAIL;
if ( RegSetValueExA(k2, str2, 0, REG_SZ, (PBYTE)str1, str1len))
diff --git a/plugins/ShellExt/src/shlcom.cpp b/plugins/ShellExt/src/shlcom.cpp index 095bee3fe0..b9d9be7191 100644 --- a/plugins/ShellExt/src/shlcom.cpp +++ b/plugins/ShellExt/src/shlcom.cpp @@ -1537,6 +1537,10 @@ HRESULT RemoveCOMRegistryEntries() if ( !RegOpenKeyExA(HKEY_CLASSES_ROOT, "miranda.shlext", 0, KEY_READ, &hRootKey)) {
// need to delete the subkey before the parent key is deleted under NT/2000/XP
RegDeleteKeyA(hRootKey, "CLSID");
+ RegDeleteKeyA(hRootKey, "{72013A26-A94C-11d6-8540-A5E62932711D}\\InprocServer32\\ThreadingModel");
+ RegDeleteKeyA(hRootKey, "{72013A26-A94C-11d6-8540-A5E62932711D}\\InprocServer32");
+ RegDeleteKeyA(hRootKey, "{72013A26-A94C-11d6-8540-A5E62932711D}\\ProgID");
+ RegDeleteKeyA(hRootKey, "{72013A26-A94C-11d6-8540-A5E62932711D}");
// close the key
RegCloseKey(hRootKey);
// delete it
@@ -1560,7 +1564,7 @@ HRESULT RemoveCOMRegistryEntries() RegCloseKey(hRootKey);
}
if ( !RegOpenKeyExA(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows\\CurrentVersion\\Shell Extensions\\Approved", 0, KEY_ALL_ACCESS, &hRootKey)) {
- if ( !RegDeleteValueA(hRootKey, "{72013A26-A94C-11d6-8540-A5E62932711D}") != ERROR_SUCCESS) {
+ if ( RegDeleteValueA(hRootKey, "{72013A26-A94C-11d6-8540-A5E62932711D}") != ERROR_SUCCESS) {
MessageBoxA(0,
"Unable to delete registry entry for 'Approved context menu handlers', this key may already be deleted or you may need admin rights.",
"Problem", MB_ICONERROR);
@@ -1576,16 +1580,17 @@ void CheckUnregisterServer() {
if (VistaOrLater) {
// launches regsvr to remove the dll under admin.
- char szFileName[MAX_PATH], szBuf[MAX_PATH * 2];
- GetModuleFileNameA(hInst, szFileName, SIZEOF(szFileName));
- mir_snprintf(szBuf, sizeof(szBuf), "/s /u \"%s\"", szFileName);
-
- SHELLEXECUTEINFOA sei = { 0 };
- sei.cbSize = sizeof(sei);
- sei.lpVerb = "runas";
- sei.lpFile = "regsvr32";
+ TCHAR szFileName[MAX_PATH], szBuf[MAX_PATH * 2];
+ GetModuleFileName(hInst, szFileName, SIZEOF(szFileName));
+ mir_sntprintf(szBuf, SIZEOF(szBuf), _T("/s /u \"%s\""), szFileName);
+
+ SHELLEXECUTEINFO sei = { sizeof(sei) };
+ sei.lpVerb = _T("runas");
+ sei.lpFile = _T("regsvr32");
sei.lpParameters = szBuf;
- ShellExecuteExA(&sei);
+ if ( ShellExecuteEx(&sei) == TRUE)
+ return;
+
Sleep(1000);
}
RemoveCOMRegistryEntries();
@@ -1596,7 +1601,7 @@ void CheckUnregisterServer() void CheckRegisterServer()
{
- char szFileName[MAX_PATH], szBuf[MAX_PATH * 2];
+ TCHAR szFileName[MAX_PATH], szBuf[MAX_PATH * 2];
HKEY hRegKey;
if ( !RegOpenKeyExA(HKEY_CLASSES_ROOT, "miranda.shlext", 0, KEY_READ, &hRegKey))
@@ -1606,14 +1611,13 @@ void CheckRegisterServer() "Shell context menus requires your permission to register with Windows Explorer (one time only).",
"Miranda NG - Shell context menus (shellext.dll)", MB_OK | MB_ICONINFORMATION);
// /s = silent
- GetModuleFileNameA(hInst, szFileName, sizeof(szFileName));
- mir_snprintf(szBuf, sizeof(szBuf), "/s \"%s\"", szFileName);
+ GetModuleFileName(hInst, szFileName, SIZEOF(szFileName));
+ mir_sntprintf(szBuf, SIZEOF(szBuf), _T("/s \"%s\""), szFileName);
- SHELLEXECUTEINFOA sei = { 0 };
- sei.cbSize = sizeof(sei);
- sei.lpVerb = "runas";
- sei.lpFile = "regsvr32";
+ SHELLEXECUTEINFO sei = { sizeof(sei) };
+ sei.lpVerb = _T("runas");
+ sei.lpFile = _T("regsvr32");
sei.lpParameters = szBuf;
- ShellExecuteExA(&sei);
+ ShellExecuteEx(&sei);
}
}
|