ReactOS 0.4.17-dev-769-g1500a35
CAssocClientElement Class Reference
Inheritance diagram for CAssocClientElement:
Collaboration diagram for CAssocClientElement:

Public Member Functions

STDMETHODIMP QueryString (ASSOCQUERY query, PCWSTR key, PWSTR *ppszValue) override
 
STDMETHODIMP GetClassID (CLSID *pClassID) override
 
HRESULT _InitSource () override
 
HRESULT _FixNetscapeRegistration ()
 
BOOL _CreateRepairedNetscapeRegistration (HKEY hKey)
 
HRESULT _InitSourceFromKey (HKEY hKey, PCWSTR lpSubKey, DWORD dwFlags)
 
- Public Member Functions inherited from CAssocShellElement
 ~CAssocShellElement ()
 
STDMETHODIMP QueryInterface (REFIID riid, PVOID *ppv) override
 
 STDMETHODIMP_ (ULONG) AddRef() override
 
 STDMETHODIMP_ (ULONG) Release() override
 
STDMETHODIMP QueryString (ASSOCQUERY query, PCWSTR key, PWSTR *ppszValue) override
 
STDMETHODIMP QueryDword (ASSOCQUERY query, PCWSTR key, DWORD *pdwValue) override
 
STDMETHODIMP QueryExists (ASSOCQUERY query, PCWSTR key) override
 
STDMETHODIMP QueryDirect (ASSOCQUERY query, PCWSTR key, FLAGGED_BYTE_BLOB **ppBlob) override
 
STDMETHODIMP QueryObject (ASSOCQUERY query, PCWSTR key, REFIID riid, PVOID *ppvObj) override
 
STDMETHODIMP GetClassID (CLSID *pClassID) override
 
STDMETHODIMP SetString (PCWSTR psz) override
 
STDMETHODIMP GetString (PWSTR *ppsz) override
 
virtual BOOL _UseEnumForDefaultVerb ()
 
virtual HRESULT _InitSource ()
 
virtual BOOL _IsAppSource ()
 
virtual HRESULT _GetVerbDelegate (PCWSTR pszSrc, IAssociationElementOld **ppElement)
 
- Public Member Functions inherited from CAssocElement
virtual ~CAssocElement ()
 
STDMETHODIMP QueryInterface (REFIID riid, PVOID *ppv) override
 
 STDMETHODIMP_ (ULONG) AddRef() override
 
 STDMETHODIMP_ (ULONG) Release() override
 
STDMETHODIMP SetSource (IQuerySourceOld *pSource) override
 
STDMETHODIMP GetSource (REFIID riid, PVOID *ppSource) override
 
STDMETHODIMP QueryString (ASSOCQUERY query, PCWSTR key, PWSTR *ppszValue) override
 
STDMETHODIMP QueryDword (ASSOCQUERY query, PCWSTR key, DWORD *pdwValue) override
 
STDMETHODIMP QueryExists (ASSOCQUERY query, PCWSTR key) override
 
STDMETHODIMP QueryDirect (ASSOCQUERY query, PCWSTR key, FLAGGED_BYTE_BLOB **ppBlob) override
 
STDMETHODIMP QueryObject (ASSOCQUERY query, PCWSTR key, REFIID riid, PVOID *ppvObj) override
 

Additional Inherited Members

- Protected Member Functions inherited from CAssocShellElement
UINT _GetQueryKeyVal (const QUERYKEYVAL **ppItems) override
 
HRESULT _DefaultVerbSource (IQuerySourceOld **ppSource)
 
- Protected Member Functions inherited from CAssocElement
HRESULT _QueryKeyValAny (QUERY_CALLBACK callback, const QUERYKEYVAL *pItems, UINT cItems, IQuerySourceOld *pQS, ASSOCQUERY query, PCWSTR valueName, PVOID pValue)
 
HRESULT _QuerySourceAny (QUERY_CALLBACK callback, IQuerySourceOld *pSource, DWORD dwFlags, ASSOCQUERY query, PCWSTR valueName, PVOID pValue)
 
virtual UINT _GetQueryKeyVal (const QUERYKEYVAL **ppItems)
 
- Protected Attributes inherited from CAssocShellElement
PWSTR m_pszName = NULL
 
WCHAR m_szBuff [64] = L""
 
