?? ordinal.c
字號:
/*
* SHLWAPI ordinal functions
*
* Copyright 1997 Marcus Meissner
* 1998 J黵gen Schmied
* 2001-2003 Jon Griffiths
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#define COM_NO_WINDOWS_H
#include "config.h"
#include "wine/port.h"
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
#define COBJMACROS
#define NONAMELESSUNION
#define NONAMELESSSTRUCT
#include "windef.h"
#include "winbase.h"
#include "winuser.h"
#include "winnls.h"
#include "objbase.h"
#include "docobj.h"
#include "exdisp.h"
#include "shlguid.h"
#include "wingdi.h"
#include "shlobj.h"
#include "shellapi.h"
#include "commdlg.h"
#include "wine/unicode.h"
#include "winreg.h"
#include "wine/debug.h"
#include "shlwapi.h"
WINE_DEFAULT_DEBUG_CHANNEL(shell);
/* Get a function pointer from a DLL handle */
#define GET_FUNC(func, module, name, fail) \
do { \
if (!func) { \
if (!SHLWAPI_h##module && !(SHLWAPI_h##module = LoadLibraryA(#module ".dll"))) return fail; \
func = (fn##func)GetProcAddress(SHLWAPI_h##module, name); \
if (!func) return fail; \
} \
} while (0)
/* DLL handles for late bound calls */
extern HINSTANCE shlwapi_hInstance;
extern HMODULE SHLWAPI_hshell32;
extern HMODULE SHLWAPI_hwinmm;
extern HMODULE SHLWAPI_hcomdlg32;
extern HMODULE SHLWAPI_hcomctl32;
extern HMODULE SHLWAPI_hmpr;
extern HMODULE SHLWAPI_hurlmon;
extern HMODULE SHLWAPI_hversion;
extern DWORD SHLWAPI_ThreadRef_index;
/* Function pointers for GET_FUNC macro; these need to be global because of gcc bug */
typedef LPITEMIDLIST (WINAPI *fnpSHBrowseForFolderW)(LPBROWSEINFOW);
static fnpSHBrowseForFolderW pSHBrowseForFolderW;
typedef BOOL (WINAPI *fnpPlaySoundW)(LPCWSTR, HMODULE, DWORD);
static fnpPlaySoundW pPlaySoundW;
typedef DWORD (WINAPI *fnpSHGetFileInfoW)(LPCWSTR,DWORD,SHFILEINFOW*,UINT,UINT);
static fnpSHGetFileInfoW pSHGetFileInfoW;
typedef UINT (WINAPI *fnpDragQueryFileW)(HDROP, UINT, LPWSTR, UINT);
static fnpDragQueryFileW pDragQueryFileW;
typedef BOOL (WINAPI *fnpSHGetPathFromIDListW)(LPCITEMIDLIST, LPWSTR);
static fnpSHGetPathFromIDListW pSHGetPathFromIDListW;
typedef BOOL (WINAPI *fnpShellExecuteExW)(LPSHELLEXECUTEINFOW);
static fnpShellExecuteExW pShellExecuteExW;
typedef HICON (WINAPI *fnpSHFileOperationW)(LPSHFILEOPSTRUCTW);
static fnpSHFileOperationW pSHFileOperationW;
typedef UINT (WINAPI *fnpExtractIconExW)(LPCWSTR, INT,HICON *,HICON *, UINT);
static fnpExtractIconExW pExtractIconExW;
typedef BOOL (WINAPI *fnpSHGetNewLinkInfoW)(LPCWSTR, LPCWSTR, LPCWSTR, BOOL*, UINT);
static fnpSHGetNewLinkInfoW pSHGetNewLinkInfoW;
typedef HRESULT (WINAPI *fnpSHDefExtractIconW)(LPCWSTR, int, UINT, HICON*, HICON*, UINT);
static fnpSHDefExtractIconW pSHDefExtractIconW;
typedef HICON (WINAPI *fnpExtractIconW)(HINSTANCE, LPCWSTR, UINT);
static fnpExtractIconW pExtractIconW;
typedef BOOL (WINAPI *fnpGetSaveFileNameW)(LPOPENFILENAMEW);
static fnpGetSaveFileNameW pGetSaveFileNameW;
typedef DWORD (WINAPI *fnpWNetRestoreConnectionW)(HWND, LPWSTR);
static fnpWNetRestoreConnectionW pWNetRestoreConnectionW;
typedef DWORD (WINAPI *fnpWNetGetLastErrorW)(LPDWORD, LPWSTR, DWORD, LPWSTR, DWORD);
static fnpWNetGetLastErrorW pWNetGetLastErrorW;
typedef BOOL (WINAPI *fnpPageSetupDlgW)(LPPAGESETUPDLGW);
static fnpPageSetupDlgW pPageSetupDlgW;
typedef BOOL (WINAPI *fnpPrintDlgW)(LPPRINTDLGW);
static fnpPrintDlgW pPrintDlgW;
typedef BOOL (WINAPI *fnpGetOpenFileNameW)(LPOPENFILENAMEW);
static fnpGetOpenFileNameW pGetOpenFileNameW;
typedef DWORD (WINAPI *fnpGetFileVersionInfoSizeW)(LPCWSTR,LPDWORD);
static fnpGetFileVersionInfoSizeW pGetFileVersionInfoSizeW;
typedef BOOL (WINAPI *fnpGetFileVersionInfoW)(LPCWSTR,DWORD,DWORD,LPVOID);
static fnpGetFileVersionInfoW pGetFileVersionInfoW;
typedef WORD (WINAPI *fnpVerQueryValueW)(LPVOID,LPCWSTR,LPVOID*,UINT*);
static fnpVerQueryValueW pVerQueryValueW;
typedef BOOL (WINAPI *fnpCOMCTL32_417)(HDC,INT,INT,UINT,const RECT*,LPCWSTR,UINT,const INT*);
static fnpCOMCTL32_417 pCOMCTL32_417;
typedef HRESULT (WINAPI *fnpDllGetVersion)(DLLVERSIONINFO*);
static fnpDllGetVersion pDllGetVersion;
typedef HRESULT (WINAPI *fnpCreateFormatEnumerator)(UINT,FORMATETC*,IEnumFORMATETC**);
static fnpCreateFormatEnumerator pCreateFormatEnumerator;
typedef HRESULT (WINAPI *fnpRegisterFormatEnumerator)(LPBC,IEnumFORMATETC*,DWORD);
static fnpRegisterFormatEnumerator pRegisterFormatEnumerator;
HRESULT WINAPI IUnknown_QueryService(IUnknown*,REFGUID,REFIID,LPVOID*);
HRESULT WINAPI SHInvokeCommand(HWND,IShellFolder*,LPCITEMIDLIST,BOOL);
HRESULT WINAPI CLSIDFromStringWrap(LPCWSTR,CLSID*);
BOOL WINAPI SHAboutInfoW(LPWSTR,DWORD);
/*
NOTES: Most functions exported by ordinal seem to be superflous.
The reason for these functions to be there is to provide a wrapper
for unicode functions to provide these functions on systems without
unicode functions eg. win95/win98. Since we have such functions we just
call these. If running Wine with native DLLs, some late bound calls may
fail. However, it is better to implement the functions in the forward DLL
and recommend the builtin rather than reimplementing the calls here!
*/
/*************************************************************************
* SHLWAPI_DupSharedHandle
*
* Internal implemetation of SHLWAPI_11.
*/
static
HANDLE WINAPI SHLWAPI_DupSharedHandle(HANDLE hShared, DWORD dwDstProcId,
DWORD dwSrcProcId, DWORD dwAccess,
DWORD dwOptions)
{
HANDLE hDst, hSrc;
DWORD dwMyProcId = GetCurrentProcessId();
HANDLE hRet = NULL;
TRACE("(%p,%ld,%ld,%08lx,%08lx)\n", hShared, dwDstProcId, dwSrcProcId,
dwAccess, dwOptions);
/* Get dest process handle */
if (dwDstProcId == dwMyProcId)
hDst = GetCurrentProcess();
else
hDst = OpenProcess(PROCESS_DUP_HANDLE, 0, dwDstProcId);
if (hDst)
{
/* Get src process handle */
if (dwSrcProcId == dwMyProcId)
hSrc = GetCurrentProcess();
else
hSrc = OpenProcess(PROCESS_DUP_HANDLE, 0, dwSrcProcId);
if (hSrc)
{
/* Make handle available to dest process */
if (!DuplicateHandle(hDst, hShared, hSrc, &hRet,
dwAccess, 0, dwOptions | DUPLICATE_SAME_ACCESS))
hRet = NULL;
if (dwSrcProcId != dwMyProcId)
CloseHandle(hSrc);
}
if (dwDstProcId != dwMyProcId)
CloseHandle(hDst);
}
TRACE("Returning handle %p\n", hRet);
return hRet;
}
/*************************************************************************
* @ [SHLWAPI.7]
*
* Create a block of sharable memory and initialise it with data.
*
* PARAMS
* lpvData [I] Pointer to data to write
* dwSize [I] Size of data
* dwProcId [I] ID of process owning data
*
* RETURNS
* Success: A shared memory handle
* Failure: NULL
*
* NOTES
* Ordinals 7-11 provide a set of calls to create shared memory between a
* group of processes. The shared memory is treated opaquely in that its size
* is not exposed to clients who map it. This is accomplished by storing
* the size of the map as the first DWORD of mapped data, and then offsetting
* the view pointer returned by this size.
*
*/
HANDLE WINAPI SHAllocShared(LPCVOID lpvData, DWORD dwSize, DWORD dwProcId)
{
HANDLE hMap;
LPVOID pMapped;
HANDLE hRet = NULL;
TRACE("(%p,%ld,%ld)\n", lpvData, dwSize, dwProcId);
/* Create file mapping of the correct length */
hMap = CreateFileMappingA(INVALID_HANDLE_VALUE, NULL, FILE_MAP_READ, 0,
dwSize + sizeof(dwSize), NULL);
if (!hMap)
return hRet;
/* Get a view in our process address space */
pMapped = MapViewOfFile(hMap, FILE_MAP_READ | FILE_MAP_WRITE, 0, 0, 0);
if (pMapped)
{
/* Write size of data, followed by the data, to the view */
*((DWORD*)pMapped) = dwSize;
if (lpvData)
memcpy((char *) pMapped + sizeof(dwSize), lpvData, dwSize);
/* Release view. All further views mapped will be opaque */
UnmapViewOfFile(pMapped);
hRet = SHLWAPI_DupSharedHandle(hMap, dwProcId,
GetCurrentProcessId(), FILE_MAP_ALL_ACCESS,
DUPLICATE_SAME_ACCESS);
}
CloseHandle(hMap);
return hRet;
}
/*************************************************************************
* @ [SHLWAPI.8]
*
* Get a pointer to a block of shared memory from a shared memory handle.
*
* PARAMS
* hShared [I] Shared memory handle
* dwProcId [I] ID of process owning hShared
*
* RETURNS
* Success: A pointer to the shared memory
* Failure: NULL
*
*/
PVOID WINAPI SHLockShared(HANDLE hShared, DWORD dwProcId)
{
HANDLE hDup;
LPVOID pMapped;
TRACE("(%p %ld)\n", hShared, dwProcId);
/* Get handle to shared memory for current process */
hDup = SHLWAPI_DupSharedHandle(hShared, dwProcId, GetCurrentProcessId(),
FILE_MAP_ALL_ACCESS, 0);
/* Get View */
pMapped = MapViewOfFile(hDup, FILE_MAP_READ | FILE_MAP_WRITE, 0, 0, 0);
CloseHandle(hDup);
if (pMapped)
return (char *) pMapped + sizeof(DWORD); /* Hide size */
return NULL;
}
/*************************************************************************
* @ [SHLWAPI.9]
*
* Release a pointer to a block of shared memory.
*
* PARAMS
* lpView [I] Shared memory pointer
*
* RETURNS
* Success: TRUE
* Failure: FALSE
*
*/
BOOL WINAPI SHUnlockShared(LPVOID lpView)
{
TRACE("(%p)\n", lpView);
return UnmapViewOfFile((char *) lpView - sizeof(DWORD)); /* Include size */
}
/*************************************************************************
* @ [SHLWAPI.10]
*
* Destroy a block of sharable memory.
*
* PARAMS
* hShared [I] Shared memory handle
* dwProcId [I] ID of process owning hShared
*
* RETURNS
* Success: TRUE
* Failure: FALSE
*
*/
BOOL WINAPI SHFreeShared(HANDLE hShared, DWORD dwProcId)
{
HANDLE hClose;
TRACE("(%p %ld)\n", hShared, dwProcId);
/* Get a copy of the handle for our process, closing the source handle */
hClose = SHLWAPI_DupSharedHandle(hShared, dwProcId, GetCurrentProcessId(),
FILE_MAP_ALL_ACCESS,DUPLICATE_CLOSE_SOURCE);
/* Close local copy */
return CloseHandle(hClose);
}
/*************************************************************************
* @ [SHLWAPI.11]
*
* Copy a sharable memory handle from one process to another.
*
* PARAMS
* hShared [I] Shared memory handle to duplicate
* dwDstProcId [I] ID of the process wanting the duplicated handle
* dwSrcProcId [I] ID of the process owning hShared
* dwAccess [I] Desired DuplicateHandle() access
* dwOptions [I] Desired DuplicateHandle() options
*
* RETURNS
* Success: A handle suitable for use by the dwDstProcId process.
* Failure: A NULL handle.
*
*/
HANDLE WINAPI SHMapHandle(HANDLE hShared, DWORD dwDstProcId, DWORD dwSrcProcId,
DWORD dwAccess, DWORD dwOptions)
{
HANDLE hRet;
hRet = SHLWAPI_DupSharedHandle(hShared, dwDstProcId, dwSrcProcId,
dwAccess, dwOptions);
return hRet;
}
/*************************************************************************
* @ [SHLWAPI.13]
*
* Create and register a clipboard enumerator for a web browser.
*
* PARAMS
* lpBC [I] Binding context
* lpUnknown [I] An object exposing the IWebBrowserApp interface
*
* RETURNS
* Success: S_OK.
* Failure: An HRESULT error code.
*
* NOTES
* The enumerator is stored as a property of the web browser. If it does not
* yet exist, it is created and set before being registered.
*/
HRESULT WINAPI RegisterDefaultAcceptHeaders(LPBC lpBC, IUnknown *lpUnknown)
{
static const WCHAR szProperty[] = { '{','D','0','F','C','A','4','2','0',
'-','D','3','F','5','-','1','1','C','F', '-','B','2','1','1','-','0',
'0','A','A','0','0','4','A','E','8','3','7','}','\0' };
IEnumFORMATETC* pIEnumFormatEtc = NULL;
VARIANTARG var;
HRESULT hRet;
IWebBrowserApp* pBrowser = NULL;
TRACE("(%p, %p)\n", lpBC, lpUnknown);
/* Get An IWebBrowserApp interface from lpUnknown */
hRet = IUnknown_QueryService(lpUnknown, &IID_IWebBrowserApp, &IID_IWebBrowserApp, (PVOID)&pBrowser);
if (FAILED(hRet) || !pBrowser)
return E_NOINTERFACE;
V_VT(&var) = VT_EMPTY;
/* The property we get is the browsers clipboard enumerator */
hRet = IWebBrowserApp_GetProperty(pBrowser, (BSTR)szProperty, &var);
if (FAILED(hRet))
return hRet;
if (V_VT(&var) == VT_EMPTY)
{
/* Iterate through accepted documents and RegisterClipBoardFormatA() them */
char szKeyBuff[128], szValueBuff[128];
DWORD dwKeySize, dwValueSize, dwRet = 0, dwCount = 0, dwNumValues, dwType;
FORMATETC* formatList, *format;
HKEY hDocs;
TRACE("Registering formats and creating IEnumFORMATETC instance\n");
if (!RegOpenKeyA(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows\\Current"
"Version\\Internet Settings\\Accepted Documents", &hDocs))
return E_FAIL;
/* Get count of values in key */
while (!dwRet)
{
dwKeySize = sizeof(szKeyBuff);
dwRet = RegEnumValueA(hDocs,dwCount,szKeyBuff,&dwKeySize,0,&dwType,0,0);
dwCount++;
}
dwNumValues = dwCount;
/* Note: dwCount = number of items + 1; The extra item is the end node */
format = formatList = HeapAlloc(GetProcessHeap(), 0, dwCount * sizeof(FORMATETC));
if (!formatList)
return E_OUTOFMEMORY;
if (dwNumValues > 1)
{
dwRet = 0;
dwCount = 0;
dwNumValues--;
/* Register clipboard formats for the values and populate format list */
while(!dwRet && dwCount < dwNumValues)
{
dwKeySize = sizeof(szKeyBuff);
dwValueSize = sizeof(szValueBuff);
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -