xref: /reactos/dll/shellext/zipfldr/Debug.cpp (revision d5399189)
1 /*
2  * PROJECT:     ReactOS Zip Shell Extension
3  * LICENSE:     GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
4  * PURPOSE:     Zip extraction
5  * COPYRIGHT:   Copyright 2017 Mark Jansen (mark.jansen@reactos.org)
6  */
7 
8 #include "precomp.h"
9 
10 static bool GetInterfaceName(const WCHAR* InterfaceString, WCHAR* buf, size_t size)
11 {
12     WCHAR LocalBuf[100];
13     DWORD dwType = 0, dwDataSize = size * sizeof(WCHAR);
14 
15     if (!SUCCEEDED(StringCchPrintfW(LocalBuf, _countof(LocalBuf), L"Interface\\%s", InterfaceString)))
16         return false;
17 
18     return SHRegGetValueW(HKEY_CLASSES_ROOT, LocalBuf, NULL, RRF_RT_REG_SZ, &dwType, buf, &dwDataSize) == ERROR_SUCCESS;
19 }
20 
21 WCHAR* guid2string(REFCLSID iid)
22 {
23     static WCHAR buf[2][300];
24     static int idx = 0;
25 
26     idx ^= 1;
27 
28     LPOLESTR tmp;
29     HRESULT hr = ProgIDFromCLSID(iid, &tmp);
30     if (SUCCEEDED(hr))
31     {
32         wcscpy(buf[idx], tmp);
33         CoTaskMemFree(tmp);
34         return buf[idx];
35     }
36     StringFromGUID2(iid, buf[idx], _countof(buf[idx]));
37     if (GetInterfaceName(buf[idx], buf[idx], _countof(buf[idx])))
38     {
39         return buf[idx];
40     }
41     StringFromGUID2(iid, buf[idx], _countof(buf[idx]));
42 
43     return buf[idx];
44 }
45