- Protected Attributes inherited from CAssocElement
LONG m_cRefs = 1
 
IQuerySourceOld * m_pSource = NULL
 

Detailed Description

Definition at line 604 of file elements.cpp.

Member Function Documentation

◆ _CreateRepairedNetscapeRegistration()

BOOL CAssocClientElement::_CreateRepairedNetscapeRegistration ( HKEY  hKey)

Definition at line 1533 of file elements.cpp.

1534{
1535 HKEY hkResult;
1537 L"Software\\Clients\\Mail\\Netscape Messenger",
1538 0, KEY_READ, &hkResult);
1539 if (error)
1540 return FALSE;
1541
1542 WCHAR szIconFile[MAX_PATH];
1543 error = _RegQueryString(hkResult, L"Protocols\\mailto\\DefaultIcon",
1544 szIconFile, _countof(szIconFile));
1545 if (error == ERROR_SUCCESS)
1546 {
1547 PathParseIconLocationW(szIconFile);
1548 StringCchCatW(szIconFile, _countof(szIconFile), L",-1349");
1549 _RegSetVolatileString(hKey, L"DefaultIcon", szIconFile);
1550 }
1551
1552 BOOL ret = FALSE;
1553 PWSTR lpString2 = NULL;
1554 if (_RegQueryString(hkResult, 0, szIconFile, _countof(szIconFile)) == ERROR_SUCCESS &&
1555 _RegSetVolatileString(hKey, 0, szIconFile) == ERROR_SUCCESS &&
1556 _RegQueryString(hkResult, L"Protocols\\mailto\\shell\\open\\command",
1557 szIconFile, _countof(szIconFile)) == ERROR_SUCCESS &&
1558 SUCCEEDED(_ExeFromCmd(szIconFile, &lpString2)))
1559 {
1560 StringCchCopyW(szIconFile, _countof(szIconFile), lpString2);
1561 CoTaskMemFree(lpString2);
1562 PathQuoteSpacesW(szIconFile);
1563 StringCchCatW(szIconFile, _countof(szIconFile), L" -mail");
1564 if (_RegSetVolatileString(hKey, L"shell\\open\\command", szIconFile) == ERROR_SUCCESS)
1565 ret = TRUE;
1566 }
1567
1568 RegCloseKey(hkResult);
1569 return ret;
1570}
#define RegCloseKey(hKey)
Definition: registry.h:49
#define ERROR_SUCCESS
Definition: deptool.c:10
static LSTATUS(WINAPI *pRegDeleteTreeW)(HKEY
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3333
void WINAPI CoTaskMemFree(void *ptr)
Definition: malloc.c:389
#define MAX_PATH
Definition: compat.h:34
int WINAPI PathParseIconLocationW(WCHAR *path)
Definition: path.c:2620
void WINAPI PathQuoteSpacesW(WCHAR *path)
Definition: path.c:2520
return ret
Definition: mutex.c:147
#define L(x)
Definition: resources.c:13
static LSTATUS _RegQueryString(HKEY hKey, PCWSTR lpSubKey, PWSTR lpData, LONG cchData)
Definition: elements.cpp:133
static LSTATUS _RegSetVolatileString(HKEY hKey, PCWSTR lpSubKey, PCWSTR lpString)
Definition: elements.cpp:140
static HRESULT _ExeFromCmd(PCWSTR pszCmdTemplate, PWSTR *ppszApplication)
Definition: elements.cpp:312
unsigned int BOOL
Definition: ntddk_ex.h:94
FxAutoRegKey hKey
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define error(str)
Definition: mkdosfs.c:1605
#define KEY_READ
Definition: nt_native.h:1026
short WCHAR
Definition: pedump.c:58
#define _countof(array)
Definition: sndvol32.h:70
STRSAFEAPI StringCchCatW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:325
STRSAFEAPI StringCchCopyW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:149
uint16_t * PWSTR
Definition: typedefs.h:56
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12

Referenced by _FixNetscapeRegistration().

◆ _FixNetscapeRegistration()

HRESULT CAssocClientElement::_FixNetscapeRegistration ( )

Definition at line 1492 of file elements.cpp.

1493{
1494 HKEY hKeyParent;
1495 LSTATUS error = RegCreateKeyExW(HKEY_CURRENT_USER, L"Software\\Clients\\Mail", 0, NULL, 0,
1496 KEY_ALL_ACCESS, NULL, &hKeyParent, NULL);
1497 if (error)
1498 return E_FAIL;
1499
1500 DWORD dwDisposition;
1501 HKEY hKey;
1502 error = RegCreateKeyExW(hKeyParent, L"Netscape Messenger", 0, NULL, REG_OPTION_VOLATILE,
1503 KEY_ALL_ACCESS, NULL, &hKey, &dwDisposition);
1504 if (error)
1505 {
1506 SHDeleteKeyW(hKeyParent, L"Netscape Messenger");
1507 RegCloseKey(hKeyParent);
1508 return E_FAIL;
1509 }
1510
1511 HRESULT hr = E_FAIL;
1513 {
1514 IQuerySourceOld* pNewSource = NULL;
1515 hr = _QuerySourceCreateFromKey(hKey, NULL, NULL, &pNewSource);
1516 if (SUCCEEDED(hr))
1517 {
1518 if (m_pSource)
1519 m_pSource->Release();
1520 m_pSource = pNewSource;
1521 }
1522 }
1523
1525
1527 SHDeleteKeyW(hKeyParent, L"Netscape Messenger");
1528
1529 RegCloseKey(hKeyParent);
1530 return hr;
1531}
BOOL _CreateRepairedNetscapeRegistration(HKEY hKey)
Definition: elements.cpp:1533
IQuerySourceOld * m_pSource
Definition: elements.cpp:383
#define E_FAIL
Definition: ddrawi.h:102
HRESULT hr
Definition: delayimp.cpp:582
LONG WINAPI RegCreateKeyExW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey, _In_ DWORD Reserved, _In_opt_ LPWSTR lpClass, _In_ DWORD dwOptions, _In_ REGSAM samDesired, _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, _Out_ PHKEY phkResult, _Out_opt_ LPDWORD lpdwDisposition)
Definition: reg.c:1096
DWORD WINAPI SHDeleteKeyW(HKEY hkey, const WCHAR *subkey)
Definition: main.c:1886
#define FAILED_UNEXPECTEDLY
Definition: utils.cpp:33
static HRESULT _QuerySourceCreateFromKey(HKEY hKey, PCWSTR lpSubKey, BOOL bCreate, IQuerySourceOld **ppSource)
Definition: elements.cpp:205
unsigned long DWORD
Definition: ntddk_ex.h:95
#define KEY_ALL_ACCESS
Definition: nt_native.h:1044
#define REG_OPENED_EXISTING_KEY
Definition: nt_native.h:1088
#define REG_OPTION_VOLATILE
Definition: nt_native.h:1063
#define HKEY_CURRENT_USER
Definition: winreg.h:11

