| 1 | /* $Id: shell32_main.cpp,v 1.8 2000-01-18 22:27:56 sandervl Exp $ */ | 
|---|
| 2 |  | 
|---|
| 3 | /* | 
|---|
| 4 | * Win32 SHELL32 for OS/2 | 
|---|
| 5 | * | 
|---|
| 6 | * Copyright 1999 Patrick Haller (haller@zebra.fh-weingarten.de) | 
|---|
| 7 | * Project Odin Software License can be found in LICENSE.TXT | 
|---|
| 8 | * | 
|---|
| 9 | *             Shell basics | 
|---|
| 10 | * | 
|---|
| 11 | *  1998 Marcus Meissner | 
|---|
| 12 | *  1998 Juergen Schmied (jsch)  *  <juergen.schmied@metronet.de> | 
|---|
| 13 | */ | 
|---|
| 14 |  | 
|---|
| 15 | /***************************************************************************** | 
|---|
| 16 | * Includes                                                                  * | 
|---|
| 17 | *****************************************************************************/ | 
|---|
| 18 |  | 
|---|
| 19 | #include <odin.h> | 
|---|
| 20 | #include <odinwrap.h> | 
|---|
| 21 | #include <os2sel.h> | 
|---|
| 22 |  | 
|---|
| 23 | #include <stdlib.h> | 
|---|
| 24 | #include <string.h> | 
|---|
| 25 |  | 
|---|
| 26 | #define ICOM_CINTERFACE 1 | 
|---|
| 27 | #define CINTERFACE 1 | 
|---|
| 28 |  | 
|---|
| 29 | #include "wine/winuser16.h" | 
|---|
| 30 | #include "winerror.h" | 
|---|
| 31 | #include "heap.h" | 
|---|
| 32 | #include "resource.h" | 
|---|
| 33 | #include "dlgs.h" | 
|---|
| 34 | //#include "ldt.h" | 
|---|
| 35 | #include "sysmetrics.h" | 
|---|
| 36 | #include "debugtools.h" | 
|---|
| 37 | #include "winreg.h" | 
|---|
| 38 | #include "authors.h" | 
|---|
| 39 | #include "winversion.h" | 
|---|
| 40 |  | 
|---|
| 41 | #include "shellapi.h" | 
|---|
| 42 | #include "pidl.h" | 
|---|
| 43 |  | 
|---|
| 44 | #include "shlobj.h" | 
|---|
| 45 | #include "shell32_main.h" | 
|---|
| 46 | #include "shlguid.h" | 
|---|
| 47 | #include "wine/undocshell.h" | 
|---|
| 48 | #include "shpolicy.h" | 
|---|
| 49 |  | 
|---|
| 50 | #include <heapstring.h> | 
|---|
| 51 | #include <misc.h> | 
|---|
| 52 |  | 
|---|
| 53 |  | 
|---|
| 54 | /***************************************************************************** | 
|---|
| 55 | * Local Variables                                                           * | 
|---|
| 56 | *****************************************************************************/ | 
|---|
| 57 |  | 
|---|
| 58 | ODINDEBUGCHANNEL(SHELL32-MAIN) | 
|---|
| 59 |  | 
|---|
| 60 |  | 
|---|
| 61 | #define MORE_DEBUG 1 | 
|---|
| 62 |  | 
|---|
| 63 |  | 
|---|
| 64 | /************************************************************************* | 
|---|
| 65 | * CommandLineToArgvW                          [SHELL32.7] | 
|---|
| 66 | */ | 
|---|
| 67 |  | 
|---|
| 68 | ODINFUNCTION2(LPWSTR*, CommandLineToArgvW, LPWSTR,  cmdline, | 
|---|
| 69 | LPDWORD, numargs) | 
|---|
| 70 | {  LPWSTR  *argv,s,t; | 
|---|
| 71 | int   i; | 
|---|
| 72 |  | 
|---|
| 73 | /* to get writeable copy */ | 
|---|
| 74 | cmdline = HEAP_strdupW( GetProcessHeap(), 0, cmdline); | 
|---|
| 75 | s=cmdline;i=0; | 
|---|
| 76 | while (*s) | 
|---|
| 77 | { /* space */ | 
|---|
| 78 | if (*s==0x0020) | 
|---|
| 79 | { i++; | 
|---|
| 80 | s++; | 
|---|
| 81 | while (*s && *s==0x0020) | 
|---|
| 82 | s++; | 
|---|
| 83 | continue; | 
|---|
| 84 | } | 
|---|
| 85 | s++; | 
|---|
| 86 | } | 
|---|
| 87 | argv=(LPWSTR*)HeapAlloc( GetProcessHeap(), 0, sizeof(LPWSTR)*(i+1) ); | 
|---|
| 88 | s=t=cmdline; | 
|---|
| 89 | i=0; | 
|---|
| 90 | while (*s) | 
|---|
| 91 | { if (*s==0x0020) | 
|---|
| 92 | { *s=0; | 
|---|
| 93 | argv[i++]=HEAP_strdupW( GetProcessHeap(), 0, t ); | 
|---|
| 94 | *s=0x0020; | 
|---|
| 95 | while (*s && *s==0x0020) | 
|---|
| 96 | s++; | 
|---|
| 97 | if (*s) | 
|---|
| 98 | t=s+1; | 
|---|
| 99 | else | 
|---|
| 100 | t=s; | 
|---|
| 101 | continue; | 
|---|
| 102 | } | 
|---|
| 103 | s++; | 
|---|
| 104 | } | 
|---|
| 105 | if (*t) | 
|---|
| 106 | argv[i++]=(LPWSTR)HEAP_strdupW( GetProcessHeap(), 0, t ); | 
|---|
| 107 |  | 
|---|
| 108 | HeapFree( GetProcessHeap(), 0, cmdline ); | 
|---|
| 109 | argv[i]=NULL; | 
|---|
| 110 | *numargs=i; | 
|---|
| 111 | return argv; | 
|---|
| 112 | } | 
|---|
| 113 |  | 
|---|
| 114 | /************************************************************************* | 
|---|
| 115 | * Control_RunDLL                           [SHELL32.12] | 
|---|
| 116 | * | 
|---|
| 117 | * Wild speculation in the following! | 
|---|
| 118 | * | 
|---|
| 119 | * http://premium.microsoft.com/msdn/library/techart/msdn193.htm | 
|---|
| 120 | */ | 
|---|
| 121 |  | 
|---|
| 122 | ODINPROCEDURE4(Control_RunDLL,HWND,   hwnd, | 
|---|
| 123 | LPCVOID,code, | 
|---|
| 124 | LPCSTR, cmd, | 
|---|
| 125 | DWORD,  arg4) | 
|---|
| 126 | { | 
|---|
| 127 | dprintf(("SHELL32:Shell32_Main:Control_RunDLL not implemented.\n")); | 
|---|
| 128 | } | 
|---|
| 129 |  | 
|---|
| 130 | /************************************************************************* | 
|---|
| 131 | * SHGetFileInfoA                           [SHELL32.254] | 
|---|
| 132 | */ | 
|---|
| 133 |  | 
|---|
| 134 | ODINFUNCTION5(DWORD, SHGetFileInfoA, LPCSTR,       path, | 
|---|
| 135 | DWORD,        dwFileAttributes, | 
|---|
| 136 | SHFILEINFOA*, psfi, | 
|---|
| 137 | UINT,         sizeofpsfi, | 
|---|
| 138 | UINT,         flags ) | 
|---|
| 139 | { | 
|---|
| 140 | char szLoaction[MAX_PATH]; | 
|---|
| 141 | int iIndex; | 
|---|
| 142 | DWORD ret = TRUE, dwAttributes = 0; | 
|---|
| 143 | IShellFolder * psfParent = NULL; | 
|---|
| 144 | IExtractIcon * pei = NULL; | 
|---|
| 145 | LPITEMIDLIST   pidlLast = NULL, pidl = NULL; | 
|---|
| 146 | HRESULT hr = S_OK; | 
|---|
| 147 |  | 
|---|
| 148 | dprintf(("SHELL32:Shell32_main:SHGetFileInfoA (%s,0x%lx,%p,0x%x,0x%x)\n", | 
|---|
| 149 | (flags & SHGFI_PIDL)? "pidl" : path, dwFileAttributes, psfi, sizeofpsfi, flags)); | 
|---|
| 150 |  | 
|---|
| 151 | #ifdef MORE_DEBUG | 
|---|
| 152 | ZeroMemory(psfi, sizeof(SHFILEINFOA)); | 
|---|
| 153 | #endif | 
|---|
| 154 | if ((flags & SHGFI_USEFILEATTRIBUTES) && (flags & (SHGFI_ATTRIBUTES|SHGFI_EXETYPE|SHGFI_PIDL))) | 
|---|
| 155 | return FALSE; | 
|---|
| 156 |  | 
|---|
| 157 | /* translate the path into a pidl only when SHGFI_USEFILEATTRIBUTES in not specified | 
|---|
| 158 | the pidl functions fail on not existing file names */ | 
|---|
| 159 | if (flags & SHGFI_PIDL) | 
|---|
| 160 | { | 
|---|
| 161 | pidl = (LPCITEMIDLIST) path; | 
|---|
| 162 | if (!pidl ) | 
|---|
| 163 | { | 
|---|
| 164 | dprintf(("pidl is null!\n")); | 
|---|
| 165 | return FALSE; | 
|---|
| 166 | } | 
|---|
| 167 | } | 
|---|
| 168 | else if (!(flags & SHGFI_USEFILEATTRIBUTES)) | 
|---|
| 169 | { | 
|---|
| 170 | hr = SHILCreateFromPathA ( path, &pidl, &dwAttributes); | 
|---|
| 171 | /* note: the attributes in ISF::ParseDisplayName are not implemented */ | 
|---|
| 172 | } | 
|---|
| 173 |  | 
|---|
| 174 | /* get the parent shellfolder */ | 
|---|
| 175 | if (pidl) | 
|---|
| 176 | { | 
|---|
| 177 | hr = SHBindToParent( pidl, &IID_IShellFolder, (LPVOID*)&psfParent, &pidlLast); | 
|---|
| 178 | } | 
|---|
| 179 |  | 
|---|
| 180 | /* get the attributes of the child */ | 
|---|
| 181 | if (SUCCEEDED(hr) && (flags & SHGFI_ATTRIBUTES)) | 
|---|
| 182 | { | 
|---|
| 183 | if (!(flags & SHGFI_ATTR_SPECIFIED)) | 
|---|
| 184 | { | 
|---|
| 185 | psfi->dwAttributes = 0xffffffff; | 
|---|
| 186 | } | 
|---|
| 187 | IShellFolder_GetAttributesOf(psfParent, 1 , &pidlLast, &(psfi->dwAttributes)); | 
|---|
| 188 | } | 
|---|
| 189 |  | 
|---|
| 190 | /* get the displayname */ | 
|---|
| 191 | if (SUCCEEDED(hr) && (flags & SHGFI_DISPLAYNAME)) | 
|---|
| 192 | { | 
|---|
| 193 | if (flags & SHGFI_USEFILEATTRIBUTES) | 
|---|
| 194 | { | 
|---|
| 195 | strcpy (psfi->szDisplayName, PathFindFilenameA(path)); | 
|---|
| 196 | } | 
|---|
| 197 | else | 
|---|
| 198 | { | 
|---|
| 199 | STRRET str; | 
|---|
| 200 | hr = IShellFolder_GetDisplayNameOf(psfParent, pidlLast, SHGDN_INFOLDER, &str); | 
|---|
| 201 | StrRetToStrNA (psfi->szDisplayName, MAX_PATH, &str, pidlLast); | 
|---|
| 202 | } | 
|---|
| 203 | } | 
|---|
| 204 |  | 
|---|
| 205 | /* get the type name */ | 
|---|
| 206 | if (SUCCEEDED(hr) && (flags & SHGFI_TYPENAME)) | 
|---|
| 207 | { | 
|---|
| 208 | _ILGetFileType(pidlLast, psfi->szTypeName, 80); | 
|---|
| 209 | } | 
|---|
| 210 |  | 
|---|
| 211 | /* ### icons ###*/ | 
|---|
| 212 | if (flags & SHGFI_LINKOVERLAY) | 
|---|
| 213 | dprintf(("SHELL32:Shell32_main:SHGetFileInfoA set icon to link, stub\n")); | 
|---|
| 214 |  | 
|---|
| 215 | if (flags & SHGFI_OPENICON) | 
|---|
| 216 | dprintf(("SHELL32:Shell32_main:SHGetFileInfoA set to open icon, stub\n")); | 
|---|
| 217 |  | 
|---|
| 218 | if (flags & SHGFI_SELECTED) | 
|---|
| 219 | dprintf(("SHELL32:Shell32_main:SHGetFileInfoA set icon to selected, stub\n")); | 
|---|
| 220 |  | 
|---|
| 221 | if (flags & SHGFI_SHELLICONSIZE) | 
|---|
| 222 | dprintf(("SHELL32:Shell32_main:SHGetFileInfoA set icon to shell size, stub\n")); | 
|---|
| 223 |  | 
|---|
| 224 | /* get the iconlocation */ | 
|---|
| 225 | if (SUCCEEDED(hr) && (flags & SHGFI_ICONLOCATION )) | 
|---|
| 226 | { | 
|---|
| 227 | UINT uDummy,uFlags; | 
|---|
| 228 | hr = IShellFolder_GetUIObjectOf(psfParent, 0, 1, &pidlLast, &IID_IExtractIconA, &uDummy, (LPVOID*)&pei); | 
|---|
| 229 |  | 
|---|
| 230 | if (SUCCEEDED(hr)) | 
|---|
| 231 | { | 
|---|
| 232 | hr = IExtractIconA_GetIconLocation(pei, 0, szLoaction, MAX_PATH, &iIndex, &uFlags); | 
|---|
| 233 | /* fixme what to do with the index? */ | 
|---|
| 234 |  | 
|---|
| 235 | if(uFlags != GIL_NOTFILENAME) | 
|---|
| 236 | strcpy (psfi->szDisplayName, szLoaction); | 
|---|
| 237 | else | 
|---|
| 238 | ret = FALSE; | 
|---|
| 239 |  | 
|---|
| 240 | IExtractIconA_Release(pei); | 
|---|
| 241 | } | 
|---|
| 242 | } | 
|---|
| 243 |  | 
|---|
| 244 | /* get icon index (or load icon)*/ | 
|---|
| 245 | if (SUCCEEDED(hr) && (flags & (SHGFI_ICON | SHGFI_SYSICONINDEX))) | 
|---|
| 246 | { | 
|---|
| 247 | if (flags & SHGFI_USEFILEATTRIBUTES) | 
|---|
| 248 | { | 
|---|
| 249 | char sTemp [MAX_PATH]; | 
|---|
| 250 | char * szExt; | 
|---|
| 251 | DWORD dwNr=0; | 
|---|
| 252 |  | 
|---|
| 253 | lstrcpynA(sTemp, path, MAX_PATH); | 
|---|
| 254 | szExt = (LPSTR) PathFindExtensionA(sTemp); | 
|---|
| 255 | if( szExt && HCR_MapTypeToValue(szExt, sTemp, MAX_PATH, TRUE) | 
|---|
| 256 | && HCR_GetDefaultIcon(sTemp, sTemp, MAX_PATH, &dwNr)) | 
|---|
| 257 | { | 
|---|
| 258 | if (!strcmp("%1",sTemp))            /* icon is in the file */ | 
|---|
| 259 | { | 
|---|
| 260 | strcpy(sTemp, path); | 
|---|
| 261 | } | 
|---|
| 262 | /* FIXME: if sTemp contains a valid filename, get the icon | 
|---|
| 263 | from there, index is in dwNr | 
|---|
| 264 | */ | 
|---|
| 265 | psfi->iIcon = 2; | 
|---|
| 266 | } | 
|---|
| 267 | else                                  /* default icon */ | 
|---|
| 268 | { | 
|---|
| 269 | psfi->iIcon = 0; | 
|---|
| 270 | } | 
|---|
| 271 | } | 
|---|
| 272 | else | 
|---|
| 273 | { | 
|---|
| 274 | if (!(PidlToSicIndex(psfParent, pidlLast, (flags && SHGFI_LARGEICON), (PUINT)&(psfi->iIcon)))) | 
|---|
| 275 | { | 
|---|
| 276 | ret = FALSE; | 
|---|
| 277 | } | 
|---|
| 278 | } | 
|---|
| 279 | if (ret) | 
|---|
| 280 | { | 
|---|
| 281 | ret = (DWORD) ((flags && SHGFI_LARGEICON) ? ShellBigIconList : ShellSmallIconList); | 
|---|
| 282 | } | 
|---|
| 283 | } | 
|---|
| 284 |  | 
|---|
| 285 | /* icon handle */ | 
|---|
| 286 | if (SUCCEEDED(hr) && (flags & SHGFI_ICON)) | 
|---|
| 287 | psfi->hIcon = pImageList_GetIcon((flags && SHGFI_LARGEICON) ? ShellBigIconList:ShellSmallIconList, psfi->iIcon, ILD_NORMAL); | 
|---|
| 288 |  | 
|---|
| 289 |  | 
|---|
| 290 | if (flags & SHGFI_EXETYPE) | 
|---|
| 291 | dprintf(("SHELL32:Shell32_main:SHGetFileInfoA type of executable, stub\n")); | 
|---|
| 292 |  | 
|---|
| 293 | if (flags & (SHGFI_UNKNOWN1 | SHGFI_UNKNOWN2 | SHGFI_UNKNOWN3)) | 
|---|
| 294 | dprintf(("SHELL32:Shell32_main:SHGetFileInfoA unknown attribute!\n")); | 
|---|
| 295 |  | 
|---|
| 296 | if (psfParent) | 
|---|
| 297 | IShellFolder_Release(psfParent); | 
|---|
| 298 |  | 
|---|
| 299 | if (hr != S_OK) | 
|---|
| 300 | ret = FALSE; | 
|---|
| 301 |  | 
|---|
| 302 | #ifdef MORE_DEBUG | 
|---|
| 303 | TRACE_(shell) ("icon=0x%08x index=0x%08x attr=0x%08lx name=%s type=%s\n", | 
|---|
| 304 | psfi->hIcon, psfi->iIcon, psfi->dwAttributes, psfi->szDisplayName, psfi->szTypeName); | 
|---|
| 305 | #endif | 
|---|
| 306 | return ret; | 
|---|
| 307 | } | 
|---|
| 308 |  | 
|---|
| 309 | /************************************************************************* | 
|---|
| 310 | * SHGetFileInfoW                           [SHELL32.255] | 
|---|
| 311 | */ | 
|---|
| 312 |  | 
|---|
| 313 | ODINFUNCTION5(DWORD, SHGetFileInfoW, LPCWSTR,      path, | 
|---|
| 314 | DWORD,        dwFileAttributes, | 
|---|
| 315 | SHFILEINFOW*, psfi, | 
|---|
| 316 | UINT,         sizeofpsfi, | 
|---|
| 317 | UINT,        flags) | 
|---|
| 318 | { | 
|---|
| 319 | dprintf(("SHELL32:Shell32_main:SHGetFileInfoW not implemented\n")); | 
|---|
| 320 | return 0; | 
|---|
| 321 | } | 
|---|
| 322 |  | 
|---|
| 323 |  | 
|---|
| 324 | /************************************************************************* | 
|---|
| 325 | * ExtractIconA                                [SHELL32.133] | 
|---|
| 326 | */ | 
|---|
| 327 |  | 
|---|
| 328 | ODINFUNCTION3(HICON, ExtractIconA, HINSTANCE, hInstance, | 
|---|
| 329 | LPCSTR,    lpszExeFileName, | 
|---|
| 330 | UINT,      nIconIndex ) | 
|---|
| 331 | { | 
|---|
| 332 | dprintf(("SHELL32:Shell32_Main:ExtractIconA not implemented.\n")); | 
|---|
| 333 |  | 
|---|
| 334 | #if 0 | 
|---|
| 335 | //@@@PH | 
|---|
| 336 | HGLOBAL handle = InternalExtractIconA(hInstance,lpszExeFileName,nIconIndex, 1); | 
|---|
| 337 | TRACE_(shell)("\n"); | 
|---|
| 338 | if( handle ) | 
|---|
| 339 | { | 
|---|
| 340 | HICON* ptr = (HICON*)GlobalLock(handle); | 
|---|
| 341 | HICON  hIcon = *ptr; | 
|---|
| 342 |  | 
|---|
| 343 | GlobalFree(handle); | 
|---|
| 344 | return hIcon; | 
|---|
| 345 | } | 
|---|
| 346 | #endif | 
|---|
| 347 | return 0; | 
|---|
| 348 | } | 
|---|
| 349 |  | 
|---|
| 350 | /************************************************************************* | 
|---|
| 351 | * ExtractIconW                                [SHELL32.180] | 
|---|
| 352 | */ | 
|---|
| 353 |  | 
|---|
| 354 | ODINFUNCTION3(HICON, ExtractIconW, HINSTANCE, hInstance, | 
|---|
| 355 | LPCWSTR,   lpszExeFileName, | 
|---|
| 356 | UINT,      nIconIndex ) | 
|---|
| 357 | { LPSTR  exefn; | 
|---|
| 358 | HICON  ret; | 
|---|
| 359 |  | 
|---|
| 360 | exefn = HEAP_strdupWtoA(GetProcessHeap(),0,lpszExeFileName); | 
|---|
| 361 | ret = ExtractIconA(hInstance,exefn,nIconIndex); | 
|---|
| 362 |  | 
|---|
| 363 | HeapFree(GetProcessHeap(),0,exefn); | 
|---|
| 364 | return ret; | 
|---|
| 365 | } | 
|---|
| 366 |  | 
|---|
| 367 | /************************************************************************* | 
|---|
| 368 | * FindExecutableA                             [SHELL32.184] | 
|---|
| 369 | */ | 
|---|
| 370 |  | 
|---|
| 371 | ODINFUNCTION3(HINSTANCE, FindExecutableA, LPCSTR, lpFile, | 
|---|
| 372 | LPCSTR, lpDirectory, | 
|---|
| 373 | LPSTR,  lpResult ) | 
|---|
| 374 | { HINSTANCE retval=31;    /* default - 'No association was found' */ | 
|---|
| 375 | char old_dir[1024]; | 
|---|
| 376 |  | 
|---|
| 377 | dprintf(("File %s, Dir %s\n", | 
|---|
| 378 | (lpFile != NULL?lpFile:"-"), | 
|---|
| 379 | (lpDirectory != NULL?lpDirectory:"-"))); | 
|---|
| 380 |  | 
|---|
| 381 | lpResult[0]='\0'; /* Start off with an empty return string */ | 
|---|
| 382 |  | 
|---|
| 383 | /* trap NULL parameters on entry */ | 
|---|
| 384 | if (( lpFile == NULL ) || ( lpResult == NULL )) | 
|---|
| 385 | { /* FIXME - should throw a warning, perhaps! */ | 
|---|
| 386 | return 2; /* File not found. Close enough, I guess. */ | 
|---|
| 387 | } | 
|---|
| 388 |  | 
|---|
| 389 | if (lpDirectory) | 
|---|
| 390 | { GetCurrentDirectoryA( sizeof(old_dir), old_dir ); | 
|---|
| 391 | SetCurrentDirectoryA( lpDirectory ); | 
|---|
| 392 | } | 
|---|
| 393 |  | 
|---|
| 394 | retval = SHELL_FindExecutable( lpFile, "open", lpResult ); | 
|---|
| 395 |  | 
|---|
| 396 | dprintf(("returning %s\n", lpResult)); | 
|---|
| 397 | if (lpDirectory) | 
|---|
| 398 | SetCurrentDirectoryA( old_dir ); | 
|---|
| 399 | return retval; | 
|---|
| 400 | } | 
|---|
| 401 |  | 
|---|
| 402 | /************************************************************************* | 
|---|
| 403 | * FindExecutableW                             [SHELL32.219] | 
|---|
| 404 | */ | 
|---|
| 405 | ODINFUNCTION3(HINSTANCE, FindExecutableW, LPCWSTR, lpFile, | 
|---|
| 406 | LPCWSTR, lpDirectory, | 
|---|
| 407 | LPWSTR,  lpResult ) | 
|---|
| 408 | { | 
|---|
| 409 | dprintf(("FindExecutableW not implemented.\n")); | 
|---|
| 410 | return 31;    /* default - 'No association was found' */ | 
|---|
| 411 | } | 
|---|
| 412 |  | 
|---|
| 413 | typedef struct | 
|---|
| 414 | { LPCSTR  szApp; | 
|---|
| 415 | LPCSTR  szOtherStuff; | 
|---|
| 416 | HICON hIcon; | 
|---|
| 417 | } ABOUT_INFO; | 
|---|
| 418 |  | 
|---|
| 419 | #define     IDC_STATIC_TEXT                 100 | 
|---|
| 420 | #define     IDC_LISTBOX                     99 | 
|---|
| 421 | #define     IDC_WINE_TEXT                   98 | 
|---|
| 422 |  | 
|---|
| 423 | #define     DROP_FIELD_TOP                  (-15) | 
|---|
| 424 | #define     DROP_FIELD_HEIGHT            15 | 
|---|
| 425 |  | 
|---|
| 426 | static BOOL __get_dropline( HWND hWnd, LPRECT lprect ) | 
|---|
| 427 | { HWND hWndCtl = GetDlgItem(hWnd, IDC_WINE_TEXT); | 
|---|
| 428 | if( hWndCtl ) | 
|---|
| 429 | { GetWindowRect( hWndCtl, lprect ); | 
|---|
| 430 | MapWindowPoints( 0, hWnd, (LPPOINT)lprect, 2 ); | 
|---|
| 431 | lprect->bottom = (lprect->top += DROP_FIELD_TOP); | 
|---|
| 432 | return TRUE; | 
|---|
| 433 | } | 
|---|
| 434 | return FALSE; | 
|---|
| 435 | } | 
|---|
| 436 |  | 
|---|
| 437 | /************************************************************************* | 
|---|
| 438 | * SHAppBarMessage32                           [SHELL32.207] | 
|---|
| 439 | */ | 
|---|
| 440 |  | 
|---|
| 441 | ODINFUNCTION2(UINT, SHAppBarMessage, DWORD,       msg, | 
|---|
| 442 | PAPPBARDATA, data) | 
|---|
| 443 | { | 
|---|
| 444 | dprintf(("SHELL32:Shell32_Main:SHAppBarMessage not implemented.\n")); | 
|---|
| 445 |  | 
|---|
| 446 | switch (msg) | 
|---|
| 447 | { case ABM_GETSTATE: | 
|---|
| 448 | return ABS_ALWAYSONTOP | ABS_AUTOHIDE; | 
|---|
| 449 | case ABM_GETTASKBARPOS: | 
|---|
| 450 | /* fake a taskbar on the bottom of the desktop */ | 
|---|
| 451 | { RECT rec; | 
|---|
| 452 | GetWindowRect(GetDesktopWindow(), &rec); | 
|---|
| 453 | rec.left = 0; | 
|---|
| 454 | rec.top = rec.bottom - 2; | 
|---|
| 455 | } | 
|---|
| 456 | return TRUE; | 
|---|
| 457 | case ABM_ACTIVATE: | 
|---|
| 458 | case ABM_GETAUTOHIDEBAR: | 
|---|
| 459 | case ABM_NEW: | 
|---|
| 460 | case ABM_QUERYPOS: | 
|---|
| 461 | case ABM_REMOVE: | 
|---|
| 462 | case ABM_SETAUTOHIDEBAR: | 
|---|
| 463 | case ABM_SETPOS: | 
|---|
| 464 | case ABM_WINDOWPOSCHANGED: | 
|---|
| 465 | return FALSE; | 
|---|
| 466 | } | 
|---|
| 467 | return 0; | 
|---|
| 468 | } | 
|---|
| 469 |  | 
|---|
| 470 | /************************************************************************* | 
|---|
| 471 | * SHHelpShortcuts_RunDLL                   [SHELL32.224] | 
|---|
| 472 | * | 
|---|
| 473 | */ | 
|---|
| 474 |  | 
|---|
| 475 | ODINFUNCTION4(DWORD, SHHelpShortcuts_RunDLL, DWORD, dwArg1, | 
|---|
| 476 | DWORD, dwArg2, | 
|---|
| 477 | DWORD, dwArg3, | 
|---|
| 478 | DWORD, dwArg4) | 
|---|
| 479 | { | 
|---|
| 480 | dprintf(("SHELL32:Shell32_Main:SHHelpShortcuts_RunDLL not implemented.\n")); | 
|---|
| 481 | return 0; | 
|---|
| 482 | } | 
|---|
| 483 |  | 
|---|
| 484 | /************************************************************************* | 
|---|
| 485 | * SHLoadInProc                                [SHELL32.225] | 
|---|
| 486 | * | 
|---|
| 487 | */ | 
|---|
| 488 |  | 
|---|
| 489 | ODINFUNCTION1(DWORD, SHLoadInProc, DWORD, dwArg1) | 
|---|
| 490 | { | 
|---|
| 491 | dprintf(("SHELL32:Shell32_Main:SHLoadInProc not implemented.\n")); | 
|---|
| 492 | return 0; | 
|---|
| 493 | } | 
|---|
| 494 |  | 
|---|
| 495 |  | 
|---|
| 496 |  | 
|---|
| 497 | /************************************************************************* | 
|---|
| 498 | * ShellExecuteA                            [SHELL32.245] | 
|---|
| 499 | */ | 
|---|
| 500 |  | 
|---|
| 501 | ODINFUNCTION6(HINSTANCE, ShellExecuteA, HWND,   hWnd, | 
|---|
| 502 | LPCSTR, lpOperation, | 
|---|
| 503 | LPCSTR, lpFile, | 
|---|
| 504 | LPCSTR, lpParameters, | 
|---|
| 505 | LPCSTR, lpDirectory, | 
|---|
| 506 | INT,    iShowCmd ) | 
|---|
| 507 | {   HINSTANCE retval=31; | 
|---|
| 508 | char old_dir[1024]; | 
|---|
| 509 | char cmd[256]; | 
|---|
| 510 |  | 
|---|
| 511 | if (lpFile==NULL) return 0; /* should not happen */ | 
|---|
| 512 | if (lpOperation==NULL) /* default is open */ | 
|---|
| 513 | lpOperation="open"; | 
|---|
| 514 |  | 
|---|
| 515 | if (lpDirectory) | 
|---|
| 516 | { GetCurrentDirectoryA( sizeof(old_dir), old_dir ); | 
|---|
| 517 | SetCurrentDirectoryA( lpDirectory ); | 
|---|
| 518 | } | 
|---|
| 519 |  | 
|---|
| 520 | retval = SHELL_FindExecutable( lpFile, lpOperation, cmd ); | 
|---|
| 521 |  | 
|---|
| 522 | if (retval > 32)  /* Found */ | 
|---|
| 523 | { | 
|---|
| 524 | if (lpParameters) | 
|---|
| 525 | { | 
|---|
| 526 | strcat(cmd," "); | 
|---|
| 527 | strcat(cmd,lpParameters); | 
|---|
| 528 | } | 
|---|
| 529 |  | 
|---|
| 530 | dprintf(("starting %s\n",cmd)); | 
|---|
| 531 | retval = WinExec( cmd, iShowCmd ); | 
|---|
| 532 | } | 
|---|
| 533 | if (lpDirectory) | 
|---|
| 534 | SetCurrentDirectoryA( old_dir ); | 
|---|
| 535 | return retval; | 
|---|
| 536 | } | 
|---|
| 537 |  | 
|---|
| 538 |  | 
|---|
| 539 | /************************************************************************* | 
|---|
| 540 | * ShellExecuteW                            [SHELL32.294] | 
|---|
| 541 | * from shellapi.h | 
|---|
| 542 | * WINSHELLAPI HINSTANCE APIENTRY ShellExecuteW(HWND hwnd, LPCWSTR lpOperation, | 
|---|
| 543 | * LPCWSTR lpFile, LPCWSTR lpParameters, LPCWSTR lpDirectory, INT nShowCmd); | 
|---|
| 544 | */ | 
|---|
| 545 |  | 
|---|
| 546 | ODINFUNCTION6(HINSTANCE, ShellExecuteW, HWND,    hWnd, | 
|---|
| 547 | LPCWSTR, lpOperation, | 
|---|
| 548 | LPCWSTR, lpFile, | 
|---|
| 549 | LPCWSTR, lpParameters, | 
|---|
| 550 | LPCWSTR, lpDirectory, | 
|---|
| 551 | INT,     iShowCmd ) | 
|---|
| 552 | { | 
|---|
| 553 | dprintf(("SHELL32:Shell32_Main:ShellExecuteW not implemented\n")); | 
|---|
| 554 | return 0; | 
|---|
| 555 | } | 
|---|
| 556 |  | 
|---|
| 557 |  | 
|---|
| 558 | /************************************************************************* | 
|---|
| 559 | * AboutDlgProc32                           (internal) | 
|---|
| 560 | */ | 
|---|
| 561 | #define IDC_ODINLOGO 2001 | 
|---|
| 562 | #define IDB_ODINLOGO 5555 | 
|---|
| 563 |  | 
|---|
| 564 | BOOL WINAPI AboutDlgProc( HWND hWnd, UINT msg, WPARAM wParam, | 
|---|
| 565 | LPARAM lParam ) | 
|---|
| 566 | { | 
|---|
| 567 | HWND hWndCtl; | 
|---|
| 568 | char Template[512], AppTitle[512]; | 
|---|
| 569 |  | 
|---|
| 570 | switch(msg) | 
|---|
| 571 | { | 
|---|
| 572 | case WM_INITDIALOG: | 
|---|
| 573 | { | 
|---|
| 574 | ABOUT_INFO *info = (ABOUT_INFO *)lParam; | 
|---|
| 575 | if(info) | 
|---|
| 576 | { | 
|---|
| 577 | const char* const *pstr = SHELL_People; | 
|---|
| 578 |  | 
|---|
| 579 | SendDlgItemMessageA(hWnd, stc1, STM_SETICON,info->hIcon, 0); | 
|---|
| 580 | GetWindowTextA( hWnd, Template, sizeof(Template) ); | 
|---|
| 581 | sprintf( AppTitle, Template, info->szApp ); | 
|---|
| 582 | SetWindowTextA( hWnd, AppTitle ); | 
|---|
| 583 | SetWindowTextA( GetDlgItem(hWnd, IDC_STATIC_TEXT), info->szOtherStuff ); | 
|---|
| 584 |  | 
|---|
| 585 | HWND hwndOdinLogo = GetDlgItem(hWnd, IDC_ODINLOGO); | 
|---|
| 586 | if(hwndOdinLogo) { | 
|---|
| 587 | HBITMAP hBitmap = LoadBitmapA(shell32_hInstance, MAKEINTRESOURCEA(IDB_ODINLOGO)); | 
|---|
| 588 | SendMessageA(hwndOdinLogo, STM_SETIMAGE, IMAGE_BITMAP, (LPARAM)hBitmap); | 
|---|
| 589 | } | 
|---|
| 590 |  | 
|---|
| 591 | hWndCtl = GetDlgItem(hWnd, IDC_LISTBOX); | 
|---|
| 592 | SendMessageA( hWndCtl, WM_SETREDRAW, 0, 0 ); | 
|---|
| 593 | while (*pstr) | 
|---|
| 594 | { | 
|---|
| 595 | SendMessageA( hWndCtl, LB_ADDSTRING, (WPARAM)-1, (LPARAM)*pstr ); | 
|---|
| 596 | pstr++; | 
|---|
| 597 | } | 
|---|
| 598 | SendMessageA( hWndCtl, WM_SETREDRAW, 1, 0 ); | 
|---|
| 599 | } | 
|---|
| 600 | return 1; | 
|---|
| 601 | } | 
|---|
| 602 |  | 
|---|
| 603 | case WM_PAINT: | 
|---|
| 604 | { | 
|---|
| 605 | RECT rect; | 
|---|
| 606 | PAINTSTRUCT ps; | 
|---|
| 607 | HDC hDC = BeginPaint( hWnd, &ps ); | 
|---|
| 608 |  | 
|---|
| 609 | if( __get_dropline( hWnd, &rect ) ) { | 
|---|
| 610 | SelectObject( hDC, GetStockObject( BLACK_PEN ) ); | 
|---|
| 611 | MoveToEx( hDC, rect.left, rect.top, NULL ); | 
|---|
| 612 | LineTo( hDC, rect.right, rect.bottom ); | 
|---|
| 613 | } | 
|---|
| 614 | EndPaint( hWnd, &ps ); | 
|---|
| 615 | break; | 
|---|
| 616 | } | 
|---|
| 617 |  | 
|---|
| 618 | #if 0 | 
|---|
| 619 | // @@@PH turned off | 
|---|
| 620 | case WM_LBTRACKPOINT: | 
|---|
| 621 | hWndCtl = GetDlgItem(hWnd, IDC_LISTBOX); | 
|---|
| 622 | if( (INT)GetKeyState( VK_CONTROL ) < 0 ) | 
|---|
| 623 | { if( DragDetect( hWndCtl, *((LPPOINT)&lParam) ) ) | 
|---|
| 624 | { INT idx = SendMessageA( hWndCtl, LB_GETCURSEL, 0, 0 ); | 
|---|
| 625 | if( idx != -1 ) | 
|---|
| 626 | { INT length = SendMessageA( hWndCtl, LB_GETTEXTLEN, (WPARAM)idx, 0 ); | 
|---|
| 627 | HGLOBAL hMemObj = GlobalAlloc( GMEM_MOVEABLE, length + 1 ); | 
|---|
| 628 | char* pstr = (char*)GlobalLock( hMemObj ); | 
|---|
| 629 |  | 
|---|
| 630 | if( pstr ) | 
|---|
| 631 | { HCURSOR hCursor = LoadCursorA( 0, (LPCSTR)OCR_DRAGOBJECT ); | 
|---|
| 632 | SendMessageA( hWndCtl, LB_GETTEXT, (WPARAM)idx, (LPARAM)pstr ); | 
|---|
| 633 | SendMessageA( hWndCtl, LB_DELETESTRING, (WPARAM)idx, 0 ); | 
|---|
| 634 | UpdateWindow( hWndCtl ); | 
|---|
| 635 | //@@@PH DragObject16 experimentally replaced by DragObject | 
|---|
| 636 | if( !DragObject(hWnd, hWnd, DRAGOBJ_DATA, hMemObj, hCursor) ) | 
|---|
| 637 | SendMessageA( hWndCtl, LB_ADDSTRING, (WPARAM)-1, (LPARAM)pstr ); | 
|---|
| 638 | } | 
|---|
| 639 | if( hMemObj ) | 
|---|
| 640 | GlobalFree( hMemObj ); | 
|---|
| 641 | } | 
|---|
| 642 | } | 
|---|
| 643 | } | 
|---|
| 644 | break; | 
|---|
| 645 |  | 
|---|
| 646 | case WM_QUERYDROPOBJECT: | 
|---|
| 647 | if( wParam == 0 ) | 
|---|
| 648 | { LPDRAGINFO lpDragInfo = (LPDRAGINFO)PTR_SEG_TO_LIN((SEGPTR)lParam); | 
|---|
| 649 | if( lpDragInfo && lpDragInfo->wFlags == DRAGOBJ_DATA ) | 
|---|
| 650 | { RECT rect; | 
|---|
| 651 | if( __get_dropline( hWnd, &rect ) ) | 
|---|
| 652 | { POINT pt; | 
|---|
| 653 | pt.x=lpDragInfo->pt.x; | 
|---|
| 654 | pt.x=lpDragInfo->pt.y; | 
|---|
| 655 | rect.bottom += DROP_FIELD_HEIGHT; | 
|---|
| 656 | if( PtInRect( &rect, pt ) ) | 
|---|
| 657 | { SetWindowLongA( hWnd, DWL_MSGRESULT, 1 ); | 
|---|
| 658 | return TRUE; | 
|---|
| 659 | } | 
|---|
| 660 | } | 
|---|
| 661 | } | 
|---|
| 662 | } | 
|---|
| 663 | break; | 
|---|
| 664 |  | 
|---|
| 665 | case WM_DROPOBJECT: | 
|---|
| 666 | if( wParam == hWnd ) | 
|---|
| 667 | { LPDRAGINFO lpDragInfo = (LPDRAGINFO)PTR_SEG_TO_LIN((SEGPTR)lParam); | 
|---|
| 668 | if( lpDragInfo && lpDragInfo->wFlags == DRAGOBJ_DATA && lpDragInfo->hList ) | 
|---|
| 669 | { char* pstr = (char*)GlobalLock( (HGLOBAL)(lpDragInfo->hList) ); | 
|---|
| 670 | if( pstr ) | 
|---|
| 671 | { static char __appendix_str[] = " with"; | 
|---|
| 672 |  | 
|---|
| 673 | hWndCtl = GetDlgItem( hWnd, IDC_WINE_TEXT ); | 
|---|
| 674 | SendMessageA( hWndCtl, WM_GETTEXT, 512, (LPARAM)Template ); | 
|---|
| 675 | if( !strncmp( Template, "WINE", 4 ) ) | 
|---|
| 676 | SetWindowTextA( GetDlgItem(hWnd, IDC_STATIC_TEXT), Template ); | 
|---|
| 677 | else | 
|---|
| 678 | { char* pch = Template + strlen(Template) - strlen(__appendix_str); | 
|---|
| 679 | *pch = '\0'; | 
|---|
| 680 | SendMessageA( GetDlgItem(hWnd, IDC_LISTBOX), LB_ADDSTRING, | 
|---|
| 681 | (WPARAM)-1, (LPARAM)Template ); | 
|---|
| 682 | } | 
|---|
| 683 |  | 
|---|
| 684 | strcpy( Template, pstr ); | 
|---|
| 685 | strcat( Template, __appendix_str ); | 
|---|
| 686 | SetWindowTextA( hWndCtl, Template ); | 
|---|
| 687 | SetWindowLongA( hWnd, DWL_MSGRESULT, 1 ); | 
|---|
| 688 | return TRUE; | 
|---|
| 689 | } | 
|---|
| 690 | } | 
|---|
| 691 | } | 
|---|
| 692 | break; | 
|---|
| 693 | #endif | 
|---|
| 694 |  | 
|---|
| 695 |  | 
|---|
| 696 | case WM_COMMAND: | 
|---|
| 697 | if (wParam == IDOK) | 
|---|
| 698 | { | 
|---|
| 699 | EndDialog(hWnd, TRUE); | 
|---|
| 700 | return TRUE; | 
|---|
| 701 | } | 
|---|
| 702 | break; | 
|---|
| 703 |  | 
|---|
| 704 | case WM_CLOSE: | 
|---|
| 705 | EndDialog(hWnd, TRUE); | 
|---|
| 706 | break; | 
|---|
| 707 | } | 
|---|
| 708 | return 0; | 
|---|
| 709 | } | 
|---|
| 710 |  | 
|---|
| 711 |  | 
|---|
| 712 | /************************************************************************* | 
|---|
| 713 | * ShellAboutA                              [SHELL32.243] | 
|---|
| 714 | */ | 
|---|
| 715 |  | 
|---|
| 716 | ODINFUNCTION4(INT,ShellAboutA, HWND,   hWnd, | 
|---|
| 717 | LPCSTR, szApp, | 
|---|
| 718 | LPCSTR, szOtherStuff, | 
|---|
| 719 | HICON,  hIcon ) | 
|---|
| 720 | {   ABOUT_INFO info; | 
|---|
| 721 | HRSRC hRes; | 
|---|
| 722 | LPVOID dlgTemplate; | 
|---|
| 723 |  | 
|---|
| 724 | if(!(hRes = FindResourceA(shell32_hInstance, "SHELL_ABOUT_MSGBOX", RT_DIALOGA))) | 
|---|
| 725 | return FALSE; | 
|---|
| 726 | if(!(dlgTemplate = (LPVOID)LoadResource(shell32_hInstance, hRes))) | 
|---|
| 727 | return FALSE; | 
|---|
| 728 |  | 
|---|
| 729 | info.szApp        = szApp; | 
|---|
| 730 | info.szOtherStuff = szOtherStuff; | 
|---|
| 731 | info.hIcon        = hIcon; | 
|---|
| 732 | if (!hIcon) info.hIcon = LoadIconA( 0, (LPCSTR)OIC_ODINICON ); | 
|---|
| 733 | return DialogBoxIndirectParamA( GetWindowLongA( hWnd, GWL_HINSTANCE ), | 
|---|
| 734 | (DLGTEMPLATE*)dlgTemplate , hWnd, AboutDlgProc, (LPARAM)&info ); | 
|---|
| 735 | } | 
|---|
| 736 |  | 
|---|
| 737 |  | 
|---|
| 738 | /************************************************************************* | 
|---|
| 739 | * ShellAboutW                              [SHELL32.244] | 
|---|
| 740 | */ | 
|---|
| 741 | ODINFUNCTION4(INT,ShellAboutW, HWND,    hWnd, | 
|---|
| 742 | LPCWSTR, szApp, | 
|---|
| 743 | LPCWSTR, szOtherStuff, | 
|---|
| 744 | HICON,   hIcon ) | 
|---|
| 745 | {   INT ret; | 
|---|
| 746 | ABOUT_INFO info; | 
|---|
| 747 | HRSRC hRes; | 
|---|
| 748 | LPVOID dlgTemplate; | 
|---|
| 749 |  | 
|---|
| 750 | if(!(hRes = FindResourceA(shell32_hInstance, "SHELL_ABOUT_MSGBOX", RT_DIALOGA))) | 
|---|
| 751 | return FALSE; | 
|---|
| 752 | if(!(dlgTemplate = (LPVOID)LoadResource(shell32_hInstance, hRes))) | 
|---|
| 753 | return FALSE; | 
|---|
| 754 |  | 
|---|
| 755 | info.szApp        = HEAP_strdupWtoA( GetProcessHeap(), 0, szApp ); | 
|---|
| 756 | info.szOtherStuff = HEAP_strdupWtoA( GetProcessHeap(), 0, szOtherStuff ); | 
|---|
| 757 | info.hIcon        = hIcon; | 
|---|
| 758 | if (!hIcon) info.hIcon = LoadIconA( 0, (LPCSTR)OIC_ODINICON ); | 
|---|
| 759 | ret = DialogBoxIndirectParamA( GetWindowLongA( hWnd, GWL_HINSTANCE ), | 
|---|
| 760 | (DLGTEMPLATE*)dlgTemplate, hWnd, AboutDlgProc, (LPARAM)&info ); | 
|---|
| 761 | HeapFree( GetProcessHeap(), 0, (LPSTR)info.szApp ); | 
|---|
| 762 | HeapFree( GetProcessHeap(), 0, (LPSTR)info.szOtherStuff ); | 
|---|
| 763 | return ret; | 
|---|
| 764 | } | 
|---|
| 765 |  | 
|---|
| 766 | /************************************************************************* | 
|---|
| 767 | * Shell_NotifyIcon                            [SHELL32.297] | 
|---|
| 768 | * FIXME | 
|---|
| 769 | * This function is supposed to deal with the systray. | 
|---|
| 770 | * Any ideas on how this is to be implimented? | 
|---|
| 771 | */ | 
|---|
| 772 |  | 
|---|
| 773 | ODINFUNCTION2(BOOL, Shell_NotifyIconA, DWORD,            dwMessage, | 
|---|
| 774 | PNOTIFYICONDATAA, pnid ) | 
|---|
| 775 | { | 
|---|
| 776 | dprintf(("SHELL32:Shell32_Main:Shell_NotifyIconA not implemented\n")); | 
|---|
| 777 | return FALSE; | 
|---|
| 778 | } | 
|---|
| 779 |  | 
|---|
| 780 | /************************************************************************* | 
|---|
| 781 | * Shell_NotifyIcon                            [SHELL32.?] | 
|---|
| 782 | * FIXME | 
|---|
| 783 | * This function is supposed to deal with the systray. | 
|---|
| 784 | * Any ideas on how this is to be implimented? | 
|---|
| 785 | */ | 
|---|
| 786 |  | 
|---|
| 787 | ODINFUNCTION2(BOOL, Shell_NotifyIconW, DWORD,            dwMessage, | 
|---|
| 788 | PNOTIFYICONDATAW, pnid ) | 
|---|
| 789 | { | 
|---|
| 790 | dprintf(("SHELL32:Shell32_Main:Shell_NotifyIconA not implemented\n")); | 
|---|
| 791 | return FALSE; | 
|---|
| 792 | } | 
|---|
| 793 |  | 
|---|
| 794 |  | 
|---|
| 795 | /************************************************************************* | 
|---|
| 796 | * Shell_NotifyIcon                            [SHELL32.296] | 
|---|
| 797 | * FIXME | 
|---|
| 798 | * This function is supposed to deal with the systray. | 
|---|
| 799 | * Any ideas on how this is to be implimented? | 
|---|
| 800 | */ | 
|---|
| 801 |  | 
|---|
| 802 | BOOL WINAPI Shell_NotifyIcon(DWORD dwMessage, PNOTIFYICONDATAA pnid ) | 
|---|
| 803 | { | 
|---|
| 804 | if (VERSION_OsIsUnicode()) | 
|---|
| 805 | return(Shell_NotifyIconW(dwMessage,(PNOTIFYICONDATAW)pnid)); | 
|---|
| 806 | else | 
|---|
| 807 | return(Shell_NotifyIconA(dwMessage,pnid)); | 
|---|
| 808 | } | 
|---|
| 809 |  | 
|---|
| 810 | /************************************************************************* | 
|---|
| 811 | * FreeIconList | 
|---|
| 812 | */ | 
|---|
| 813 |  | 
|---|
| 814 | ODINPROCEDURE1(FreeIconList,DWORD,dw) | 
|---|
| 815 | { | 
|---|
| 816 | dprintf(("SHELL32:Shell32_Main:FreeIconList not implemented.\n")); | 
|---|
| 817 | } | 
|---|
| 818 |  | 
|---|
| 819 | /*********************************************************************** | 
|---|
| 820 | * DllGetVersion [COMCTL32.25] | 
|---|
| 821 | * | 
|---|
| 822 | * Retrieves version information of the 'SHELL32.DLL' | 
|---|
| 823 | * | 
|---|
| 824 | * PARAMS | 
|---|
| 825 | *     pdvi [O] pointer to version information structure. | 
|---|
| 826 | * | 
|---|
| 827 | * RETURNS | 
|---|
| 828 | *     Success: S_OK | 
|---|
| 829 | *     Failure: E_INVALIDARG | 
|---|
| 830 | * | 
|---|
| 831 | * NOTES | 
|---|
| 832 | *     Returns version of a shell32.dll from IE4.01 SP1. | 
|---|
| 833 | */ | 
|---|
| 834 |  | 
|---|
| 835 | ODINFUNCTION1(HRESULT, SHELL32_DllGetVersion, DLLVERSIONINFO*, pdvi) | 
|---|
| 836 | { | 
|---|
| 837 | if (pdvi->cbSize != sizeof(DLLVERSIONINFO)) | 
|---|
| 838 | { dprintf(("wrong DLLVERSIONINFO size from app\n")); | 
|---|
| 839 | return E_INVALIDARG; | 
|---|
| 840 | } | 
|---|
| 841 |  | 
|---|
| 842 | pdvi->dwMajorVersion = 4; | 
|---|
| 843 | pdvi->dwMinorVersion = 72; | 
|---|
| 844 | pdvi->dwBuildNumber = 3110; | 
|---|
| 845 | pdvi->dwPlatformID = 1; | 
|---|
| 846 |  | 
|---|
| 847 | dprintf(("%lu.%lu.%lu.%lu\n", | 
|---|
| 848 | pdvi->dwMajorVersion, pdvi->dwMinorVersion, | 
|---|
| 849 | pdvi->dwBuildNumber, pdvi->dwPlatformID)); | 
|---|
| 850 |  | 
|---|
| 851 | return S_OK; | 
|---|
| 852 | } | 
|---|
| 853 | /************************************************************************* | 
|---|
| 854 | * global variables of the shell32.dll | 
|---|
| 855 | * all are once per process | 
|---|
| 856 | * | 
|---|
| 857 | */ | 
|---|
| 858 | void  (WINAPI* pDLLInitComctl)(LPVOID); | 
|---|
| 859 | INT   (WINAPI* pImageList_AddIcon) (HIMAGELIST himl, HICON hIcon); | 
|---|
| 860 | INT   (WINAPI* pImageList_ReplaceIcon) (HIMAGELIST, INT, HICON); | 
|---|
| 861 | HIMAGELIST (WINAPI * pImageList_Create) (INT,INT,UINT,INT,INT); | 
|---|
| 862 | BOOL  (WINAPI* pImageList_Draw) (HIMAGELIST himl, int i, HDC hdcDest, int x, int y, UINT fStyle); | 
|---|
| 863 | HICON (WINAPI * pImageList_GetIcon) (HIMAGELIST, INT, UINT); | 
|---|
| 864 | INT   (WINAPI* pImageList_GetImageCount)(HIMAGELIST); | 
|---|
| 865 | COLORREF (WINAPI *pImageList_SetBkColor)(HIMAGELIST, COLORREF); | 
|---|
| 866 |  | 
|---|
| 867 | LPVOID   (WINAPI* pCOMCTL32_Alloc) (INT); | 
|---|
| 868 | BOOL  (WINAPI* pCOMCTL32_Free) (LPVOID); | 
|---|
| 869 |  | 
|---|
| 870 | HDPA  (WINAPI* pDPA_Create) (INT); | 
|---|
| 871 | INT   (WINAPI* pDPA_InsertPtr) (const HDPA, INT, LPVOID); | 
|---|
| 872 | BOOL  (WINAPI* pDPA_Sort) (const HDPA, PFNDPACOMPARE, LPARAM); | 
|---|
| 873 | LPVOID   (WINAPI* pDPA_GetPtr) (const HDPA, INT); | 
|---|
| 874 | BOOL  (WINAPI* pDPA_Destroy) (const HDPA); | 
|---|
| 875 | INT   (WINAPI *pDPA_Search) (const HDPA, LPVOID, INT, PFNDPACOMPARE, LPARAM, UINT); | 
|---|
| 876 | LPVOID   (WINAPI *pDPA_DeletePtr) (const HDPA hdpa, INT i); | 
|---|
| 877 |  | 
|---|
| 878 | /* user32 */ | 
|---|
| 879 | HICON (WINAPI *pLookupIconIdFromDirectoryEx)(LPBYTE dir, BOOL bIcon, INT width, INT height, UINT cFlag); | 
|---|
| 880 | HICON (WINAPI *pCreateIconFromResourceEx)(LPBYTE bits,UINT cbSize, BOOL bIcon, DWORD dwVersion, INT width, INT height,UINT cFlag); | 
|---|
| 881 |  | 
|---|
| 882 | /* ole2 */ | 
|---|
| 883 | HRESULT (WINAPI* pOleInitialize)(LPVOID reserved); | 
|---|
| 884 | void (WINAPI* pOleUninitialize)(void); | 
|---|
| 885 | HRESULT (WINAPI* pDoDragDrop)(IDataObject* pDataObject, IDropSource * pDropSource, DWORD dwOKEffect, DWORD *pdwEffect); | 
|---|
| 886 | HRESULT (WINAPI* pRegisterDragDrop)(HWND hwnd, IDropTarget* pDropTarget); | 
|---|
| 887 | HRESULT (WINAPI* pRevokeDragDrop)(HWND hwnd); | 
|---|
| 888 |  | 
|---|
| 889 | static HINSTANCE  hComctl32; | 
|---|
| 890 | static HINSTANCE  hOle32; | 
|---|
| 891 | static INT     shell32_RefCount = 0; | 
|---|
| 892 |  | 
|---|
| 893 | INT      shell32_ObjCount = 0; | 
|---|
| 894 | HINSTANCE   shell32_hInstance = 0; | 
|---|
| 895 | HIMAGELIST  ShellSmallIconList = 0; | 
|---|
| 896 | HIMAGELIST  ShellBigIconList = 0; | 
|---|
| 897 |  | 
|---|
| 898 | /************************************************************************* | 
|---|
| 899 | * SHELL32 LibMain | 
|---|
| 900 | * | 
|---|
| 901 | * NOTES | 
|---|
| 902 | *  calling oleinitialize here breaks sone apps. | 
|---|
| 903 | */ | 
|---|
| 904 |  | 
|---|
| 905 | static void Shell32ProcLoadHelper(LPVOID* pAddr, | 
|---|
| 906 | HANDLE hModule, | 
|---|
| 907 | LPCSTR lpstrName) | 
|---|
| 908 | { | 
|---|
| 909 | *pAddr = (void*)GetProcAddress(hModule,lpstrName); | 
|---|
| 910 |  | 
|---|
| 911 | if (!pAddr) | 
|---|
| 912 | dprintf(("Shell32: Shell32ProcLoadHelper(%08xh,%08xh,%s) failed!\n", | 
|---|
| 913 | pAddr, | 
|---|
| 914 | hModule, | 
|---|
| 915 | lpstrName)); | 
|---|
| 916 | } | 
|---|
| 917 |  | 
|---|
| 918 |  | 
|---|
| 919 | ODINFUNCTION3(BOOL, Shell32LibMain, HINSTANCE, hinstDLL, | 
|---|
| 920 | DWORD,     fdwReason, | 
|---|
| 921 | LPVOID,    fImpLoad) | 
|---|
| 922 | { | 
|---|
| 923 | HMODULE  hUser32; | 
|---|
| 924 |  | 
|---|
| 925 | switch (fdwReason) | 
|---|
| 926 | { | 
|---|
| 927 | case DLL_PROCESS_ATTACH: | 
|---|
| 928 | shell32_RefCount++; | 
|---|
| 929 | if (shell32_hInstance) | 
|---|
| 930 | { | 
|---|
| 931 | dprintf(("shell32.dll instantiated twice in one address space!\n")); | 
|---|
| 932 | } | 
|---|
| 933 | else | 
|---|
| 934 | { | 
|---|
| 935 | /* we only want to call this the first time shell32 is instantiated */ | 
|---|
| 936 | SHInitRestricted(NULL, NULL); | 
|---|
| 937 | } | 
|---|
| 938 |  | 
|---|
| 939 | shell32_hInstance = hinstDLL; | 
|---|
| 940 |  | 
|---|
| 941 | hComctl32 = LoadLibraryA("COMCTL32.DLL"); | 
|---|
| 942 | hOle32 = LoadLibraryA("OLE32.DLL"); | 
|---|
| 943 | hUser32 = GetModuleHandleA("USER32"); | 
|---|
| 944 |  | 
|---|
| 945 | if (!hComctl32 || !hUser32 || !hOle32) | 
|---|
| 946 | { | 
|---|
| 947 | dprintf(("P A N I C SHELL32 loading failed\n")); | 
|---|
| 948 | return FALSE; | 
|---|
| 949 | } | 
|---|
| 950 |  | 
|---|
| 951 | /* comctl32 */ | 
|---|
| 952 | Shell32ProcLoadHelper((LPVOID*)&pDLLInitComctl,hComctl32,"InitCommonControlsEx"); | 
|---|
| 953 | Shell32ProcLoadHelper((LPVOID*)&pImageList_Create,hComctl32,"ImageList_Create"); | 
|---|
| 954 | Shell32ProcLoadHelper((LPVOID*)&pImageList_AddIcon,hComctl32,"ImageList_AddIcon"); | 
|---|
| 955 | Shell32ProcLoadHelper((LPVOID*)&pImageList_ReplaceIcon,hComctl32,"ImageList_ReplaceIcon"); | 
|---|
| 956 | Shell32ProcLoadHelper((LPVOID*)&pImageList_GetIcon,hComctl32,"ImageList_GetIcon"); | 
|---|
| 957 | Shell32ProcLoadHelper((LPVOID*)&pImageList_GetImageCount,hComctl32,"ImageList_GetImageCount"); | 
|---|
| 958 | Shell32ProcLoadHelper((LPVOID*)&pImageList_Draw,hComctl32,"ImageList_Draw"); | 
|---|
| 959 | Shell32ProcLoadHelper((LPVOID*)&pImageList_SetBkColor,hComctl32,"ImageList_SetBkColor"); | 
|---|
| 960 | Shell32ProcLoadHelper((LPVOID*)&pCOMCTL32_Alloc,hComctl32, (LPCSTR)71L); | 
|---|
| 961 | Shell32ProcLoadHelper((LPVOID*)&pCOMCTL32_Free,hComctl32, (LPCSTR)73L); | 
|---|
| 962 | Shell32ProcLoadHelper((LPVOID*)&pDPA_Create,hComctl32, (LPCSTR)328L); | 
|---|
| 963 | Shell32ProcLoadHelper((LPVOID*)&pDPA_Destroy,hComctl32, (LPCSTR)329L); | 
|---|
| 964 | Shell32ProcLoadHelper((LPVOID*)&pDPA_GetPtr,hComctl32, (LPCSTR)332L); | 
|---|
| 965 | Shell32ProcLoadHelper((LPVOID*)&pDPA_InsertPtr,hComctl32, (LPCSTR)334L); | 
|---|
| 966 | Shell32ProcLoadHelper((LPVOID*)&pDPA_DeletePtr,hComctl32, (LPCSTR)336L); | 
|---|
| 967 | Shell32ProcLoadHelper((LPVOID*)&pDPA_Sort,hComctl32, (LPCSTR)338L); | 
|---|
| 968 | Shell32ProcLoadHelper((LPVOID*)&pDPA_Search,hComctl32, (LPCSTR)339L); | 
|---|
| 969 | /* user32 */ | 
|---|
| 970 | Shell32ProcLoadHelper((LPVOID*)&pLookupIconIdFromDirectoryEx,hUser32,"LookupIconIdFromDirectoryEx"); | 
|---|
| 971 | Shell32ProcLoadHelper((LPVOID*)&pCreateIconFromResourceEx,hUser32,"CreateIconFromResourceEx"); | 
|---|
| 972 | /* ole2 */ | 
|---|
| 973 | Shell32ProcLoadHelper((LPVOID*)&pOleInitialize,hOle32,"OleInitialize"); | 
|---|
| 974 | Shell32ProcLoadHelper((LPVOID*)&pOleUninitialize,hOle32,"OleUninitialize"); | 
|---|
| 975 | Shell32ProcLoadHelper((LPVOID*)&pDoDragDrop,hOle32,"DoDragDrop"); | 
|---|
| 976 | Shell32ProcLoadHelper((LPVOID*)&pRegisterDragDrop,hOle32,"RegisterDragDrop"); | 
|---|
| 977 | Shell32ProcLoadHelper((LPVOID*)&pRevokeDragDrop,hOle32,"RevokeDragDrop"); | 
|---|
| 978 |  | 
|---|
| 979 | /* initialize the common controls */ | 
|---|
| 980 | if (pDLLInitComctl) | 
|---|
| 981 | { | 
|---|
| 982 | pDLLInitComctl(NULL); | 
|---|
| 983 | } | 
|---|
| 984 |  | 
|---|
| 985 | SIC_Initialize(); | 
|---|
| 986 |  | 
|---|
| 987 | break; | 
|---|
| 988 |  | 
|---|
| 989 | case DLL_THREAD_ATTACH: | 
|---|
| 990 | shell32_RefCount++; | 
|---|
| 991 | break; | 
|---|
| 992 |  | 
|---|
| 993 | case DLL_THREAD_DETACH: | 
|---|
| 994 | shell32_RefCount--; | 
|---|
| 995 | break; | 
|---|
| 996 |  | 
|---|
| 997 | case DLL_PROCESS_DETACH: | 
|---|
| 998 | shell32_RefCount--; | 
|---|
| 999 |  | 
|---|
| 1000 | if ( !shell32_RefCount ) | 
|---|
| 1001 | { | 
|---|
| 1002 | shell32_hInstance = 0; | 
|---|
| 1003 |  | 
|---|
| 1004 | if (pdesktopfolder) | 
|---|
| 1005 | { | 
|---|
| 1006 | IShellFolder_Release(pdesktopfolder); | 
|---|
| 1007 | pdesktopfolder = NULL; | 
|---|
| 1008 | } | 
|---|
| 1009 |  | 
|---|
| 1010 | SIC_Destroy(); | 
|---|
| 1011 |  | 
|---|
| 1012 | /* this one is here to check if AddRef/Release is balanced */ | 
|---|
| 1013 | if (shell32_ObjCount) | 
|---|
| 1014 | { | 
|---|
| 1015 | dprintf(("leaving with %u objects left (memory leak)\n", shell32_ObjCount)); | 
|---|
| 1016 | } | 
|---|
| 1017 | } | 
|---|
| 1018 |  | 
|---|
| 1019 | FreeLibrary(hOle32); | 
|---|
| 1020 | FreeLibrary(hComctl32); | 
|---|
| 1021 |  | 
|---|
| 1022 | dprintf(("refcount=%u objcount=%u \n", shell32_RefCount, shell32_ObjCount)); | 
|---|
| 1023 | break; | 
|---|
| 1024 | } | 
|---|
| 1025 | return TRUE; | 
|---|
| 1026 | } | 
|---|