2 * Shell Library Functions
20 /*************************************************************************
21 * DragAcceptFiles [SHELL.9]
23 void DragAcceptFiles(HWND hWnd, BOOL b)
25 /* flips WS_EX_ACCEPTFILES bit according to the value of b */
26 dprintf_reg(stddeb,"DragAcceptFiles(%04x, %u) old exStyle %08lx\n",
27 hWnd,b,GetWindowLong(hWnd,GWL_EXSTYLE));
29 SetWindowLong(hWnd,GWL_EXSTYLE,
30 GetWindowLong(hWnd,GWL_EXSTYLE) | b*(LONG)WS_EX_ACCEPTFILES);
34 /*************************************************************************
35 * DragQueryFile [SHELL.11]
37 UINT DragQueryFile(HDROP hDrop, WORD wFile, LPSTR lpszFile, WORD wLength)
39 /* hDrop is a global memory block allocated with GMEM_SHARE
40 * with DROPFILESTRUCT as a header and filenames following
41 * it, zero length filename is in the end */
43 LPDROPFILESTRUCT lpDropFileStruct;
47 dprintf_reg(stddeb,"DragQueryFile(%04x, %i, %p, %u)\n",
48 hDrop,wFile,lpszFile,wLength);
50 lpDropFileStruct = (LPDROPFILESTRUCT) GlobalLock(hDrop);
53 dprintf_reg(stddeb,"DragQueryFile: unable to lock handle!\n");
56 lpCurrent = (LPSTR) lpDropFileStruct + lpDropFileStruct->wSize;
61 while (*lpCurrent++); /* skip filename */
63 return (wFile == 0xFFFF) ? i : 0;
66 i = strlen(lpCurrent);
67 if (!lpszFile) return i+1; /* needed buffer size */
69 i = (wLength > i) ? i : wLength-1;
70 strncpy(lpszFile, lpCurrent, i);
78 /*************************************************************************
79 * DragFinish [SHELL.12]
81 void DragFinish(HDROP h)
83 GlobalFree((HGLOBAL)h);
87 /*************************************************************************
88 * DragQueryPoint [SHELL.13]
90 BOOL DragQueryPoint(HDROP hDrop, POINT FAR *p)
92 LPDROPFILESTRUCT lpDropFileStruct;
95 lpDropFileStruct = (LPDROPFILESTRUCT) GlobalLock(hDrop);
97 memcpy(p,&lpDropFileStruct->ptMousePos,sizeof(POINT));
98 bRet = lpDropFileStruct->fInNonClientArea;
105 /*************************************************************************
106 * ShellExecute [SHELL.20]
108 HINSTANCE ShellExecute(HWND hWnd, LPCSTR lpOperation, LPCSTR lpFile, LPSTR lpParameters, LPCSTR lpDirectory, INT iShowCmd)
114 /* OK. We are supposed to lookup the program associated with lpFile,
115 * then to execute it using that program. If lpFile is a program,
116 * we have to pass the parameters. If an instance is already running,
117 * we might have to send DDE commands.
119 dprintf_exec(stddeb, "ShellExecute(%04x,'%s','%s','%s','%s',%x)\n",
120 hWnd, lpOperation ? lpOperation:"<null>", lpFile ? lpFile:"<null>",
121 lpParameters ? lpParameters : "<null>",
122 lpDirectory ? lpDirectory : "<null>", iShowCmd);
123 if (lpFile==NULL) return 0; /* should not happen */
124 if (lpOperation==NULL) /* default is open */
126 p=strrchr(lpFile,'.');
128 x=p; /* the suffixes in the register database are lowercased */
129 while (*x) {*x=tolower(*x);x++;}
131 if (p==NULL || !strcmp(p,".exe")) {
134 sprintf(cmd,"%s %s",lpFile,lpParameters);
140 if (RegQueryValue((HKEY)HKEY_CLASSES_ROOT,p,subclass,&len)==SHELL_ERROR_SUCCESS) {
142 fprintf(stddeb,"ShellExecute:subclass with len %ld? (%s), please report.\n",len,subclass);
144 strcat(subclass,"\\shell\\");
145 strcat(subclass,lpOperation);
146 strcat(subclass,"\\command");
147 dprintf_exec(stddeb,"ShellExecute:looking for %s.\n",subclass);
149 if (RegQueryValue((HKEY)HKEY_CLASSES_ROOT,subclass,cmd,&len)==SHELL_ERROR_SUCCESS) {
151 dprintf_exec(stddeb,"ShellExecute:...got %s\n",cmd);
159 s=xmalloc(len+strlen(lpFile)+10);
160 strncpy(s,cmd,t-cmd);
167 /* does this use %x magic too? */
170 strcat(cmd,lpParameters);
173 fprintf(stddeb,"ShellExecute: No %s\\shell\\%s\\command found for \"%s\" suffix.\n",subclass,lpOperation,p);
174 return (HINSTANCE)14; /* unknown type */
177 fprintf(stddeb,"ShellExecute: No operation found for \"%s\" suffix.\n",p);
178 return (HINSTANCE)14; /* file not found */
181 dprintf_exec(stddeb,"ShellExecute:starting %s\n",cmd);
182 return WinExec(cmd,iShowCmd);
186 /*************************************************************************
187 * FindExecutable [SHELL.21]
189 HINSTANCE FindExecutable(LPCSTR lpFile, LPCSTR lpDirectory, LPSTR lpResult)
191 fprintf(stdnimp, "FindExecutable : Empty Stub !!!\n");
195 static char AppName[128], AppMisc[906];
197 /*************************************************************************
198 * AboutDlgProc [SHELL.33]
200 LRESULT AboutDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
202 char Template[512], AppTitle[512];
207 SendDlgItemMessage(hWnd,stc1,STM_SETICON,lParam,0);
209 SendDlgItemMessage(hWnd,stc1,STM_SETICON,LOWORD(lParam),0);
211 GetWindowText(hWnd, Template, 511);
212 sprintf(AppTitle, Template, AppName);
213 SetWindowText(hWnd, AppTitle);
214 SetWindowText(GetDlgItem(hWnd,100), AppMisc);
220 EndDialog(hWnd, TRUE);
228 /*************************************************************************
229 * ShellAbout [SHELL.22]
231 INT ShellAbout(HWND hWnd, LPCSTR szApp, LPCSTR szOtherStuff, HICON hIcon)
236 if (szApp) strncpy(AppName, szApp, sizeof(AppName));
238 AppName[sizeof(AppName)-1]=0;
240 if (szOtherStuff) strncpy(AppMisc, szOtherStuff, sizeof(AppMisc));
242 AppMisc[sizeof(AppMisc)-1]=0;
244 if (!hIcon) hIcon = LoadIcon(0,MAKEINTRESOURCE(OIC_WINEICON));
245 handle = SYSRES_LoadResource( SYSRES_DIALOG_SHELL_ABOUT_MSGBOX );
246 if (!handle) return FALSE;
247 bRet = DialogBoxIndirectParam( WIN_GetWindowInstance( hWnd ),
249 MODULE_GetWndProcEntry16("AboutDlgProc"),
251 SYSRES_FreeResource( handle );
255 /*************************************************************************
256 * ExtractIcon [SHELL.34]
258 HICON ExtractIcon(HINSTANCE hInst, LPCSTR lpszExeFileName, UINT nIconIndex)
261 HINSTANCE hInst2 = hInst;
262 dprintf_reg(stddeb, "ExtractIcon(%04x, '%s', %d\n",
263 hInst, lpszExeFileName, nIconIndex);
265 if (lpszExeFileName != NULL) {
266 hInst2 = LoadModule(lpszExeFileName,(LPVOID)-1);
268 if (hInst2 != 0 && nIconIndex == (UINT)-1) {
270 count = GetRsrcCount(hInst2, NE_RSCTYPE_GROUP_ICON);
271 dprintf_reg(stddeb, "ExtractIcon // '%s' has %d icons !\n", lpszExeFileName, count);
275 if (hInst2 != hInst && hInst2 != 0) {
282 /*************************************************************************
283 * ExtractAssociatedIcon [SHELL.36]
285 HICON ExtractAssociatedIcon(HINSTANCE hInst,LPSTR lpIconPath, LPWORD lpiIcon)
287 dprintf_reg(stdnimp, "ExtractAssociatedIcon : Empty Stub !!!\n");
291 /*************************************************************************
292 * DoEnvironmentSubst [SHELL.37]
294 DWORD DoEnvironmentSubst(LPSTR str,WORD len)
296 dprintf_reg(stdnimp, "DoEnvironmentSubst(%s,%x): Empty Stub !!!\n",str,len);
300 /*************************************************************************
301 * RegisterShellHook [SHELL.102]
303 int RegisterShellHook(void *ptr)
305 dprintf_reg(stdnimp, "RegisterShellHook : Empty Stub !!!\n");
310 /*************************************************************************
311 * ShellHookProc [SHELL.103]
313 int ShellHookProc(void)
315 dprintf_reg(stdnimp, "ShellHookProc : Empty Stub !!!\n");