mirror of
https://github.com/reactos/wine.git
synced 2024-12-11 05:14:25 +00:00
2d93d000a4
Tue May 21 14:06:07 1996 Alexandre Julliard <julliard@lrc.epfl.ch> * [controls/button.c] Made ButtonWndProc a 32-bit window procedure. * [controls/desktop.c] Made DesktopWndProc a 32-bit window procedure. Added handling of WM_SETCURSOR. * [controls/menu.c] Allocate menu items and strings on the 32-bit system heap. Implemented Win32 versions for ChangeMenu, InsertMenu, ModifyMenu, AppendMenu and LoadMenuIndirect. * [controls/widgets.c] Added possibility to have 32-bit built-in classes. * [files/drive.c] Implemented GetLogicalDrive() and GetLogicalDriveStrings(). * [misc/spy.c] [include/spy.h] Added support for spying Win32 messages. * [loader/builtin.c] Fixed bug in -dll option parsing. * [memory/local.c] Added back the change by Huw D. M. Davies to free the block in LocalRealloc() before allocating the new one. * [objects/bitmap.c] [objects/cursoricon.c] [objects/oembitmap.c] Fixed bug in bitmap size that caused memory corruption for 24bpp. * [windows/defwnd.c] Implemented Win32 version of DefWindowProc(). * [windows/dialog.c] Implemented Win32 version of SendDlgItemMessage, Get/SetDlgItemText and Get/SetDlgItemInt. * [windows/mdi.c] Implemented Win32 version of DefFrameProc() and DefMDIChildProc(). Don't make a copy of the OBM bitmaps for every MDI window. * [windows/message.c] Implemented Win32 version of SendMessage(). * [windows/winproc.c] [windows/class.c] [windows/win.c] New scheme for 32-bit window procedures to replace aliases. All 32-bit window procedure get a 16-bit address pointing to a WINDOWPROC structure. Implemented Ansi<->Unicode translation for CallWindowProc(). Added translation of WM_DRAWITEM between Win16 and Win32. * [windows/win.c] [include/callback.h] Added ugly hack to build CREATESTRUCT on the stack when sending WM_NCCREATE. Implemented Win32 version of Get/SetWindowWord/Long and Get/SetWindowText. Fri May 17 10:20:16 1996 Albrecht Kleine <kleine@ak.sax.de> * [controls/button.c] Avoid gray text on gray background in disabled push buttons using a b/w raster and some raster operations (PatBlt,BitBlt). * [objects/text.c] DrawText(): don't draw an underbar anymore if DT_CALCRECT is set.
707 lines
20 KiB
C
707 lines
20 KiB
C
/*
|
|
* Shell Library Functions
|
|
*/
|
|
#include <stdlib.h>
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
#include <unistd.h>
|
|
#include <ctype.h>
|
|
#include "windows.h"
|
|
#include "file.h"
|
|
#include "shell.h"
|
|
#include "module.h"
|
|
#include "neexe.h"
|
|
#include "resource.h"
|
|
#include "dlgs.h"
|
|
#include "win.h"
|
|
#include "stddebug.h"
|
|
#include "debug.h"
|
|
#include "xmalloc.h"
|
|
#include "winreg.h"
|
|
|
|
extern HANDLE CURSORICON_LoadHandler( HANDLE, HINSTANCE, BOOL);
|
|
extern WORD GetIconID( HANDLE hResource, DWORD resType );
|
|
|
|
/*************************************************************************
|
|
* DragAcceptFiles [SHELL.9]
|
|
*/
|
|
void DragAcceptFiles(HWND hWnd, BOOL b)
|
|
{
|
|
WND* wnd = WIN_FindWndPtr(hWnd);
|
|
|
|
if( wnd )
|
|
wnd->dwExStyle = b? wnd->dwExStyle | WS_EX_ACCEPTFILES
|
|
: wnd->dwExStyle & ~WS_EX_ACCEPTFILES;
|
|
}
|
|
|
|
|
|
/*************************************************************************
|
|
* DragQueryFile [SHELL.11]
|
|
*/
|
|
UINT DragQueryFile(HDROP16 hDrop, WORD wFile, LPSTR lpszFile, WORD wLength)
|
|
{
|
|
/* hDrop is a global memory block allocated with GMEM_SHARE
|
|
* with DROPFILESTRUCT as a header and filenames following
|
|
* it, zero length filename is in the end */
|
|
|
|
LPDROPFILESTRUCT lpDropFileStruct;
|
|
LPSTR lpCurrent;
|
|
WORD i;
|
|
|
|
dprintf_reg(stddeb,"DragQueryFile(%04x, %i, %p, %u)\n",
|
|
hDrop,wFile,lpszFile,wLength);
|
|
|
|
lpDropFileStruct = (LPDROPFILESTRUCT) GlobalLock16(hDrop);
|
|
if(!lpDropFileStruct)
|
|
{
|
|
dprintf_reg(stddeb,"DragQueryFile: unable to lock handle!\n");
|
|
return 0;
|
|
}
|
|
lpCurrent = (LPSTR) lpDropFileStruct + lpDropFileStruct->wSize;
|
|
|
|
i = 0;
|
|
while (i++ < wFile)
|
|
{
|
|
while (*lpCurrent++); /* skip filename */
|
|
if (!*lpCurrent)
|
|
return (wFile == 0xFFFF) ? i : 0;
|
|
}
|
|
|
|
i = strlen(lpCurrent);
|
|
if (!lpszFile) return i+1; /* needed buffer size */
|
|
|
|
i = (wLength > i) ? i : wLength-1;
|
|
strncpy(lpszFile, lpCurrent, i);
|
|
lpszFile[i] = '\0';
|
|
|
|
GlobalUnlock16(hDrop);
|
|
return i;
|
|
}
|
|
|
|
|
|
/*************************************************************************
|
|
* DragFinish [SHELL.12]
|
|
*/
|
|
void DragFinish(HDROP16 h)
|
|
{
|
|
GlobalFree16((HGLOBAL16)h);
|
|
}
|
|
|
|
|
|
/*************************************************************************
|
|
* DragQueryPoint [SHELL.13]
|
|
*/
|
|
BOOL DragQueryPoint(HDROP16 hDrop, POINT16 *p)
|
|
{
|
|
LPDROPFILESTRUCT lpDropFileStruct;
|
|
BOOL bRet;
|
|
|
|
lpDropFileStruct = (LPDROPFILESTRUCT) GlobalLock16(hDrop);
|
|
|
|
memcpy(p,&lpDropFileStruct->ptMousePos,sizeof(POINT16));
|
|
bRet = lpDropFileStruct->fInNonClientArea;
|
|
|
|
GlobalUnlock16(hDrop);
|
|
return bRet;
|
|
}
|
|
|
|
|
|
/*************************************************************************
|
|
* ShellExecute [SHELL.20]
|
|
*/
|
|
HINSTANCE ShellExecute(HWND hWnd, LPCSTR lpOperation, LPCSTR lpFile, LPSTR lpParameters, LPCSTR lpDirectory, INT iShowCmd)
|
|
{
|
|
char cmd[400];
|
|
char *p,*x;
|
|
long len;
|
|
char subclass[200];
|
|
|
|
/* OK. We are supposed to lookup the program associated with lpFile,
|
|
* then to execute it using that program. If lpFile is a program,
|
|
* we have to pass the parameters. If an instance is already running,
|
|
* we might have to send DDE commands.
|
|
*
|
|
* FIXME: Should also look up WIN.INI [Extensions] section?
|
|
*/
|
|
|
|
dprintf_exec(stddeb, "ShellExecute(%04x,'%s','%s','%s','%s',%x)\n",
|
|
hWnd, lpOperation ? lpOperation:"<null>", lpFile ? lpFile:"<null>",
|
|
lpParameters ? lpParameters : "<null>",
|
|
lpDirectory ? lpDirectory : "<null>", iShowCmd);
|
|
|
|
if (lpFile==NULL) return 0; /* should not happen */
|
|
if (lpOperation==NULL) /* default is open */
|
|
lpOperation="open";
|
|
p=strrchr(lpFile,'.');
|
|
if (p!=NULL) {
|
|
x=p; /* the suffixes in the register database are lowercased */
|
|
while (*x) {*x=tolower(*x);x++;}
|
|
}
|
|
if (p==NULL || !strcmp(p,".exe")) {
|
|
p=".exe";
|
|
if (lpParameters) {
|
|
sprintf(cmd,"%s %s",lpFile,lpParameters);
|
|
} else {
|
|
strcpy(cmd,lpFile);
|
|
}
|
|
} else {
|
|
len=200;
|
|
if (RegQueryValue16((HKEY)HKEY_CLASSES_ROOT,p,subclass,&len)==SHELL_ERROR_SUCCESS) {
|
|
if (len>20)
|
|
fprintf(stddeb,"ShellExecute:subclass with len %ld? (%s), please report.\n",len,subclass);
|
|
subclass[len]='\0';
|
|
strcat(subclass,"\\shell\\");
|
|
strcat(subclass,lpOperation);
|
|
strcat(subclass,"\\command");
|
|
dprintf_exec(stddeb,"ShellExecute:looking for %s.\n",subclass);
|
|
len=400;
|
|
if (RegQueryValue16((HKEY)HKEY_CLASSES_ROOT,subclass,cmd,&len)==SHELL_ERROR_SUCCESS) {
|
|
char *t;
|
|
dprintf_exec(stddeb,"ShellExecute:...got %s\n",cmd);
|
|
cmd[len]='\0';
|
|
t=strstr(cmd,"%1");
|
|
if (t==NULL) {
|
|
strcat(cmd," ");
|
|
strcat(cmd,lpFile);
|
|
} else {
|
|
char *s;
|
|
s=xmalloc(len+strlen(lpFile)+10);
|
|
strncpy(s,cmd,t-cmd);
|
|
s[t-cmd]='\0';
|
|
strcat(s,lpFile);
|
|
strcat(s,t+2);
|
|
strcpy(cmd,s);
|
|
free(s);
|
|
}
|
|
/* does this use %x magic too? */
|
|
if (lpParameters) {
|
|
strcat(cmd," ");
|
|
strcat(cmd,lpParameters);
|
|
}
|
|
} else {
|
|
fprintf(stddeb,"ShellExecute: No %s\\shell\\%s\\command found for \"%s\" suffix.\n",subclass,lpOperation,p);
|
|
return (HINSTANCE)31; /* unknown type */
|
|
}
|
|
} else {
|
|
fprintf(stddeb,"ShellExecute: No operation found for \"%s\" suffix.\n",p);
|
|
return (HINSTANCE)31; /* file not found */
|
|
}
|
|
}
|
|
dprintf_exec(stddeb,"ShellExecute:starting %s\n",cmd);
|
|
return WinExec(cmd,iShowCmd);
|
|
}
|
|
|
|
|
|
/*************************************************************************
|
|
* FindExecutable [SHELL.21]
|
|
*/
|
|
HINSTANCE FindExecutable(LPCSTR lpFile, LPCSTR lpDirectory, LPSTR lpResult)
|
|
{
|
|
char *extension = NULL; /* pointer to file extension */
|
|
char tmpext[5]; /* local copy to mung as we please */
|
|
char filetype[256]; /* registry name for this filetype */
|
|
LONG filetypelen=256; /* length of above */
|
|
char command[256]; /* command from registry */
|
|
LONG commandlen=256; /* This is the most DOS can handle :) */
|
|
char buffer[256]; /* Used to GetProfileString */
|
|
HINSTANCE retval=31; /* default - 'No association was found' */
|
|
char *tok; /* token pointer */
|
|
int i; /* random counter */
|
|
|
|
dprintf_exec(stddeb, "FindExecutable: File %s, Dir %s\n",
|
|
(lpFile != NULL?lpFile:"-"),
|
|
(lpDirectory != NULL?lpDirectory:"-"));
|
|
|
|
lpResult[0]='\0'; /* Start off with an empty return string */
|
|
|
|
/* trap NULL parameters on entry */
|
|
if (( lpFile == NULL ) || ( lpDirectory == NULL ) ||
|
|
( lpResult == NULL ))
|
|
{
|
|
/* FIXME - should throw a warning, perhaps! */
|
|
return 2; /* File not found. Close enough, I guess. */
|
|
}
|
|
|
|
/* First thing we need is the file's extension */
|
|
extension = strchr( lpFile, '.' ); /* Assumes first "." is the one... */
|
|
if ((extension == NULL) || (extension == &lpFile[strlen(lpFile)]))
|
|
{
|
|
return 31; /* no association */
|
|
}
|
|
|
|
/* Make local copy & lowercase it for reg & 'programs=' lookup */
|
|
strncpy( tmpext, extension, 5 );
|
|
if (strlen(extension)<=4)
|
|
tmpext[strlen(extension)]='\0';
|
|
else
|
|
tmpext[4]='\0';
|
|
for (i=0;i<strlen(tmpext);i++) tmpext[i]=tolower(tmpext[i]);
|
|
dprintf_exec(stddeb, "FindExecutable: %s file\n", tmpext);
|
|
|
|
/* Three places to check: */
|
|
/* 1. win.ini, [windows], programs (NB no leading '.') */
|
|
/* 2. Registry, HKEY_CLASS_ROOT\<filetype>\shell\open\command */
|
|
/* 3. win.ini, [extensions], extension (NB no leading '.' */
|
|
/* All I know of the order is that registry is checked before */
|
|
/* extensions; however, it'd make sense to check the programs */
|
|
/* section first, so that's what happens here. */
|
|
|
|
/* See if it's a program */
|
|
GetProfileString("windows", "programs", "exe pif bat com",
|
|
buffer, sizeof(buffer)); /* FIXME check return code! */
|
|
|
|
for (i=0;i<strlen(buffer); i++) buffer[i]=tolower(buffer[i]);
|
|
|
|
tok = strtok(buffer, " \t"); /* ? */
|
|
while( tok!= NULL)
|
|
{
|
|
if (strcmp(tok, &tmpext[1])==0) /* have to skip the leading "." */
|
|
{
|
|
strcpy(lpResult, lpFile); /* Need to perhaps check that */
|
|
/* the file has a path attached */
|
|
dprintf_exec(stddeb, "FindExecutable: found %s\n", lpResult);
|
|
return 33; /* Greater than 32 to indicate success FIXME */
|
|
/* what are the correct values here? */
|
|
}
|
|
tok=strtok(NULL, " \t");
|
|
}
|
|
|
|
/* Check registry */
|
|
if (RegQueryValue16( (HKEY)HKEY_CLASSES_ROOT, tmpext, filetype,
|
|
&filetypelen ) == SHELL_ERROR_SUCCESS )
|
|
{
|
|
filetype[filetypelen]='\0';
|
|
dprintf_exec(stddeb, "File type: %s\n", filetype);
|
|
|
|
/* Looking for ...buffer\shell\open\command */
|
|
strcat( filetype, "\\shell\\open\\command" );
|
|
|
|
if (RegQueryValue16( (HKEY)HKEY_CLASSES_ROOT, filetype, command,
|
|
&commandlen ) == SHELL_ERROR_SUCCESS )
|
|
{
|
|
/* Is there a replace() function anywhere? */
|
|
command[commandlen]='\0';
|
|
strcpy( lpResult, command );
|
|
tok=strstr( lpResult, "%1" );
|
|
if (tok != NULL)
|
|
{
|
|
tok[0]='\0'; /* truncate string at the percent */
|
|
strcat( lpResult, lpFile ); /* what if no dir in lpFile? */
|
|
tok=strstr( command, "%1" );
|
|
if ((tok!=NULL) && (strlen(tok)>2))
|
|
{
|
|
strcat( lpResult, &tok[2] );
|
|
}
|
|
}
|
|
retval=33;
|
|
}
|
|
}
|
|
else /* Check win.ini */
|
|
{
|
|
/* Toss the leading dot */
|
|
extension++;
|
|
GetProfileString( "extensions", extension, "", command,
|
|
sizeof(command));
|
|
if (strlen(command)!=0)
|
|
{
|
|
strcpy( lpResult, command );
|
|
tok=strstr( lpResult, "^" ); /* should be ^.extension? */
|
|
if (tok != NULL)
|
|
{
|
|
tok[0]='\0';
|
|
strcat( lpResult, lpFile ); /* what if no dir in lpFile? */
|
|
tok=strstr( command, "^" ); /* see above */
|
|
if ((tok != NULL) && (strlen(tok)>5))
|
|
{
|
|
strcat( lpResult, &tok[5]);
|
|
}
|
|
}
|
|
retval=33;
|
|
}
|
|
}
|
|
|
|
dprintf_exec(stddeb, "FindExecutable: returning %s\n", lpResult);
|
|
return retval;
|
|
}
|
|
|
|
static char AppName[128], AppMisc[1536];
|
|
|
|
/*************************************************************************
|
|
* AboutDlgProc [SHELL.33]
|
|
*/
|
|
LRESULT AboutDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
|
{
|
|
char Template[512], AppTitle[512];
|
|
|
|
switch(msg) {
|
|
case WM_INITDIALOG:
|
|
#ifdef WINELIB32
|
|
SendDlgItemMessage32A(hWnd,stc1,STM_SETICON,lParam,0);
|
|
#else
|
|
SendDlgItemMessage16(hWnd,stc1,STM_SETICON,LOWORD(lParam),0);
|
|
#endif
|
|
GetWindowText32A(hWnd, Template, sizeof(Template));
|
|
sprintf(AppTitle, Template, AppName);
|
|
SetWindowText32A(hWnd, AppTitle);
|
|
SetWindowText32A(GetDlgItem(hWnd,100), AppMisc);
|
|
return 1;
|
|
|
|
case WM_COMMAND:
|
|
switch (wParam) {
|
|
case IDOK:
|
|
EndDialog(hWnd, TRUE);
|
|
return TRUE;
|
|
}
|
|
break;
|
|
}
|
|
return FALSE;
|
|
}
|
|
|
|
/*************************************************************************
|
|
* ShellAbout [SHELL.22]
|
|
*/
|
|
INT ShellAbout(HWND hWnd, LPCSTR szApp, LPCSTR szOtherStuff, HICON hIcon)
|
|
{
|
|
HANDLE handle;
|
|
BOOL bRet;
|
|
|
|
if (szApp) strncpy(AppName, szApp, sizeof(AppName));
|
|
else *AppName = 0;
|
|
AppName[sizeof(AppName)-1]=0;
|
|
|
|
if (szOtherStuff) strncpy(AppMisc, szOtherStuff, sizeof(AppMisc));
|
|
else *AppMisc = 0;
|
|
AppMisc[sizeof(AppMisc)-1]=0;
|
|
|
|
if (!hIcon) hIcon = LoadIcon(0,MAKEINTRESOURCE(OIC_WINEICON));
|
|
handle = SYSRES_LoadResource( SYSRES_DIALOG_SHELL_ABOUT_MSGBOX );
|
|
if (!handle) return FALSE;
|
|
bRet = DialogBoxIndirectParam( WIN_GetWindowInstance( hWnd ),
|
|
handle, hWnd,
|
|
MODULE_GetWndProcEntry16("AboutDlgProc"),
|
|
(LONG)hIcon );
|
|
SYSRES_FreeResource( handle );
|
|
return bRet;
|
|
}
|
|
|
|
/*************************************************************************
|
|
* SHELL_GetResourceTable
|
|
*
|
|
* FIXME: Implement GetPEResourceTable in w32sys.c and call it here.
|
|
*/
|
|
BYTE* SHELL_GetResourceTable(HFILE hFile)
|
|
{
|
|
struct mz_header_s mz_header;
|
|
struct ne_header_s ne_header;
|
|
int size;
|
|
|
|
_llseek( hFile, 0, SEEK_SET );
|
|
if ((FILE_Read(hFile,&mz_header,sizeof(mz_header)) != sizeof(mz_header)) ||
|
|
(mz_header.mz_magic != MZ_SIGNATURE)) return (BYTE*)-1;
|
|
|
|
_llseek( hFile, mz_header.ne_offset, SEEK_SET );
|
|
if (FILE_Read( hFile, &ne_header, sizeof(ne_header) ) != sizeof(ne_header))
|
|
return NULL;
|
|
|
|
if (ne_header.ne_magic == PE_SIGNATURE)
|
|
{ fprintf(stdnimp,"Win32 FIXME: file %s line %i\n", __FILE__, __LINE__ );
|
|
return NULL; }
|
|
|
|
if (ne_header.ne_magic != NE_SIGNATURE) return NULL;
|
|
|
|
size = ne_header.rname_tab_offset - ne_header.resource_tab_offset;
|
|
|
|
if( size > sizeof(NE_TYPEINFO) )
|
|
{
|
|
BYTE* pTypeInfo = (BYTE*)xmalloc(size);
|
|
|
|
if( !pTypeInfo ) return NULL;
|
|
|
|
_llseek(hFile, mz_header.ne_offset+ne_header.resource_tab_offset, SEEK_SET);
|
|
if( FILE_Read( hFile, (char*)pTypeInfo, size) != size )
|
|
{ free(pTypeInfo); return NULL; }
|
|
return pTypeInfo;
|
|
}
|
|
/* no resources */
|
|
|
|
return NULL;
|
|
}
|
|
|
|
/*************************************************************************
|
|
* SHELL_LoadResource
|
|
*/
|
|
HANDLE SHELL_LoadResource(HINSTANCE hInst, HFILE hFile, NE_NAMEINFO* pNInfo, WORD sizeShift)
|
|
{
|
|
BYTE* ptr;
|
|
HANDLE handle = DirectResAlloc( hInst, 0x10, (DWORD)pNInfo->length << sizeShift);
|
|
|
|
if( (ptr = (BYTE*)GlobalLock16( handle )) )
|
|
{
|
|
_llseek( hFile, (DWORD)pNInfo->offset << sizeShift, SEEK_SET);
|
|
FILE_Read( hFile, (char*)ptr, pNInfo->length << sizeShift);
|
|
return handle;
|
|
}
|
|
return (HANDLE)0;
|
|
}
|
|
|
|
/*************************************************************************
|
|
* InternalExtractIcon [SHELL.39]
|
|
*
|
|
* This abortion is called directly by Progman
|
|
*/
|
|
HICON InternalExtractIcon(HINSTANCE hInstance, LPCSTR lpszExeFileName, UINT nIconIndex, WORD n )
|
|
{
|
|
HANDLE hRet = 0;
|
|
HICON* RetPtr = NULL;
|
|
BYTE* pData;
|
|
OFSTRUCT ofs;
|
|
HFILE hFile = OpenFile( lpszExeFileName, &ofs, OF_READ );
|
|
|
|
dprintf_reg(stddeb, "InternalExtractIcon(%04x, file '%s', start from %d, extract %d\n",
|
|
hInstance, lpszExeFileName, nIconIndex, n);
|
|
|
|
if( hFile == HFILE_ERROR || !n ) return 0;
|
|
|
|
hRet = GlobalAlloc16( GMEM_FIXED, sizeof(HICON)*n);
|
|
RetPtr = (HICON*)GlobalLock16(hRet);
|
|
|
|
*RetPtr = (n == 0xFFFF)? 0: 1; /* error return values */
|
|
|
|
pData = SHELL_GetResourceTable(hFile);
|
|
if( pData )
|
|
if( pData == (BYTE*)-1 )
|
|
{
|
|
/* FIXME: possible .ICO file */
|
|
|
|
fprintf(stddeb,"InternalExtractIcon: cannot handle file %s\n", lpszExeFileName);
|
|
}
|
|
else /* got resource table */
|
|
{
|
|
UINT iconDirCount = 0;
|
|
UINT iconCount = 0;
|
|
NE_TYPEINFO* pTInfo = (NE_TYPEINFO*)(pData + 2);
|
|
NE_NAMEINFO* pIconStorage = NULL;
|
|
NE_NAMEINFO* pIconDir = NULL;
|
|
|
|
/* find icon directory and icon repository */
|
|
|
|
while( pTInfo->type_id && !(pIconStorage && pIconDir) )
|
|
{
|
|
if( pTInfo->type_id == NE_RSCTYPE_GROUP_ICON )
|
|
{
|
|
iconDirCount = pTInfo->count;
|
|
pIconDir = ((NE_NAMEINFO*)(pTInfo + 1));
|
|
dprintf_reg(stddeb,"\tfound directory - %i icon families\n", iconDirCount);
|
|
}
|
|
if( pTInfo->type_id == NE_RSCTYPE_ICON )
|
|
{
|
|
iconCount = pTInfo->count;
|
|
pIconStorage = ((NE_NAMEINFO*)(pTInfo + 1));
|
|
dprintf_reg(stddeb,"\ttotal icons - %i\n", iconCount);
|
|
}
|
|
pTInfo = (NE_TYPEINFO *)((char*)(pTInfo+1)+pTInfo->count*sizeof(NE_NAMEINFO));
|
|
}
|
|
|
|
/* load resources and create icons */
|
|
|
|
if( pIconStorage && pIconDir )
|
|
|
|
if( nIconIndex == (UINT)-1 ) RetPtr[0] = iconDirCount;
|
|
else if( nIconIndex < iconDirCount )
|
|
{
|
|
HANDLE hIcon;
|
|
UINT i, icon;
|
|
|
|
if( n > iconDirCount - nIconIndex ) n = iconDirCount - nIconIndex;
|
|
|
|
for( i = nIconIndex; i < nIconIndex + n; i++ )
|
|
{
|
|
hIcon = SHELL_LoadResource( hInstance, hFile, pIconDir + (i - nIconIndex),
|
|
*(WORD*)pData );
|
|
RetPtr[i-nIconIndex] = GetIconID( hIcon, 3 );
|
|
GlobalFree16(hIcon);
|
|
}
|
|
|
|
for( icon = nIconIndex; icon < nIconIndex + n; icon++ )
|
|
{
|
|
hIcon = 0;
|
|
for( i = 0; i < iconCount; i++ )
|
|
if( pIconStorage[i].id == (RetPtr[icon-nIconIndex] | 0x8000) )
|
|
hIcon = SHELL_LoadResource( hInstance, hFile, pIconStorage + i,
|
|
*(WORD*)pData );
|
|
RetPtr[icon-nIconIndex] = (hIcon)?CURSORICON_LoadHandler( hIcon, hInstance, FALSE ):0;
|
|
}
|
|
}
|
|
free(pData);
|
|
}
|
|
|
|
_lclose( hFile );
|
|
|
|
/* return array with icon handles */
|
|
|
|
return hRet;
|
|
}
|
|
|
|
/*************************************************************************
|
|
* ExtractIcon [SHELL.34]
|
|
*/
|
|
HICON ExtractIcon(HINSTANCE hInstance, LPCSTR lpszExeFileName, WORD nIconIndex)
|
|
{
|
|
HANDLE handle = InternalExtractIcon(hInstance,lpszExeFileName,nIconIndex, 1);
|
|
|
|
if( handle )
|
|
{
|
|
HICON* ptr = (HICON*)GlobalLock16(handle);
|
|
HICON hIcon = *ptr;
|
|
|
|
GlobalFree16(handle);
|
|
return hIcon;
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
/*************************************************************************
|
|
* ExtractAssociatedIcon [SHELL.36]
|
|
*/
|
|
HICON ExtractAssociatedIcon(HINSTANCE hInst,LPSTR lpIconPath, LPWORD lpiIcon)
|
|
{
|
|
HICON hIcon = ExtractIcon(hInst, lpIconPath, *lpiIcon);
|
|
|
|
/* MAKEINTRESOURCE(2) seems to be "default" icon according to Progman
|
|
*
|
|
* For data files it probably should call FindExecutable and load
|
|
* icon from there. As of now FindExecutable is empty stub.
|
|
*/
|
|
|
|
if( hIcon < 2 ) hIcon = LoadIcon( hInst, MAKEINTRESOURCE(2));
|
|
|
|
return hIcon;
|
|
}
|
|
|
|
/*************************************************************************
|
|
* FindEnvironmentString [SHELL.38]
|
|
*
|
|
* Returns a pointer into the DOS environment... Ugh.
|
|
*/
|
|
LPSTR SHELL_FindString(LPSTR lpEnv, LPCSTR entry)
|
|
{
|
|
UINT l = strlen(entry);
|
|
for( ; *lpEnv ; lpEnv+=strlen(lpEnv)+1 )
|
|
{
|
|
if( lstrncmpi(lpEnv, entry, l) ) continue;
|
|
|
|
if( !*(lpEnv+l) )
|
|
return (lpEnv + l); /* empty entry */
|
|
else if ( *(lpEnv+l)== '=' )
|
|
return (lpEnv + l + 1);
|
|
}
|
|
return NULL;
|
|
}
|
|
|
|
SEGPTR FindEnvironmentString(LPSTR str)
|
|
{
|
|
SEGPTR spEnv = GetDOSEnvironment();
|
|
LPSTR lpEnv = (LPSTR)PTR_SEG_TO_LIN(spEnv);
|
|
|
|
LPSTR lpString = (spEnv)?SHELL_FindString(lpEnv, str):NULL;
|
|
|
|
if( lpString ) /* offset should be small enough */
|
|
return spEnv + (lpString - lpEnv);
|
|
|
|
return (SEGPTR)NULL;
|
|
}
|
|
|
|
/*************************************************************************
|
|
* DoEnvironmentSubst [SHELL.37]
|
|
*
|
|
* Replace %KEYWORD% in the str with the value of variable KEYWORD
|
|
* from "DOS" environment.
|
|
*/
|
|
DWORD DoEnvironmentSubst(LPSTR str,WORD length)
|
|
{
|
|
LPSTR lpEnv = (LPSTR)PTR_SEG_TO_LIN(GetDOSEnvironment());
|
|
LPSTR lpBuffer = (LPSTR)xmalloc(length);
|
|
LPSTR lpstr = str;
|
|
LPSTR lpbstr = lpBuffer;
|
|
|
|
AnsiToOem(str,str);
|
|
|
|
dprintf_reg(stddeb,"DoEnvSubst: accept %s", str);
|
|
|
|
while( *lpstr && lpbstr - lpBuffer < length )
|
|
{
|
|
LPSTR lpend = lpstr;
|
|
|
|
if( *lpstr == '%' )
|
|
{
|
|
do { lpend++; } while( *lpend && *lpend != '%' );
|
|
if( *lpend == '%' && lpend - lpstr > 1 ) /* found key */
|
|
{
|
|
LPSTR lpKey;
|
|
*lpend = '\0';
|
|
lpKey = SHELL_FindString(lpEnv, lpstr+1);
|
|
if( lpKey ) /* found key value */
|
|
{
|
|
int l = strlen(lpKey);
|
|
|
|
if( l > length - (lpbstr - lpBuffer) - 1 )
|
|
{
|
|
fprintf(stdnimp,"File %s, line %i: Env subst aborted - string too short\n",
|
|
__FILE__, __LINE__);
|
|
*lpend = '%';
|
|
break;
|
|
}
|
|
strcpy(lpbstr, lpKey);
|
|
lpbstr += l;
|
|
}
|
|
else break;
|
|
*lpend = '%';
|
|
lpstr = lpend + 1;
|
|
}
|
|
else break; /* back off and whine */
|
|
|
|
continue;
|
|
}
|
|
|
|
*lpbstr++ = *lpstr++;
|
|
}
|
|
|
|
*lpbstr = '\0';
|
|
if( lpstr - str == strlen(str) )
|
|
{
|
|
strncpy(str, lpBuffer, length);
|
|
length = 1;
|
|
}
|
|
else
|
|
length = 0;
|
|
|
|
dprintf_reg(stddeb," return %s\n", str);
|
|
|
|
OemToAnsi(str,str);
|
|
free(lpBuffer);
|
|
|
|
/* Return str length in the LOWORD
|
|
* and 1 in HIWORD if subst was successful.
|
|
*/
|
|
return (DWORD)MAKELONG(strlen(str), length);
|
|
}
|
|
|
|
/*************************************************************************
|
|
* RegisterShellHook [SHELL.102]
|
|
*/
|
|
int RegisterShellHook(void *ptr)
|
|
{
|
|
dprintf_reg(stdnimp, "RegisterShellHook : Empty Stub !!!\n");
|
|
return 0;
|
|
}
|
|
|
|
|
|
/*************************************************************************
|
|
* ShellHookProc [SHELL.103]
|
|
*/
|
|
int ShellHookProc(void)
|
|
{
|
|
dprintf_reg(stdnimp, "ShellHookProc : Empty Stub !!!\n");
|
|
return 0;
|
|
}
|