2 * Shell Library Functions
8 #include "prototypes.h"
16 LPKEYSTRUCT lphRootKey = NULL;
18 DECLARE_HANDLE(HDROP);
20 extern HINSTANCE hSysRes;
22 /*************************************************************************
23 * RegOpenKey [SHELL.1]
25 LONG RegOpenKey(HKEY hKey, LPCSTR lpSubKey, HKEY FAR *lphKey)
27 LPKEYSTRUCT lpKey = lphRootKey;
32 fprintf(stderr, "RegOpenKey(%04X, %08X='%s', %08X)\n",
33 hKey, lpSubKey, lpSubKey, lphKey);
35 if (lpKey == NULL) return ERROR_BADKEY;
36 if (lpSubKey == NULL) return ERROR_INVALID_PARAMETER;
37 if (lphKey == NULL) return ERROR_INVALID_PARAMETER;
38 if (hKey != HKEY_CLASSES_ROOT) {
40 printf("RegOpenKey // specific key = %04X !\n", hKey);
42 lpKey = (LPKEYSTRUCT)GlobalLock(hKey);
44 while ( (ptr = strchr(lpSubKey, '\\')) != NULL ) {
45 strncpy(str, lpSubKey, (LONG)ptr - (LONG)lpSubKey);
46 str[(LONG)ptr - (LONG)lpSubKey] = '\0';
49 printf("RegOpenKey // next level '%s' !\n", str);
53 printf("RegOpenKey // '%s' <-> '%s' !\n", str, lpKey->lpSubKey);
55 if (lpKey->lpSubKey != NULL && lpKey->lpSubKey[0] != '\0' &&
56 strcmp(lpKey->lpSubKey, str) == 0) {
57 lpKey = lpKey->lpSubLvl;
59 printf("RegOpenKey // can't find subkey '%s' !\n", str);
64 if (lpKey->lpNextKey == NULL) {
65 printf("RegOpenKey // can't find subkey '%s' !\n", str);
68 lpKey = lpKey->lpNextKey;
72 if (lpKey->lpSubKey != NULL &&
73 strcmp(lpKey->lpSubKey, lpSubKey) == 0) break;
74 if (lpKey->lpNextKey == NULL) {
75 printf("RegOpenKey // can't find subkey '%s' !\n", str);
78 lpKey = lpKey->lpNextKey;
80 *lphKey = lpKey->hKey;
82 printf("RegOpenKey // return hKey=%04X !\n", lpKey->hKey);
88 /*************************************************************************
89 * RegCreateKey [SHELL.2]
91 LONG RegCreateKey(HKEY hKey, LPCSTR lpSubKey, HKEY FAR *lphKey)
95 LPKEYSTRUCT lpKey = lphRootKey;
96 LPKEYSTRUCT lpPrevKey;
101 fprintf(stderr, "RegCreateKey(%04X, '%s', %08X)\n", hKey, lpSubKey, lphKey);
103 if (lpSubKey == NULL) return ERROR_INVALID_PARAMETER;
104 if (lphKey == NULL) return ERROR_INVALID_PARAMETER;
105 if (hKey != HKEY_CLASSES_ROOT) {
107 printf("RegCreateKey // specific key = %04X !\n", hKey);
109 lpKey = (LPKEYSTRUCT)GlobalLock(hKey);
111 while ( (ptr = strchr(lpSubKey, '\\')) != NULL ) {
112 strncpy(str, lpSubKey, (LONG)ptr - (LONG)lpSubKey);
113 str[(LONG)ptr - (LONG)lpSubKey] = '\0';
116 printf("RegCreateKey // next level '%s' !\n", str);
121 printf("RegCreateKey // '%s' <-> '%s' !\n", str, lpKey->lpSubKey);
123 if (lpKey->lpSubKey != NULL &&
124 strcmp(lpKey->lpSubKey, str) == 0) {
125 if (lpKey->lpSubLvl == NULL) {
127 printf("RegCreateKey // '%s' found !\n", str);
129 if ( (ptr = strchr(lpSubKey, '\\')) != NULL ) {
130 strncpy(str, lpSubKey, (LONG)ptr - (LONG)lpSubKey);
131 str[(LONG)ptr - (LONG)lpSubKey] = '\0';
135 strcpy(str, lpSubKey);
136 dwRet = RegCreateKey(lpKey->hKey, str, &hNewKey);
137 if (dwRet != ERROR_SUCCESS) {
138 printf("RegCreateKey // can't create subkey '%s' !\n", str);
141 lpKey->lpSubLvl = (LPKEYSTRUCT)GlobalLock(hNewKey);
143 lpKey = lpKey->lpSubLvl;
146 if (lpKey->lpNextKey == NULL) {
147 dwRet = RegCreateKey(lpPrevKey->hKey, str, &hNewKey);
148 if (dwRet != ERROR_SUCCESS) {
149 printf("RegCreateKey // can't create subkey '%s' !\n", str);
152 lpKey = (LPKEYSTRUCT)GlobalLock(hNewKey);
155 lpKey = lpKey->lpNextKey;
158 hNewKey = GlobalAlloc(GMEM_MOVEABLE, sizeof(KEYSTRUCT));
159 lpNewKey = (LPKEYSTRUCT) GlobalLock(hNewKey);
160 if (lpNewKey == NULL) {
161 printf("RegCreateKey // Can't alloc new key !\n");
162 return ERROR_OUTOFMEMORY;
164 if (lphRootKey == NULL) {
165 lphRootKey = lpNewKey;
166 lpNewKey->lpPrevKey = NULL;
169 lpKey->lpNextKey = lpNewKey;
170 lpNewKey->lpPrevKey = lpKey;
172 lpNewKey->hKey = hNewKey;
173 lpNewKey->lpSubKey = malloc(strlen(lpSubKey) + 1);
174 if (lpNewKey->lpSubKey == NULL) {
175 printf("RegCreateKey // Can't alloc key string !\n");
176 return ERROR_OUTOFMEMORY;
178 strcpy(lpNewKey->lpSubKey, lpSubKey);
179 lpNewKey->dwType = 0;
180 lpNewKey->lpValue = NULL;
181 lpNewKey->lpNextKey = NULL;
182 lpNewKey->lpSubLvl = NULL;
185 printf("RegCreateKey // successful '%s' key=%04X !\n", lpSubKey, hNewKey);
187 return ERROR_SUCCESS;
191 /*************************************************************************
192 * RegCloseKey [SHELL.3]
194 LONG RegCloseKey(HKEY hKey)
196 fprintf(stderr, "EMPTY STUB !!! RegCloseKey(%04X);\n", hKey);
197 return ERROR_INVALID_PARAMETER;
201 /*************************************************************************
202 * RegDeleteKey [SHELL.4]
204 LONG RegDeleteKey(HKEY hKey, LPCSTR lpSubKey)
206 fprintf(stderr, "EMPTY STUB !!! RegDeleteKey(%04X, '%s');\n",
208 return ERROR_INVALID_PARAMETER;
212 /*************************************************************************
213 * RegSetValue [SHELL.5]
215 LONG RegSetValue(HKEY hKey, LPCSTR lpSubKey, DWORD dwType,
216 LPCSTR lpVal, DWORD dwIgnored)
222 fprintf(stderr, "RegSetValue(%04X, '%s', %08X, '%s', %08X);\n",
223 hKey, lpSubKey, dwType, lpVal, dwIgnored);
225 if (lpSubKey == NULL) return ERROR_INVALID_PARAMETER;
226 if (lpVal == NULL) return ERROR_INVALID_PARAMETER;
227 if ((dwRet = RegOpenKey(hKey, lpSubKey, &hRetKey)) != ERROR_SUCCESS) {
229 fprintf(stderr, "RegSetValue // key not found ... so create it !\n");
231 if ((dwRet = RegCreateKey(hKey, lpSubKey, &hRetKey)) != ERROR_SUCCESS) {
232 fprintf(stderr, "RegSetValue // key creation error %04X !\n", dwRet);
236 lpKey = (LPKEYSTRUCT)GlobalLock(hRetKey);
237 if (lpKey == NULL) return ERROR_BADKEY;
238 if (lpKey->lpValue != NULL) free(lpKey->lpValue);
239 lpKey->lpValue = malloc(strlen(lpVal) + 1);
240 strcpy(lpKey->lpValue, lpVal);
242 printf("RegSetValue // successful key='%s' val='%s' !\n", lpSubKey, lpVal);
244 return ERROR_SUCCESS;
248 /*************************************************************************
249 * RegQueryValue [SHELL.6]
251 LONG RegQueryValue(HKEY hKey, LPCSTR lpSubKey, LPSTR lpVal, LONG FAR *lpcb)
257 fprintf(stderr, "RegQueryValue(%04X, '%s', %08X, %08X);\n",
258 hKey, lpSubKey, lpVal, lpcb);
259 if (lpSubKey == NULL) return ERROR_INVALID_PARAMETER;
260 if (lpVal == NULL) return ERROR_INVALID_PARAMETER;
261 if (lpcb == NULL) return ERROR_INVALID_PARAMETER;
262 if ((dwRet = RegOpenKey(hKey, lpSubKey, &hRetKey)) != ERROR_SUCCESS) {
263 fprintf(stderr, "RegQueryValue // key not found !\n");
266 lpKey = (LPKEYSTRUCT)GlobalLock(hRetKey);
267 if (lpKey == NULL) return ERROR_BADKEY;
268 if (lpKey->lpValue != NULL) {
269 size = min(strlen(lpKey->lpValue), *lpcb);
270 strncpy(lpVal, lpKey->lpValue, size);
277 printf("RegQueryValue // return '%s' !\n", lpVal);
278 return ERROR_SUCCESS;
282 /*************************************************************************
283 * RegEnumKey [SHELL.7]
285 LONG RegEnumKey(HKEY hKey, DWORD dwSubKey, LPSTR lpBuf, DWORD dwSize)
287 fprintf(stderr, "RegEnumKey : Empty Stub !!!\n");
288 return ERROR_INVALID_PARAMETER;
291 /*************************************************************************
292 * DragAcceptFiles [SHELL.9]
294 void DragAcceptFiles(HWND hWnd, BOOL b)
296 fprintf(stderr, "DragAcceptFiles : Empty Stub !!!\n");
300 /*************************************************************************
301 * DragQueryFile [SHELL.11]
303 void DragQueryFile(HDROP h, UINT u, LPSTR u2, UINT u3)
305 fprintf(stderr, "DragQueryFile : Empty Stub !!!\n");
310 /*************************************************************************
311 * DragFinish [SHELL.12]
313 void DragFinish(HDROP h)
315 fprintf(stderr, "DragFinish : Empty Stub !!!\n");
320 /*************************************************************************
321 * DragQueryPoint [SHELL.13]
323 BOOL DragQueryPoint(HDROP h, POINT FAR *p)
325 fprintf(stderr, "DragQueryPoinyt : Empty Stub !!!\n");
330 /*************************************************************************
331 * ShellExecute [SHELL.20]
333 HINSTANCE ShellExecute(HWND hWnd, LPCSTR lpOperation, LPCSTR lpFile, LPCSTR lpParameters, LPCSTR lpDirectory, int iShowCmd)
335 fprintf(stderr, "ShellExecute // hWnd=%04X\n", hWnd);
336 fprintf(stderr, "ShellExecute // lpOperation='%s'\n", lpOperation);
337 fprintf(stderr, "ShellExecute // lpFile='%s'\n", lpFile);
338 fprintf(stderr, "ShellExecute // lpParameters='%s'\n", lpParameters);
339 fprintf(stderr, "ShellExecute // lpDirectory='%s'\n", lpDirectory);
340 fprintf(stderr, "ShellExecute // iShowCmd=%04X\n", iShowCmd);
341 return 2; /* file not found */
345 /*************************************************************************
346 * FindExecutable [SHELL.21]
348 HINSTANCE FindExecutable(LPCSTR lpFile, LPCSTR lpDirectory, LPSTR lpResult)
350 fprintf(stderr, "FindExecutable : Empty Stub !!!\n");
354 char AppName[256], AppMisc[256];
355 INT AboutDlgProc(HWND hWnd, WORD msg, WORD wParam, LONG lParam);
357 /*************************************************************************
358 * ShellAbout [SHELL.22]
360 INT ShellAbout(HWND hWnd, LPCSTR szApp, LPCSTR szOtherStuff, HICON hIcon)
362 fprintf(stderr, "ShellAbout ! (%s, %s)\n", szApp, szOtherStuff);
364 strcpy(AppName, szApp);
365 strcpy(AppMisc, szOtherStuff);
367 return DialogBox(hSysRes, "SHELL_ABOUT_MSGBOX", hWnd, (FARPROC)AboutDlgProc);
371 /*************************************************************************
372 * AboutDlgProc [SHELL.33]
374 INT AboutDlgProc(HWND hWnd, WORD msg, WORD wParam, LONG lParam)
380 sprintf(temp, "About %s", AppName);
381 SetWindowText(hWnd, temp);
382 SetDlgItemText(hWnd, 100, AppMisc);
388 EndDialog(hWnd, TRUE);
395 /*************************************************************************
396 * ExtractIcon [SHELL.34]
398 HICON ExtractIcon(HINSTANCE hInst, LPCSTR lpszExeFileName, UINT nIconIndex)
402 HINSTANCE hInst2 = hInst;
403 fprintf(stderr, "ExtractIcon(%04X, '%s', %d\n",
404 hInst, lpszExeFileName, nIconIndex);
405 if (lpszExeFileName != NULL) {
406 hInst2 = LoadLibrary(lpszExeFileName);
408 if (hInst2 != 0 && nIconIndex == (UINT)-1) {
409 count = GetRsrcCount(hInst2, NE_RSCTYPE_GROUP_ICON);
410 printf("ExtractIcon // '%s' has %d icons !\n", lpszExeFileName, count);
413 if (hInst2 != hInst && hInst2 != 0) {
420 /*************************************************************************
421 * ExtractAssociatedIcon [SHELL.36]
423 HICON ExtractAssociatedIcon(HINSTANCE hInst,LPSTR lpIconPath, LPWORD lpiIcon)
425 fprintf(stderr, "ExtractAssociatedIcon : Empty Stub !!!\n");
428 /*************************************************************************
429 * RegisterShellHook [SHELL.102]
431 int RegisterShellHook(void *ptr)
433 fprintf(stderr, "RegisterShellHook : Empty Stub !!!\n");
438 /*************************************************************************
439 * ShellHookProc [SHELL.103]
441 int ShellHookProc(void)
443 fprintf(stderr, "ShellHookProc : Empty Stub !!!\n");