MCPcopy Create free account
hub / github.com/XRay3D/GERBER_X3 / RegisterShellExtThumbnailHandler

Function RegisterShellExtThumbnailHandler

GTE_Win/Reg.cpp:218–254  ·  view source on GitHub ↗

FUNCTION: RegisterShellExtThumbnailHandler PURPOSE: Register the thumbnail handler. PARAMETERS: pszFileType - The file type that the thumbnail handler is associated with. For example, '*' means all file types; '.txt' means all .txt files. The parameter must not be NULL. clsid - Class ID of the component NOTE: The function creates the following key in the registry. HKCR { NoRemove {

Source from the content-addressed store, hash-verified

216// }
217//
218HRESULT RegisterShellExtThumbnailHandler(PCWSTR pszFileType, const CLSID& clsid)
219{
220 if (pszFileType == nullptr) {
221 return E_INVALIDARG;
222 }
223
224 HRESULT hr;
225
226 wchar_t szCLSID[MAX_PATH];
227 StringFromGUID2(clsid, szCLSID, ARRAYSIZE(szCLSID));
228
229 wchar_t szSubkey[MAX_PATH];
230
231 // If pszFileType starts with '.', try to read the default value of the
232 // HKCR\<File Type> key which contains the ProgID to which the file type
233 // is linked.
234 if (*pszFileType == L'.') {
235 wchar_t szDefaultVal[260];
236 hr = GetHKCRRegistryKeyAndValue(pszFileType, nullptr, szDefaultVal, sizeof(szDefaultVal));
237
238 // If the key exists and its default value is not empty, use the
239 // ProgID as the file type.
240 if (SUCCEEDED(hr) && szDefaultVal[0] != L'\0') {
241 pszFileType = szDefaultVal;
242 }
243 }
244
245 // Create the registry key
246 // HKCR\<File Type>\shellex\{e357fccd-a995-4576-b01f-234630154e96}
247 hr = StringCchPrintf(szSubkey, ARRAYSIZE(szSubkey), L"%s\\shellex\\{e357fccd-a995-4576-b01f-234630154e96}", pszFileType);
248 if (SUCCEEDED(hr)) {
249 // Set the default value of the key.
250 hr = SetHKCRRegistryKeyAndValue(szSubkey, nullptr, szCLSID);
251 }
252
253 return hr;
254}
255
256//
257// FUNCTION: UnregisterShellExtThumbnailHandler

Callers 1

DllRegisterServerFunction · 0.85

Calls 2

Tested by

no test coverage detected