- Implementation of HCR_GetExecuteCommandExW for internal use.

- New inline function  __SHCloneStrAtoW.
This commit is contained in:
Marcelo Duarte 2003-12-10 00:39:31 +00:00 committed by Alexandre Julliard
parent 8b773b125a
commit 36002739c7
3 changed files with 51 additions and 5 deletions

View File

@ -149,7 +149,7 @@ BOOL HCR_GetExecuteCommandA(LPCSTR szClass, LPCSTR szVerb, LPSTR szDest, DWORD l
return FALSE;
}
BOOL HCR_GetExecuteCommandEx( HKEY hkeyClass, LPCSTR szClass, LPCSTR szVerb, LPSTR szDest, DWORD len )
BOOL HCR_GetExecuteCommandExA( HKEY hkeyClass, LPCSTR szClass, LPCSTR szVerb, LPSTR szDest, DWORD len )
{
BOOL ret = FALSE;
@ -174,6 +174,34 @@ BOOL HCR_GetExecuteCommandEx( HKEY hkeyClass, LPCSTR szClass, LPCSTR szVerb, LPS
return ret;
}
BOOL HCR_GetExecuteCommandExW( HKEY hkeyClass, LPCWSTR szClass, LPCWSTR szVerb, LPWSTR szDest, DWORD len )
{
static const WCHAR swShell[] = {'\\','s','h','e','l','l','\\',0};
static const WCHAR swCommand[] = {'\\','c','o','m','m','a','n','d',0};
BOOL ret = FALSE;
TRACE("%p %s %s %p\n", hkeyClass, debugstr_w(szClass), debugstr_w(szVerb), szDest);
if (szClass)
RegOpenKeyExW(hkeyClass,szClass,0,0x02000000,&hkeyClass);
if (hkeyClass)
{
WCHAR sTemp[MAX_PATH];
lstrcpyW(sTemp, swShell);
lstrcatW(sTemp, szVerb);
lstrcatW(sTemp, swCommand);
ret = (ERROR_SUCCESS == SHGetValueW(hkeyClass, sTemp, NULL, NULL, szDest, &len));
if (szClass)
RegCloseKey(hkeyClass);
}
TRACE("-- %s\n", debugstr_w(szDest) );
return ret;
}
/***************************************************************************************
* HCR_GetDefaultIcon [internal]
*

View File

@ -35,6 +35,7 @@
#include "shlobj.h"
#include "shellapi.h"
#include "wine/windef16.h"
#include "wine/unicode.h"
/*******************************************
* global SHELL32.DLL variables
@ -62,6 +63,7 @@ INT SIC_GetIconIndex (LPCSTR sSourceFile, INT dwSourceIndex );
/* Classes Root */
BOOL HCR_MapTypeToValueW(LPCWSTR szExtension, LPWSTR szFileType, DWORD len, BOOL bPrependDot);
BOOL HCR_GetExecuteCommandW(LPCWSTR szClass, LPCWSTR szVerb, LPWSTR szDest, DWORD len);
BOOL HCR_GetExecuteCommandExW( HKEY hkeyClass, LPCWSTR szClass, LPCWSTR szVerb, LPWSTR szDest, DWORD len );
BOOL HCR_GetDefaultIconW(LPCWSTR szClass, LPWSTR szDest, DWORD len, LPDWORD dwNr);
BOOL HCR_GetDefaultIconFromGUIDW(REFIID riid, LPWSTR szDest, DWORD len, LPDWORD dwNr);
BOOL HCR_GetClassNameW(REFIID riid, LPWSTR szDest, DWORD len);
@ -69,10 +71,10 @@ BOOL HCR_GetClassNameW(REFIID riid, LPWSTR szDest, DWORD len);
/* ANSI versions of above functions, supposed to go away as soon as they are not used anymore */
BOOL HCR_MapTypeToValueA(LPCSTR szExtension, LPSTR szFileType, DWORD len, BOOL bPrependDot);
BOOL HCR_GetExecuteCommandA(LPCSTR szClass, LPCSTR szVerb, LPSTR szDest, DWORD len);
BOOL HCR_GetExecuteCommandExA( HKEY hkeyClass, LPCSTR szClass, LPCSTR szVerb, LPSTR szDest, DWORD len );
BOOL HCR_GetDefaultIconA(LPCSTR szClass, LPSTR szDest, DWORD len, LPDWORD dwNr);
BOOL HCR_GetClassNameA(REFIID riid, LPSTR szDest, DWORD len);
BOOL HCR_GetExecuteCommandEx ( HKEY hkeyClass, LPCSTR szClass, LPCSTR szVerb, LPSTR szDest, DWORD len );
BOOL HCR_GetFolderAttributes(REFIID riid, LPDWORD szDest);
INT_PTR CALLBACK AboutDlgProc(HWND,UINT,WPARAM,LPARAM);
@ -202,8 +204,8 @@ inline static BOOL SHELL_OsIsUnicode(void)
};
inline static void __SHCloneStrA(char ** target,const char * source)
{
*target = SHAlloc(strlen(source)+1); \
strcpy(*target, source); \
*target = SHAlloc(strlen(source)+1);
strcpy(*target, source);
}
inline static void __SHCloneStrWtoA(char ** target, const WCHAR * source)
@ -213,6 +215,20 @@ inline static void __SHCloneStrWtoA(char ** target, const WCHAR * source)
WideCharToMultiByte(CP_ACP, 0, source, -1, *target, len, NULL, NULL);
}
inline static void __SHCloneStrW(WCHAR ** target, const WCHAR * source)
{
*target = SHAlloc( (strlenW(source)+1) * sizeof(WCHAR) );
strcpyW(*target, source);
}
inline static WCHAR * __SHCloneStrAtoW(WCHAR ** target, const char * source)
{
int len = MultiByteToWideChar(CP_ACP, 0, source, -1, NULL, 0);
*target = SHAlloc(len*sizeof(WCHAR));
MultiByteToWideChar(CP_ACP, 0, source, -1, *target, len);
return *target;
}
/* handle conversions */
#define HICON_16(h32) (LOWORD(h32))
#define HICON_32(h16) ((HICON)(ULONG_PTR)(h16))
@ -221,5 +237,7 @@ inline static void __SHCloneStrWtoA(char ** target, const WCHAR * source)
typedef UINT (*SHELL_ExecuteA1632)(char *lpCmd, void *env, LPSHELLEXECUTEINFOA sei, BOOL shWait);
BOOL WINAPI ShellExecuteExA32 (LPSHELLEXECUTEINFOA sei, SHELL_ExecuteA1632 execfunc);
typedef UINT (*SHELL_ExecuteW32)(WCHAR *lpCmd, void *env, LPSHELLEXECUTEINFOW sei, BOOL shWait);
BOOL WINAPI ShellExecuteExW32 (LPSHELLEXECUTEINFOW sei, SHELL_ExecuteW32 execfunc);
#endif

View File

@ -688,7 +688,7 @@ BOOL WINAPI ShellExecuteExA32 (LPSHELLEXECUTEINFOA sei, SHELL_ExecuteA1632 execf
/* the Commandline contains 'c:\Path\wordpad.exe "%1"' */
/* FIXME: szCommandline should not be of a fixed size. Plus MAX_PATH is way too short! */
if (sei->fMask & SEE_MASK_CLASSKEY)
HCR_GetExecuteCommandEx(sei->hkeyClass,
HCR_GetExecuteCommandExA(sei->hkeyClass,
(sei->fMask & SEE_MASK_CLASSNAME) ? sei->lpClass: NULL,
(sei->lpVerb) ? sei->lpVerb : "open", szCommandline, sizeof(szCommandline));
else if (sei->fMask & SEE_MASK_CLASSNAME)