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