Referenced by _InitSourceFromKey().

◆ _InitSource()

HRESULT CAssocClientElement::_InitSource ( )
overridevirtual

Reimplemented from CAssocShellElement.

Definition at line 1481 of file elements.cpp.

1482{
1483 WCHAR szBuff[MAX_PATH];
1484 StringCchPrintfW(szBuff, _countof(szBuff), L"SOFTWARE\\Clients\\%s", m_pszName);
1485
1487 if (SUCCEEDED(hr))
1488 return hr;
1489 return _InitSourceFromKey(HKEY_LOCAL_MACHINE, szBuff, 0);
1490}
HRESULT _InitSourceFromKey(HKEY hKey, PCWSTR lpSubKey, DWORD dwFlags)
Definition: elements.cpp:1572
STRSAFEAPI StringCchPrintfW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszFormat,...)
Definition: strsafe.h:530

◆ _InitSourceFromKey()

HRESULT CAssocClientElement::_InitSourceFromKey ( HKEY  hKey,
PCWSTR  lpSubKey,
DWORD  dwFlags 
)

Definition at line 1572 of file elements.cpp.

1573{
1574 HKEY hKey2;
1575 LSTATUS error = RegOpenKeyExW(hKey, lpSubKey, 0, KEY_READ | dwFlags, &hKey2);
1576 if (error)
1577 return E_INVALIDARG;
1578
1580 HKEY hkeySrc = NULL;
1581 WCHAR szData[80];
1582 DWORD dwType, cbData = sizeof(szData);
1583 error = RegQueryValueExW(hKey2, NULL, NULL, &dwType, (PBYTE)szData, &cbData);
1584 if (error == ERROR_SUCCESS && dwType == REG_SZ && szData[0] &&
1585 RegOpenKeyExW(HKEY_LOCAL_MACHINE, lpSubKey, 0, KEY_READ, &hkeySrc) == ERROR_SUCCESS)
1586 {
1587 hr = _QuerySourceCreateFromKey2(hkeySrc, NULL, szData, &m_pSource);
1588 RegCloseKey(hkeySrc);
1589 }
1590
1591 RegCloseKey(hKey2);
1592
1593 if (FAILED_UNEXPECTEDLY(hr) ||
1594 lstrcmpiW(m_pszName, L"mail") != 0 ||
1595 lstrcmpiW(szData, L"Netscape Messenger") != 0 ||
1597 {
1598 return hr;
1599 }
1600
1601 return _FixNetscapeRegistration();
1602}
HRESULT _FixNetscapeRegistration()
Definition: elements.cpp:1492
STDMETHODIMP QueryExists(ASSOCQUERY query, PCWSTR key) override
Definition: elements.cpp:891
#define E_INVALIDARG
Definition: ddrawi.h:101
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4103
int WINAPI lstrcmpiW(LPCWSTR str1, LPCWSTR str2)
Definition: locale.c:4171
static HRESULT _QuerySourceCreateFromKey2(HKEY hKey, PCWSTR key1, PCWSTR key2, IQuerySourceOld **ppSource)
Definition: elements.cpp:212
#define ASSOCQUERY_COMMAND
Definition: elements.h:25
#define REG_SZ
Definition: layer.c:22
_In_ LPWSTR _In_ DWORD _In_ DWORD _In_ DWORD dwFlags
Definition: netsh.h:141
BYTE * PBYTE
Definition: pedump.c:66
_In_opt_ _In_opt_ _In_ _In_ DWORD cbData
Definition: shlwapi.h:761

Referenced by _InitSource().

◆ GetClassID()

STDMETHODIMP CAssocClientElement::GetClassID ( CLSID pClassID)
override

Definition at line 1475 of file elements.cpp.

1476{
1477 *pClassID = CLSID_AssocClientElement;
1478 return S_OK;
1479}
#define S_OK
Definition: intsafe.h:52

◆ QueryString()

STDMETHODIMP CAssocClientElement::QueryString ( ASSOCQUERY  query,
PCWSTR  key,
PWSTR ppszValue 
)
override

Definition at line 1444 of file elements.cpp.

1445{
1446 HRESULT hr;
1447
1449 {
1451 if (SUCCEEDED(hr))
1452 return hr;
1453
1454 IAssociationElementOld* pDelegate;
1455 HRESULT hr = _GetVerbDelegate(key, &pDelegate);
1457 return hr;
1458
1459 hr = pDelegate->QueryString(ASSOCQUERY_DELEGATE, L"open", ppszValue);
1460 pDelegate->Release();
1461 return hr;
1462 }
1463
1465 {
1466 hr = CAssocElement::QueryString(ASSOCQUERY_LOCALIZEDSTRING, L"LocalizedString", ppszValue);
1467 if (SUCCEEDED(hr))
1468 return hr;
1470 }
1471
1472 return CAssocShellElement::QueryString(query, key, ppszValue);
1473}
STDMETHODIMP QueryString(ASSOCQUERY query, PCWSTR key, PWSTR *ppszValue) override
Definition: elements.cpp:742
virtual HRESULT _GetVerbDelegate(PCWSTR pszSrc, IAssociationElementOld **ppElement)
Definition: elements.cpp:831
STDMETHODIMP QueryString(ASSOCQUERY query, PCWSTR key, PWSTR *ppszValue) override
Definition: elements.cpp:861
#define ASSOCQUERY_DELEGATE
Definition: elements.h:34
#define ASSOCQUERY_LOCALIZEDSTRING
Definition: elements.h:30
#define ASSOCQUERY_FRIENDLYAPPNAME
Definition: elements.h:23
#define ASSOCQUERY_DEFAULTICON
Definition: elements.h:17
#define ASSOCQUERY_SDED
Definition: elements.h:13
ULONG Release()
#define ASSOCQUERY_EXTRA_NON_VERB
Definition: shlobj_undoc.h:42
Definition: copy.c:22

The documentation for this class was generated from the following file: