📄 shell.c
字号:
/*
* Shell Library Functions
*
* Copyright 1998 Marcus Meissner
* Copyright 2000 Juergen Schmied
* Copyright 2002 Eric Pouech
*
* 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
*/
#include "config.h"
#include "wine/port.h"
#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
#include <ctype.h>
#include "windef.h"
#include "winbase.h"
#include "winerror.h"
#include "winreg.h"
#include "wownt32.h"
#include "dlgs.h"
#include "shellapi.h"
#include "winuser.h"
#include "wingdi.h"
#include "shlobj.h"
#include "shlwapi.h"
#include "ddeml.h"
#include "wine/winbase16.h"
#include "wine/winuser16.h"
#include "shell32_main.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(shell);
typedef struct { /* structure for dropped files */
WORD wSize;
POINT16 ptMousePos;
BOOL16 fInNonClientArea;
/* memory block with filenames follows */
} DROPFILESTRUCT16, *LPDROPFILESTRUCT16;
static const char* lpstrMsgWndCreated = "OTHERWINDOWCREATED";
static const char* lpstrMsgWndDestroyed = "OTHERWINDOWDESTROYED";
static const char* lpstrMsgShellActivate = "ACTIVATESHELLWINDOW";
static HWND SHELL_hWnd = 0;
static HHOOK SHELL_hHook = 0;
static UINT uMsgWndCreated = 0;
static UINT uMsgWndDestroyed = 0;
static UINT uMsgShellActivate = 0;
/***********************************************************************
* DllEntryPoint [SHELL.101]
*
* Initialization code for shell.dll. Automatically loads the
* 32-bit shell32.dll to allow thunking up to 32-bit code.
*
* RETURNS
* Success: TRUE. Initialization completed successfully.
* Failure: FALSE.
*/
BOOL WINAPI SHELL_DllEntryPoint(DWORD Reason, HINSTANCE16 hInst,
WORD ds, WORD HeapSize, DWORD res1, WORD res2)
{
return TRUE;
}
/*************************************************************************
* DragAcceptFiles [SHELL.9]
*/
void WINAPI DragAcceptFiles16(HWND16 hWnd, BOOL16 b)
{
DragAcceptFiles(HWND_32(hWnd), b);
}
/*************************************************************************
* DragQueryFile [SHELL.11]
*/
UINT16 WINAPI DragQueryFile16(
HDROP16 hDrop,
WORD wFile,
LPSTR lpszFile,
WORD wLength)
{
LPSTR lpDrop;
UINT i = 0;
LPDROPFILESTRUCT16 lpDropFileStruct = (LPDROPFILESTRUCT16) GlobalLock16(hDrop);
TRACE("(%04x, %x, %p, %u)\n", hDrop,wFile,lpszFile,wLength);
if(!lpDropFileStruct) goto end;
lpDrop = (LPSTR) lpDropFileStruct + lpDropFileStruct->wSize;
while (i++ < wFile)
{
while (*lpDrop++); /* skip filename */
if (!*lpDrop)
{
i = (wFile == 0xFFFF) ? i : 0;
goto end;
}
}
i = strlen(lpDrop);
i++;
if (!lpszFile ) goto end; /* needed buffer size */
i = (wLength > i) ? i : wLength;
lstrcpynA (lpszFile, lpDrop, i);
end:
GlobalUnlock16(hDrop);
return i;
}
/*************************************************************************
* DragFinish [SHELL.12]
*/
void WINAPI DragFinish16(HDROP16 h)
{
TRACE("\n");
GlobalFree16((HGLOBAL16)h);
}
/*************************************************************************
* DragQueryPoint [SHELL.13]
*/
BOOL16 WINAPI DragQueryPoint16(HDROP16 hDrop, POINT16 *p)
{
LPDROPFILESTRUCT16 lpDropFileStruct;
BOOL16 bRet;
TRACE("\n");
lpDropFileStruct = (LPDROPFILESTRUCT16) GlobalLock16(hDrop);
memcpy(p,&lpDropFileStruct->ptMousePos,sizeof(POINT16));
bRet = lpDropFileStruct->fInNonClientArea;
GlobalUnlock16(hDrop);
return bRet;
}
/*************************************************************************
* FindExecutable (SHELL.21)
*/
HINSTANCE16 WINAPI FindExecutable16( LPCSTR lpFile, LPCSTR lpDirectory,
LPSTR lpResult )
{ return HINSTANCE_16(FindExecutableA( lpFile, lpDirectory, lpResult ));
}
/*************************************************************************
* AboutDlgProc (SHELL.33)
*/
BOOL16 WINAPI AboutDlgProc16( HWND16 hWnd, UINT16 msg, WPARAM16 wParam,
LPARAM lParam )
{ return (BOOL16)AboutDlgProc( HWND_32(hWnd), msg, wParam, lParam );
}
/*************************************************************************
* ShellAbout (SHELL.22)
*/
BOOL16 WINAPI ShellAbout16( HWND16 hWnd, LPCSTR szApp, LPCSTR szOtherStuff,
HICON16 hIcon )
{ return ShellAboutA( HWND_32(hWnd), szApp, szOtherStuff, HICON_32(hIcon) );
}
/*************************************************************************
* InternalExtractIcon [SHELL.39]
*
* This abortion is called directly by Progman
*/
HGLOBAL16 WINAPI InternalExtractIcon16(HINSTANCE16 hInstance,
LPCSTR lpszExeFileName, UINT16 nIconIndex, WORD n )
{
HGLOBAL16 hRet = 0;
HICON16 *RetPtr = NULL;
OFSTRUCT ofs;
TRACE("(%04x,file %s,start %d,extract %d\n",
hInstance, lpszExeFileName, nIconIndex, n);
if (!n)
return 0;
hRet = GlobalAlloc16(GMEM_FIXED | GMEM_ZEROINIT, sizeof(*RetPtr) * n);
RetPtr = (HICON16*)GlobalLock16(hRet);
if (nIconIndex == (UINT16)-1) /* get number of icons */
{
RetPtr[0] = PrivateExtractIconsA(ofs.szPathName, 0, 0, 0, NULL, NULL, 0, LR_DEFAULTCOLOR);
}
else
{
UINT ret;
HICON *icons;
icons = HeapAlloc(GetProcessHeap(), 0, n * sizeof(*icons));
ret = PrivateExtractIconsA(ofs.szPathName, nIconIndex,
GetSystemMetrics(SM_CXICON),
GetSystemMetrics(SM_CYICON),
icons, NULL, n, LR_DEFAULTCOLOR);
if ((ret != 0xffffffff) && ret)
{
int i;
for (i = 0; i < n; i++) RetPtr[i] = HICON_16(icons[i]);
}
else
{
GlobalFree16(hRet);
hRet = 0;
}
HeapFree(GetProcessHeap(), 0, icons);
}
return hRet;
}
/*************************************************************************
* ExtractIcon (SHELL.34)
*/
HICON16 WINAPI ExtractIcon16( HINSTANCE16 hInstance, LPCSTR lpszExeFileName,
UINT16 nIconIndex )
{ TRACE("\n");
return HICON_16(ExtractIconA(HINSTANCE_32(hInstance), lpszExeFileName, nIconIndex));
}
/*************************************************************************
* ExtractIconEx (SHELL.40)
*/
HICON16 WINAPI ExtractIconEx16(
LPCSTR lpszFile, INT16 nIconIndex, HICON16 *phiconLarge,
HICON16 *phiconSmall, UINT16 nIcons
) {
HICON *ilarge,*ismall;
UINT16 ret;
int i;
if (phiconLarge)
ilarge = HeapAlloc(GetProcessHeap(),0,nIcons*sizeof(HICON));
else
ilarge = NULL;
if (phiconSmall)
ismall = HeapAlloc(GetProcessHeap(),0,nIcons*sizeof(HICON));
else
ismall = NULL;
ret = HICON_16(ExtractIconExA(lpszFile,nIconIndex,ilarge,ismall,nIcons));
if (ilarge) {
for (i=0;i<nIcons;i++)
phiconLarge[i]=HICON_16(ilarge[i]);
HeapFree(GetProcessHeap(),0,ilarge);
}
if (ismall) {
for (i=0;i<nIcons;i++)
phiconSmall[i]=HICON_16(ismall[i]);
HeapFree(GetProcessHeap(),0,ismall);
}
return ret;
}
/*************************************************************************
* ExtractAssociatedIcon [SHELL.36]
*
* Return icon for given file (either from file itself or from associated
* executable) and patch parameters if needed.
*/
HICON16 WINAPI ExtractAssociatedIcon16(HINSTANCE16 hInst, LPSTR lpIconPath, LPWORD lpiIcon)
{
return HICON_16(ExtractAssociatedIconA(HINSTANCE_32(hInst), lpIconPath,
lpiIcon));
}
/*************************************************************************
* FindEnvironmentString [SHELL.38]
*
* Returns a pointer into the DOS environment... Ugh.
*/
static LPSTR SHELL_FindString(LPSTR lpEnv, LPCSTR entry)
{ UINT16 l;
TRACE("\n");
l = strlen(entry);
for( ; *lpEnv ; lpEnv+=strlen(lpEnv)+1 )
{ if( strncasecmp(lpEnv, entry, l) )
continue;
if( !*(lpEnv+l) )
return (lpEnv + l); /* empty entry */
else if ( *(lpEnv+l)== '=' )
return (lpEnv + l + 1);
}
return NULL;
}
/**********************************************************************/
SEGPTR WINAPI FindEnvironmentString16(LPSTR str)
{ SEGPTR spEnv;
LPSTR lpEnv,lpString;
TRACE("\n");
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -