void RegisterSourceFilter(const CLSID& clsid, const GUID& subtype2, std::list<LPCWSTR> chkbytes, ...) { std::wstring null = CStringFromGUID(GUID_NULL); std::wstring majortype = CStringFromGUID(MEDIATYPE_Stream); std::wstring subtype = CStringFromGUID(subtype2); int i = 0; std::list<LPCWSTR>::iterator it; for(it = chkbytes.begin(); it != chkbytes.end(); ++it) { WCHAR idx[10] = {0}; swprintf_s(idx, _T("%d"), i); SetRegKeyValue(_T("Media Type\\") + majortype, subtype, idx, *it); i++; } SetRegKeyValue(_T("Media Type\\") + majortype, subtype, _T("Source Filter"), CStringFromGUID(clsid)); DeleteRegKey(_T("Media Type\\") + null, subtype); va_list extensions; va_start(extensions, chkbytes); LPCWSTR ext = NULL; while (ext = va_arg(extensions, LPCWSTR)) { DeleteRegKey(_T("Media Type\\Extensions"), ext); } va_end(extensions); }
STDAPI DllUnregisterServer() { DeleteRegKey(_T("Media Type\\{e436eb83-524f-11ce-9f53-0020af0ba770}"), _T("{54A35221-2C8D-4a31-A5DF-6D809847E393}")); DeleteRegKey(_T("Media Type\\Extensions"), _T(".cda")); return AMovieDllRegisterServer2(FALSE); }
static bool RemoveUninstallerRegistryInfo(HKEY hkey) { bool ok1 = DeleteRegKey(hkey, REG_PATH_UNINST); // this key was added by installers up to version 1.8 bool ok2 = DeleteRegKey(hkey, REG_PATH_SOFTWARE); return ok1 && ok2; }
static void RemoveOwnRegistryKeys() { HKEY keys[] = { HKEY_LOCAL_MACHINE, HKEY_CURRENT_USER }; // remove all keys from both HKLM and HKCU (wherever they exist) for (int i = 0; i < dimof(keys); i++) { UnregisterFromBeingDefaultViewer(keys[i]); DeleteRegKey(keys[i], REG_CLASSES_APP); DeleteRegKey(keys[i], REG_CLASSES_APPS); SHDeleteValue(keys[i], REG_CLASSES_PDF L"\\OpenWithProgids", TAPP); for (int j = 0; NULL != gSupportedExts[j]; j++) { ScopedMem<WCHAR> keyname(str::Join(L"Software\\Classes\\", gSupportedExts[j], L"\\OpenWithProgids")); SHDeleteValue(keys[i], keyname, TAPP); DeleteEmptyRegKey(keys[i], keyname); keyname.Set(str::Join(L"Software\\Classes\\", gSupportedExts[j], L"\\OpenWithList\\" EXENAME)); if (!DeleteRegKey(keys[i], keyname)) continue; // remove empty keys that the installer might have created *(WCHAR *)str::FindCharLast(keyname, '\\') = '\0'; if (!DeleteEmptyRegKey(keys[i], keyname)) continue; *(WCHAR *)str::FindCharLast(keyname, '\\') = '\0'; DeleteEmptyRegKey(keys[i], keyname); } } }
static bool RemoveUninstallerRegistryInfo(HKEY hkey) { bool ok1 = DeleteRegKey(hkey, REG_PATH_UNINST); // legacy, this key was added by installers up to version 1.8 bool ok2 = DeleteRegKey(hkey, L"Software\\" APP_NAME_STR); return ok1 && ok2; }
STDAPI DllUnregisterServer() { DeleteRegKey(_T("Media Type\\{e436eb83-524f-11ce-9f53-0020af0ba770}"), _T("{17DB5CF6-39BB-4d5b-B0AA-BEBA44673AD4}")); DeleteRegKey(_T("Media Type\\Extensions"), _T(".fli")); DeleteRegKey(_T("Media Type\\Extensions"), _T(".flc")); return AMovieDllRegisterServer2(FALSE); }
/* Undo what DoAssociateExeWithPdfExtension() in AppTools.cpp did */ static void UnregisterFromBeingDefaultViewer(HKEY hkey) { ScopedMem<WCHAR> curr(ReadRegStr(hkey, REG_CLASSES_PDF, NULL)); ScopedMem<WCHAR> prev(ReadRegStr(hkey, REG_CLASSES_APP, L"previous.pdf")); if (!curr || !str::Eq(curr, TAPP)) { // not the default, do nothing } else if (prev) { WriteRegStr(hkey, REG_CLASSES_PDF, NULL, prev); } else { SHDeleteValue(hkey, REG_CLASSES_PDF, NULL); } // the following settings overrule HKEY_CLASSES_ROOT\.pdf ScopedMem<WCHAR> buf(ReadRegStr(HKEY_CURRENT_USER, REG_EXPLORER_PDF_EXT, PROG_ID)); if (str::Eq(buf, TAPP)) { LONG res = SHDeleteValue(HKEY_CURRENT_USER, REG_EXPLORER_PDF_EXT, PROG_ID); if (res != ERROR_SUCCESS) LogLastError(res); } buf.Set(ReadRegStr(HKEY_CURRENT_USER, REG_EXPLORER_PDF_EXT, APPLICATION)); if (str::EqI(buf, EXENAME)) { LONG res = SHDeleteValue(HKEY_CURRENT_USER, REG_EXPLORER_PDF_EXT, APPLICATION); if (res != ERROR_SUCCESS) LogLastError(res); } buf.Set(ReadRegStr(HKEY_CURRENT_USER, REG_EXPLORER_PDF_EXT L"\\UserChoice", PROG_ID)); if (str::Eq(buf, TAPP)) DeleteRegKey(HKEY_CURRENT_USER, REG_EXPLORER_PDF_EXT L"\\UserChoice", true); }
/* Undo what DoAssociateExeWithPdfExtension() in AppTools.cpp did */ static void UnregisterFromBeingDefaultViewer(HKEY hkey) { ScopedMem<WCHAR> curr(ReadRegStr(hkey, REG_CLASSES_PDF, nullptr)); ScopedMem<WCHAR> prev(ReadRegStr(hkey, REG_CLASSES_APP, L"previous.pdf")); if (!curr || !str::Eq(curr, APP_NAME_STR)) { // not the default, do nothing } else if (prev) { WriteRegStr(hkey, REG_CLASSES_PDF, nullptr, prev); } else { #pragma warning(push) #pragma warning(disable : 6387) // silence /analyze: '_Param_(3)' could be '0': this does not adhere to the specification for the function 'SHDeleteValueW' SHDeleteValue(hkey, REG_CLASSES_PDF, nullptr); #pragma warning(pop) } // the following settings overrule HKEY_CLASSES_ROOT\.pdf ScopedMem<WCHAR> buf(ReadRegStr(HKEY_CURRENT_USER, REG_EXPLORER_PDF_EXT, PROG_ID)); if (str::Eq(buf, APP_NAME_STR)) { LONG res = SHDeleteValue(HKEY_CURRENT_USER, REG_EXPLORER_PDF_EXT, PROG_ID); if (res != ERROR_SUCCESS) LogLastError(res); } buf.Set(ReadRegStr(HKEY_CURRENT_USER, REG_EXPLORER_PDF_EXT, APPLICATION)); if (str::EqI(buf, EXENAME)) { LONG res = SHDeleteValue(HKEY_CURRENT_USER, REG_EXPLORER_PDF_EXT, APPLICATION); if (res != ERROR_SUCCESS) LogLastError(res); } buf.Set(ReadRegStr(HKEY_CURRENT_USER, REG_EXPLORER_PDF_EXT L"\\UserChoice", PROG_ID)); if (str::Eq(buf, APP_NAME_STR)) DeleteRegKey(HKEY_CURRENT_USER, REG_EXPLORER_PDF_EXT L"\\UserChoice", true); }
// cf. http://msdn.microsoft.com/en-us/library/cc144148(v=vs.85).aspx static bool WriteExtendedFileExtensionInfo(HKEY hkey) { bool success = true; ScopedMem<WCHAR> exePath(GetInstalledExePath()); if (HKEY_LOCAL_MACHINE == hkey) success &= WriteRegStr(hkey, L"Software\\Microsoft\\Windows\\CurrentVersion\\App Paths\\" EXENAME, NULL, exePath); // mirroring some of what DoAssociateExeWithPdfExtension() does (cf. AppTools.cpp) ScopedMem<WCHAR> iconPath(str::Join(exePath, L",1")); success &= WriteRegStr(hkey, REG_CLASSES_APPS L"\\DefaultIcon", NULL, iconPath); ScopedMem<WCHAR> cmdPath(str::Format(L"\"%s\" \"%%1\" %%*", exePath)); success &= WriteRegStr(hkey, REG_CLASSES_APPS L"\\Shell\\Open\\Command", NULL, cmdPath); ScopedMem<WCHAR> printPath(str::Format(L"\"%s\" -print-to-default \"%%1\"", exePath)); success &= WriteRegStr(hkey, REG_CLASSES_APPS L"\\Shell\\Print\\Command", NULL, printPath); ScopedMem<WCHAR> printToPath(str::Format(L"\"%s\" -print-to \"%%2\" \"%%1\"", exePath)); success &= WriteRegStr(hkey, REG_CLASSES_APPS L"\\Shell\\PrintTo\\Command", NULL, printToPath); // don't add REG_CLASSES_APPS L"\\SupportedTypes", as that prevents SumatraPDF.exe to // potentially appear in the Open With lists for other filetypes (such as single images) // add the installed SumatraPDF.exe to the Open With lists of the supported file extensions for (int i = 0; NULL != gSupportedExts[i]; i++) { ScopedMem<WCHAR> keyname(str::Join(L"Software\\Classes\\", gSupportedExts[i], L"\\OpenWithList\\" EXENAME)); success &= CreateRegKey(hkey, keyname); // TODO: stop removing this after version 1.8 (was wrongly created for version 1.6) keyname.Set(str::Join(L"Software\\Classes\\", gSupportedExts[i], L"\\OpenWithList\\" APP_NAME_STR)); DeleteRegKey(hkey, keyname); } // in case these values don't exist yet (we won't delete these at uninstallation) success &= WriteRegStr(hkey, REG_CLASSES_PDF, L"Content Type", L"application/pdf"); success &= WriteRegStr(hkey, L"Software\\Classes\\MIME\\Database\\Content Type\\application/pdf", L"Extension", L".pdf"); return success; }
DLLEXPORT STDAPI DllUnregisterServer(VOID) { ScopedMem<WCHAR> mozPluginPath(ReadRegStr(HKEY_CURRENT_USER, L"Environment", L"MOZ_PLUGIN_PATH")); if (mozPluginPath) { WCHAR szModulePath[MAX_PATH]; GetModuleFileName(g_hInstance, szModulePath, MAX_PATH); if (str::StartsWithI(szModulePath, mozPluginPath)) SHDeleteValue(HKEY_CURRENT_USER, L"Environment", L"MOZ_PLUGIN_PATH"); } DeleteRegKey(HKEY_LOCAL_MACHINE, g_lpRegKey); if (!DeleteRegKey(HKEY_CURRENT_USER, g_lpRegKey)) return E_UNEXPECTED; return S_OK; }
void RegisterSourceFilter(const CLSID& clsid, const GUID& subtype2, LPCWSTR chkbytes, ...) { std::wstring null = CStringFromGUID(GUID_NULL); std::wstring majortype = CStringFromGUID(MEDIATYPE_Stream); std::wstring subtype = CStringFromGUID(subtype2); SetRegKeyValue(_T("Media Type\\") + majortype, subtype, _T("0"), chkbytes); SetRegKeyValue(_T("Media Type\\") + majortype, subtype, _T("Source Filter"), CStringFromGUID(clsid)); DeleteRegKey(_T("Media Type\\") + null, subtype); va_list extensions; va_start(extensions, chkbytes); LPCWSTR ext = NULL; while (ext = va_arg(extensions, LPCWSTR)) { DeleteRegKey(_T("Media Type\\Extensions"), ext); } va_end(extensions); }
STDAPI DllUnregisterServer() { DeleteRegKey(_T("Media Type\\Extensions"), _T(".sub")); DeleteRegKey(_T("Media Type\\Extensions"), _T(".srt")); DeleteRegKey(_T("Media Type\\Extensions"), _T(".smi")); DeleteRegKey(_T("Media Type\\Extensions"), _T(".ssa")); DeleteRegKey(_T("Media Type\\Extensions"), _T(".ass")); DeleteRegKey(_T("Media Type\\Extensions"), _T(".xss")); DeleteRegKey(_T("Media Type\\Extensions"), _T(".usf")); /**/ return AMovieDllRegisterServer2(FALSE); }
void WindowsPlatform::removeSyncFromLeftPane(QString, QString, QString uuid) { REGSAM samDesired = 0; int it = 1; if (IsWow64()) { samDesired = KEY_WOW64_64KEY; it++; } QString key = QString::fromUtf8("Software\\Classes\\CLSID\\%1").arg(uuid); for (int i = 0; i < it; i++) { DeleteRegKey(HKEY_CURRENT_USER, (LPTSTR)key.utf16(), samDesired); samDesired = 0; } key = QString::fromUtf8("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Desktop\\NameSpace\\%1").arg(uuid); DeleteRegKey(HKEY_CURRENT_USER, (LPTSTR)key.utf16(), 0); key = QString::fromUtf8("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\HideDesktopIcons\\NewStartPanel"); DeleteRegValue(HKEY_CURRENT_USER, (LPTSTR)key.utf16(), (LPTSTR)uuid.utf16(), 0); }
static bool DeleteEmptyRegKey(HKEY root, const WCHAR *keyName) { HKEY hkey; if (RegOpenKeyEx(root, keyName, 0, KEY_READ, &hkey) != ERROR_SUCCESS) return true; DWORD subkeys, values; bool isEmpty = false; if (RegQueryInfoKey(hkey, NULL, NULL, NULL, &subkeys, NULL, NULL, &values, NULL, NULL, NULL, NULL) == ERROR_SUCCESS) { isEmpty = 0 == subkeys && 0 == values; } RegCloseKey(hkey); if (isEmpty) DeleteRegKey(root, keyName); return isEmpty; }
void DoAssociateExeWithPdfExtension(HKEY hkey) { ScopedMem<WCHAR> exePath(GetExePath()); if (!exePath) return; ScopedMem<WCHAR> prevHandler(nullptr); // Remember the previous default app for the Uninstaller prevHandler.Set(ReadRegStr(hkey, REG_CLASSES_PDF, nullptr)); if (prevHandler && !str::Eq(prevHandler, APP_NAME_STR)) WriteRegStr(hkey, REG_CLASSES_APP, L"previous.pdf", prevHandler); WriteRegStr(hkey, REG_CLASSES_APP, nullptr, _TR("PDF Document")); WCHAR *icon_path = str::Join(exePath, L",1"); WriteRegStr(hkey, REG_CLASSES_APP L"\\DefaultIcon", nullptr, icon_path); free(icon_path); WriteRegStr(hkey, REG_CLASSES_APP L"\\shell", nullptr, L"open"); ScopedMem<WCHAR> cmdPath(str::Format(L"\"%s\" \"%%1\" %%*", exePath.Get())); // "${exePath}" "%1" %* bool ok = WriteRegStr(hkey, REG_CLASSES_APP L"\\shell\\open\\command", nullptr, cmdPath); // also register for printing cmdPath.Set(str::Format(L"\"%s\" -print-to-default \"%%1\"", exePath.Get())); // "${exePath}" -print-to-default "%1" WriteRegStr(hkey, REG_CLASSES_APP L"\\shell\\print\\command", nullptr, cmdPath); // also register for printing to specific printer cmdPath.Set(str::Format(L"\"%s\" -print-to \"%%2\" \"%%1\"", exePath.Get())); // "${exePath}" -print-to "%2" "%1" WriteRegStr(hkey, REG_CLASSES_APP L"\\shell\\printto\\command", nullptr, cmdPath); // Only change the association if we're confident, that we've registered ourselves well enough if (!ok) return; WriteRegStr(hkey, REG_CLASSES_PDF, nullptr, APP_NAME_STR); // TODO: also add SumatraPDF to the Open With lists for the other supported extensions? WriteRegStr(hkey, REG_CLASSES_PDF L"\\OpenWithProgids", APP_NAME_STR, L""); if (hkey == HKEY_CURRENT_USER) { WriteRegStr(hkey, REG_EXPLORER_PDF_EXT, L"Progid", APP_NAME_STR); CrashIf(hkey == 0); // to appease prefast SHDeleteValue(hkey, REG_EXPLORER_PDF_EXT, L"Application"); DeleteRegKey(hkey, REG_EXPLORER_PDF_EXT L"\\UserChoice", true); } }
/* $ 03.08.2000 SVS ! Не срабатывал шаблон поиска файлов для под-юзеров */ void CopyGlobalSettings() { if (CheckRegKey(L"")) // при существующем - вываливаемся return; // такого извера нету - перенесем данные! SetRegRootKey(HKEY_LOCAL_MACHINE); CopyKeyTree(L"Software/Far2",Opt.strRegRoot,L"Software/Far2/Users\0"); SetRegRootKey(HKEY_CURRENT_USER); CopyKeyTree(L"Software/Far2",Opt.strRegRoot,L"Software/Far2/Users/Software/Far2/PluginsCache\0"); // "Вспомним" путь по шаблону!!! SetRegRootKey(HKEY_LOCAL_MACHINE); GetRegKey(L"System",L"TemplatePluginsPath",Opt.LoadPlug.strPersonalPluginsPath,L""); // удалим!!! DeleteRegKey(L"System"); // запишем новое значение! SetRegRootKey(HKEY_CURRENT_USER); SetRegKey(L"System",L"PersonalPluginsPath",Opt.LoadPlug.strPersonalPluginsPath); }
bool DeleteRegKey(HKEY key, LPTSTR subkey, REGSAM samDesired) { TCHAR keyPath[MAX_PATH]; DWORD maxSize; HKEY hKey; LONG result = MEGARegDeleteKeyEx(key, subkey, samDesired, 0); if (result == ERROR_SUCCESS) { return true; } result = RegOpenKeyEx(key, subkey, 0, samDesired | KEY_READ, &hKey); if (result != ERROR_SUCCESS) { return (result == ERROR_FILE_NOT_FOUND); } int len = _tcslen(subkey); if (!len || len >= (MAX_PATH - 1) || _tcscpy_s(keyPath, MAX_PATH, subkey)) { RegCloseKey(hKey); return false; } LPTSTR endPos = keyPath + len - 1; if (*(endPos++) != TEXT('\\')) { *(endPos++) = TEXT('\\'); *endPos = TEXT('\0'); len++; } do { maxSize = MAX_PATH - len; } while (RegEnumKeyEx(hKey, 0, endPos, &maxSize, NULL, NULL, NULL, NULL) == ERROR_SUCCESS && DeleteRegKey(key, keyPath, samDesired)); RegCloseKey(hKey); return (MEGARegDeleteKeyEx(key, subkey, samDesired, 0) == ERROR_SUCCESS); }
bool History::SaveHistory() { if (!*EnableSave) return true; if (!HistoryList.Count()) { DeleteRegKey(strRegKey); return true; } //for dialogs, locked items should show first (be last in the list) if (TypeHistory == HISTORYTYPE_DIALOG) { for (const HistoryRecord *HistoryItem=HistoryList.First(), *LastItem=HistoryList.Last(); HistoryItem; ) { const HistoryRecord *tmp = HistoryItem; HistoryItem=HistoryList.Next(HistoryItem); if (tmp->Lock) HistoryList.MoveAfter(HistoryList.Last(), tmp); if (tmp == LastItem) break; } } wchar_t *TypesBuffer=nullptr; if (SaveType) { TypesBuffer=(wchar_t *)xf_malloc((HistoryList.Count()+1)*sizeof(wchar_t)); if (!TypesBuffer) return false; } wchar_t *LocksBuffer=nullptr; if (!(LocksBuffer=(wchar_t *)xf_malloc((HistoryList.Count()+1)*sizeof(wchar_t)))) { if (TypesBuffer) xf_free(TypesBuffer); return false; } FILETIME *TimesBuffer=nullptr; if (!(TimesBuffer=(FILETIME *)xf_malloc((HistoryList.Count()+1)*sizeof(FILETIME)))) { if (LocksBuffer) xf_free(LocksBuffer); if (TypesBuffer) xf_free(TypesBuffer); return false; } memset(TimesBuffer,0,(HistoryList.Count()+1)*sizeof(FILETIME)); wmemset(LocksBuffer,0,HistoryList.Count()+1); if (SaveType) wmemset(TypesBuffer,0,HistoryList.Count()+1); bool ret = false; HKEY hKey = nullptr; wchar_t *BufferLines=nullptr, *PtrBuffer; size_t SizeLines=0, SizeTypes=0, SizeLocks=0, SizeTimes=0; int Position = -1; size_t i=HistoryList.Count()-1; for (const HistoryRecord *HistoryItem=HistoryList.Last(); HistoryItem ; HistoryItem=HistoryList.Prev(HistoryItem)) { if (!(PtrBuffer=(wchar_t*)xf_realloc(BufferLines,(SizeLines+HistoryItem->strName.GetLength()+2)*sizeof(wchar_t)))) { ret = false; goto end; } BufferLines=PtrBuffer; xwcsncpy(BufferLines+SizeLines,HistoryItem->strName,HistoryItem->strName.GetLength()+1); SizeLines+=HistoryItem->strName.GetLength()+1; if (SaveType) TypesBuffer[SizeTypes++]=HistoryItem->Type+L'0'; LocksBuffer[SizeLocks++]=HistoryItem->Lock+L'0'; TimesBuffer[SizeTimes].dwLowDateTime=HistoryItem->Timestamp.dwLowDateTime; TimesBuffer[SizeTimes].dwHighDateTime=HistoryItem->Timestamp.dwHighDateTime; SizeTimes++; if (HistoryItem == CurrentItem) Position = static_cast<int>(i); i--; } hKey=CreateRegKey(strRegKey); if (hKey) { RegSetValueEx(hKey,L"Lines",0,REG_MULTI_SZ,(unsigned char *)BufferLines,static_cast<DWORD>(SizeLines*sizeof(wchar_t))); if (SaveType) RegSetValueEx(hKey,L"Types",0,REG_SZ,(unsigned char *)TypesBuffer,static_cast<DWORD>((SizeTypes+1)*sizeof(wchar_t))); RegSetValueEx(hKey,L"Locks",0,REG_SZ,(unsigned char *)LocksBuffer,static_cast<DWORD>((SizeLocks+1)*sizeof(wchar_t))); RegSetValueEx(hKey,L"Times",0,REG_BINARY,(unsigned char *)TimesBuffer,(DWORD)SizeTimes*sizeof(FILETIME)); RegSetValueEx(hKey,L"Position",0,REG_DWORD,(BYTE *)&Position,sizeof(Position)); RegCloseKey(hKey); ret = true; } end: if (BufferLines) xf_free(BufferLines); if (TypesBuffer) xf_free(TypesBuffer); if (LocksBuffer) xf_free(LocksBuffer); if (TimesBuffer) xf_free(TimesBuffer); return ret; }
HRESULT Register_IF(pCHAR pszDllPath, pCCHAR pszPROGID, pCCHAR pszPROGID_DESC, pCCHAR pszPROGID_CURVER, pCCHAR pszPROGID_VERINDEP, REFGUID pClsId, BOOL bReg) { HRESULT rslt = SELFREG_E_CLASS; BYTE ClassIdStr_W[100]; CHAR ClassIdStr[100]; // LPCWSTR pClassIdStr_W = (LPCWSTR) &ClassIdStr_W; // UINT32 iStrLen = 100; if (StringFromGUID2(pClsId, (LPOLESTR)ClassIdStr_W, 100) != 0) // (returns len) { CHAR szBuf[100]; pCHAR pMarker; // ClassID in unicode. Convert to ANSI. WideCharToMultiByte(CP_ACP, 0, (LPCWSTR)ClassIdStr_W, -1, ClassIdStr, 100, NULL, NULL); if (bReg) { HKEY hKey = NULL; // PROGID-entry lstrcpy(szBuf, pszPROGID); // "Borland.DbClient = Borland Client Engine" CreateRegKey(szBuf, NULL, pszPROGID_DESC); pMarker = &szBuf[lstrlen(szBuf)]; // Points to 0 lstrcat(szBuf, "\\Clsid"); // "Borland.DbClient\Clsid = {12343-22 ..}" CreateRegKey(szBuf, NULL, ClassIdStr); if (pszPROGID_CURVER) { *pMarker = 0; lstrcat(szBuf, "\\CurVer"); // "Borland.DbClient\CurVer = DSBASE.2" CreateRegKey(szBuf, NULL, pszPROGID_CURVER); rslt = 0; } else { // CLSID-entry lstrcpy(szBuf, "CLSID\\"); // "CLDID\" lstrcat(szBuf, ClassIdStr); // "CLDID\{121212 .. } = Borland Client Engine" CreateRegKey(szBuf, NULL, pszPROGID_DESC); // ProgID pMarker = &szBuf[lstrlen(szBuf)]; // Points to 0 lstrcat(szBuf, "\\ProgID"); // "CLDID\{121212 .. }\ProgID = Borland.DbClient" CreateRegKey(szBuf, NULL, pszPROGID); // InProcServer *pMarker = 0; // lstrcat(szBuf, "\\InProcServer32"); // "CLDID\{121212 .. }\InProcServer32 = <j:\t4d\dbclient.dll>" CreateRegKey(szBuf, NULL, pszDllPath); // We need to add an additional value. rslt = RegOpenKeyEx(HKEY_CLASSES_ROOT, szBuf, '\0', KEY_SET_VALUE, &hKey); if (rslt == 0) { // "CLDID\{121212 .. }\InProcServer32 = "ThreadingModel = <Apartment>" RegSetValueEx(hKey, "ThreadingModel", 0, REG_SZ, (CONST BYTE*)"Apartment", 10); RegCloseKey(hKey); } rslt = 0; // Succeded // VersionIndependentProgID if (pszPROGID_VERINDEP) { *pMarker = 0; // lstrcat(szBuf, "\\VersionIndependentProgID"); // "CLDID\{121212 .. }\InProcServer32 = <j:\t4d\dbclient.dll>" CreateRegKey(szBuf, NULL, pszPROGID_VERINDEP); } *pMarker = 0; } } else { // Delete CLSID if (pszPROGID_CURVER == NULL) { lstrcpy(szBuf, "CLSID\\"); lstrcat(szBuf, ClassIdStr); pMarker = &szBuf[lstrlen(szBuf)]; // Points to 0 *pMarker = 0; // lstrcat(szBuf, "\\InProcServer32"); DeleteRegKey(szBuf); *pMarker = 0; // lstrcat(szBuf, "\\ProgID"); DeleteRegKey(szBuf); *pMarker = 0; // lstrcat(szBuf, "\\VersionIndependentProgID"); DeleteRegKey(szBuf); *pMarker = 0; // DeleteRegKey(szBuf); } // delete PROGID lstrcpy(szBuf, pszPROGID); pMarker = &szBuf[lstrlen(szBuf)]; // Points to 0 lstrcat(szBuf, "\\Clsid"); DeleteRegKey(szBuf); *pMarker = 0; // lstrcat(szBuf, "\\CurVer"); DeleteRegKey(szBuf); *pMarker = 0; // DeleteRegKey(szBuf); rslt = 0; // Succeded } } return rslt; }
void UnRegisterProtocolSourceFilter(LPCWSTR protocol) { DeleteRegKey(protocol, _T("")); }
STDAPI DllUnregisterServer() { DeleteRegKey(_T("Media Type\\{e436eb83-524f-11ce-9f53-0020af0ba770}"), _T("{773EAEDE-D5EE-4fce-9C8F-C4F53D0A2F73}")); return AMovieDllRegisterServer2(FALSE); }
bool CheckLeftPaneIcon(wchar_t *path, bool remove) { HKEY hKey = NULL; LONG result = RegOpenKeyEx(HKEY_CURRENT_USER, L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Desktop\\NameSpace", 0, KEY_READ | KEY_ENUMERATE_SUB_KEYS, &hKey); if (result != ERROR_SUCCESS) { return false; } DWORD retCode = ERROR_SUCCESS; WCHAR uuid[MAX_PATH]; DWORD uuidlen = sizeof(uuid); for (int i = 0; retCode == ERROR_SUCCESS; i++) { uuidlen = sizeof(uuid); uuid[0] = '\0'; retCode = RegEnumKeyEx(hKey, i, uuid, &uuidlen, NULL, NULL, NULL, NULL); if (retCode == ERROR_SUCCESS) { HKEY hSubKey; TCHAR subKeyPath[MAX_PATH]; swprintf_s(subKeyPath, MAX_PATH, L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Desktop\\NameSpace\\%s", uuid); result = RegOpenKeyEx(HKEY_CURRENT_USER, subKeyPath, 0, KEY_READ, &hSubKey); if (result != ERROR_SUCCESS) { continue; } DWORD type; TCHAR value[MAX_PATH]; DWORD valuelen = sizeof(value); result = RegQueryValueEx(hSubKey, L"", NULL, &type, (LPBYTE)value, &valuelen); RegCloseKey(hSubKey); if (result != ERROR_SUCCESS || type != REG_SZ || valuelen != 10 || memcmp(value, L"MEGA", 10)) { continue; } if (path) { bool found = false; swprintf_s(subKeyPath, MAX_PATH, L"Software\\Classes\\CLSID\\%s\\Instance\\InitPropertyBag", uuid); result = RegOpenKeyEx(HKEY_CURRENT_USER, subKeyPath, 0, KEY_READ, &hSubKey); if (result == ERROR_SUCCESS) { valuelen = sizeof(value); result = RegQueryValueEx(hSubKey, L"TargetFolderPath", NULL, &type, (LPBYTE)value, &valuelen); RegCloseKey(hSubKey); if (result == ERROR_SUCCESS && type == REG_EXPAND_SZ && !_wcsicmp(value, path)) { found = true; } } if (!found) { swprintf_s(subKeyPath, MAX_PATH, L"Software\\Classes\\CLSID\\%s\\Instance\\InitPropertyBag", uuid); result = RegOpenKeyEx(HKEY_CURRENT_USER, subKeyPath, 0, KEY_WOW64_64KEY | KEY_READ, &hSubKey); if (result == ERROR_SUCCESS) { valuelen = sizeof(value); result = RegQueryValueEx(hSubKey, L"TargetFolderPath", NULL, &type, (LPBYTE)value, &valuelen); RegCloseKey(hSubKey); if (result == ERROR_SUCCESS && type == REG_EXPAND_SZ && !_wcsicmp(value, path)) { found = true; } } } if (!found) { continue; } } if (remove) { wchar_t buffer[MAX_PATH]; swprintf_s(buffer, MAX_PATH, L"Software\\Classes\\CLSID\\%s", uuid); if (IsWow64()) { DeleteRegKey(HKEY_CURRENT_USER, buffer, KEY_WOW64_64KEY); } DeleteRegKey(HKEY_CURRENT_USER, buffer, 0); DeleteRegValue(HKEY_CURRENT_USER, (LPTSTR)L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\HideDesktopIcons\\NewStartPanel", uuid, 0); swprintf_s(buffer, MAX_PATH, L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Desktop\\NameSpace\\%s", uuid); DeleteRegKey(HKEY_CURRENT_USER, buffer, 0); } RegCloseKey(hKey); return true; } } RegCloseKey(hKey); return false; }
void UnRegisterSourceFilter(const GUID& subtype) { DeleteRegKey(_T("Media Type\\") + CStringFromGUID(MEDIATYPE_Stream), CStringFromGUID(subtype)); }