ReactOS 0.4.17-dev-444-g71ee754
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 627 of file elements.cpp.

Member Function Documentation

◆ _CreateRepairedNetscapeRegistration()

BOOL CAssocClientElement::_CreateRepairedNetscapeRegistration ( HKEY  hKey)

Definition at line 1556 of file elements.cpp.

1557{
1558 HKEY hkResult;
1560 L"Software\\Clients\\Mail\\Netscape Messenger",
1561 0, KEY_READ, &hkResult);
1562 if (error)
1563 return FALSE;
1564
1565 WCHAR szIconFile[MAX_PATH];
1566 error = _RegQueryString(hkResult, L"Protocols\\mailto\\DefaultIcon",
1567 szIconFile, _countof(szIconFile));
1568 if (error == ERROR_SUCCESS)
1569 {
1570 PathParseIconLocationW(szIconFile);
1571 StringCchCatW(szIconFile, _countof(szIconFile), L",-1349");
1572 _RegSetVolatileString(hKey, L"DefaultIcon", szIconFile);
1573 }
1574
1575 BOOL ret = FALSE;
1576 PWSTR lpString2 = NULL;
1577 if (_RegQueryString(hkResult, 0, szIconFile, _countof(szIconFile)) == ERROR_SUCCESS &&
1578 _RegSetVolatileString(hKey, 0, szIconFile) == ERROR_SUCCESS &&
1579 _RegQueryString(hkResult, L"Protocols\\mailto\\shell\\open\\command",
1580 szIconFile, _countof(szIconFile)) == ERROR_SUCCESS &&
1581 SUCCEEDED(_ExeFromCmd(szIconFile, &lpString2)))
1582 {
1583 StringCchCopyW(szIconFile, _countof(szIconFile), lpString2);
1584 CoTaskMemFree(lpString2);
1585 PathQuoteSpacesW(szIconFile);
1586 StringCchCatW(szIconFile, _countof(szIconFile), L" -mail");
1587 if (_RegSetVolatileString(hKey, L"shell\\open\\command", szIconFile) == ERROR_SUCCESS)
1588 ret = TRUE;
1589 }
1590
1591 RegCloseKey(hkResult);
1592 return ret;
1593}
#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:146
#define L(x)
Definition: resources.c:13
static LSTATUS _RegQueryString(HKEY hKey, PCWSTR lpSubKey, PWSTR lpData, LONG cchData)
Definition: elements.cpp:156
static LSTATUS _RegSetVolatileString(HKEY hKey, PCWSTR lpSubKey, PCWSTR lpString)
Definition: elements.cpp:163
static HRESULT _ExeFromCmd(PCWSTR pszCmdTemplate, PWSTR *ppszApplication)
Definition: elements.cpp:335
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 1515 of file elements.cpp.

1516{
1517 HKEY hKeyParent;
1518 LSTATUS error = RegCreateKeyExW(HKEY_CURRENT_USER, L"Software\\Clients\\Mail", 0, NULL, 0,
1519 KEY_ALL_ACCESS, NULL, &hKeyParent, NULL);
1520 if (error)
1521 return E_FAIL;
1522
1523 DWORD dwDisposition;
1524 HKEY hKey;
1525 error = RegCreateKeyExW(hKeyParent, L"Netscape Messenger", 0, NULL, REG_OPTION_VOLATILE,
1526 KEY_ALL_ACCESS, NULL, &hKey, &dwDisposition);
1527 if (error)
1528 {
1529 SHDeleteKeyW(hKeyParent, L"Netscape Messenger");
1530 RegCloseKey(hKeyParent);
1531 return E_FAIL;
1532 }
1533
1534 HRESULT hr = E_FAIL;
1536 {
1537 IQuerySourceOld* pNewSource = NULL;
1538 hr = _QuerySourceCreateFromKey(hKey, NULL, NULL, &pNewSource);
1539 if (SUCCEEDED(hr))
1540 {
1541 if (m_pSource)
1542 m_pSource->Release();
1543 m_pSource = pNewSource;
1544 }
1545 }
1546
1548
1550 SHDeleteKeyW(hKeyParent, L"Netscape Messenger");
1551
1552 RegCloseKey(hKeyParent);
1553 return hr;
1554}
BOOL _CreateRepairedNetscapeRegistration(HKEY hKey)
Definition: elements.cpp:1556
IQuerySourceOld * m_pSource
Definition: elements.cpp:406
#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:228
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 1504 of file elements.cpp.

1505{
1506 WCHAR szBuff[MAX_PATH];
1507 StringCchPrintfW(szBuff, _countof(szBuff), L"SOFTWARE\\Clients\\%s", m_pszName);
1508
1510 if (SUCCEEDED(hr))
1511 return hr;
1512 return _InitSourceFromKey(HKEY_LOCAL_MACHINE, szBuff, 0);
1513}
HRESULT _InitSourceFromKey(HKEY hKey, PCWSTR lpSubKey, DWORD dwFlags)
Definition: elements.cpp:1595
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 1595 of file elements.cpp.

1596{
1597 HKEY hKey2;
1598 LSTATUS error = RegOpenKeyExW(hKey, lpSubKey, 0, KEY_READ | dwFlags, &hKey2);
1599 if (error)
1600 return E_INVALIDARG;
1601
1603 HKEY hkeySrc = NULL;
1604 WCHAR szData[80];
1605 DWORD dwType, cbData = sizeof(szData);
1606 error = RegQueryValueExW(hKey2, NULL, NULL, &dwType, (PBYTE)szData, &cbData);
1607 if (error == ERROR_SUCCESS && dwType == REG_SZ && szData[0] &&
1608 RegOpenKeyExW(HKEY_LOCAL_MACHINE, lpSubKey, 0, KEY_READ, &hkeySrc) == ERROR_SUCCESS)
1609 {
1610 hr = _QuerySourceCreateFromKey2(hkeySrc, NULL, szData, &m_pSource);
1611 RegCloseKey(hkeySrc);
1612 }
1613
1614 RegCloseKey(hKey2);
1615
1616 if (FAILED_UNEXPECTEDLY(hr) ||
1617 lstrcmpiW(m_pszName, L"mail") != 0 ||
1618 lstrcmpiW(szData, L"Netscape Messenger") != 0 ||
1620 {
1621 return hr;
1622 }
1623
1624 return _FixNetscapeRegistration();
1625}
HRESULT _FixNetscapeRegistration()
Definition: elements.cpp:1515
STDMETHODIMP QueryExists(ASSOCQUERY query, PCWSTR key) override
Definition: elements.cpp:914
#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:235
#define ASSOCQUERY_COMMAND
Definition: elements.cpp:48
#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 1498 of file elements.cpp.

1499{
1500 *pClassID = CLSID_AssocClientElement;
1501 return S_OK;
1502}
#define S_OK
Definition: intsafe.h:52

◆ QueryString()

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

Definition at line 1467 of file elements.cpp.

1468{
1469 HRESULT hr;
1470
1472 {
1474 if (SUCCEEDED(hr))
1475 return hr;
1476
1477 IAssociationElementOld* pDelegate;
1478 HRESULT hr = _GetVerbDelegate(key, &pDelegate);
1480 return hr;
1481
1482 hr = pDelegate->QueryString(ASSOCQUERY_DELEGATE, L"open", ppszValue);
1483 pDelegate->Release();
1484 return hr;
1485 }
1486
1488 {
1489 hr = CAssocElement::QueryString(ASSOCQUERY_LOCALIZEDSTRING, L"LocalizedString", ppszValue);
1490 if (SUCCEEDED(hr))
1491 return hr;
1493 }
1494
1495 return CAssocShellElement::QueryString(query, key, ppszValue);
1496}
STDMETHODIMP QueryString(ASSOCQUERY query, PCWSTR key, PWSTR *ppszValue) override
Definition: elements.cpp:765
virtual HRESULT _GetVerbDelegate(PCWSTR pszSrc, IAssociationElementOld **ppElement)
Definition: elements.cpp:854
STDMETHODIMP QueryString(ASSOCQUERY query, PCWSTR key, PWSTR *ppszValue) override
Definition: elements.cpp:884
#define ASSOCQUERY_DELEGATE
Definition: elements.cpp:57
#define ASSOCQUERY_LOCALIZEDSTRING
Definition: elements.cpp:53
#define ASSOCQUERY_FRIENDLYAPPNAME
Definition: elements.cpp:46
#define ASSOCQUERY_DEFAULTICON
Definition: elements.cpp:40
#define ASSOCQUERY_SDED
Definition: elements.cpp:36
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: