~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Wine Cross Reference
wine/dlls/comdlg32/cdlg32.c

Version: ~ [ wine-1.1.0 ] ~ [ wine-1.0 ] ~ [ wine-1.0-rc5 ] ~ [ wine-1.0-rc4 ] ~ [ wine-1.0-rc3 ] ~ [ wine-1.0-rc2 ] ~ [ wine-1.0-rc1 ] ~ [ wine-0.9.61 ] ~ [ wine-0.9.60 ] ~ [ wine-0.9.59 ] ~ [ wine-0.9.58 ] ~ [ wine-0.9.57 ] ~ [ wine-0.9.56 ] ~ [ wine-0.9.55 ] ~ [ wine-0.9.54 ] ~ [ wine-0.9.53 ] ~ [ wine-0.9.52 ] ~ [ wine-0.9.51 ] ~ [ wine-0.9.50 ] ~ [ wine-0.9.49 ] ~ [ wine-0.9.48 ] ~ [ wine-0.9.47 ] ~ [ wine-0.9.46 ] ~ [ wine-0.9.45 ] ~ [ wine-0.9.44 ] ~ [ wine-0.9.43 ] ~ [ wine-0.9.42 ] ~ [ wine-0.9.41 ] ~ [ wine-0.9.40 ] ~ [ wine-0.9.39 ] ~ [ wine-0.9.38 ] ~ [ wine-0.9.37 ] ~ [ wine-0.9.36 ] ~ [ wine-0.9.35 ] ~ [ wine-0.9.34 ] ~ [ wine-0.9.33 ] ~ [ wine-0.9.32 ] ~ [ wine-0.9.31 ] ~ [ wine-0.9.30 ] ~ [ wine-0.9.29 ] ~ [ wine-0.9.28 ] ~ [ wine-0.9.27 ] ~ [ wine-0.9.26 ] ~ [ wine-0.9.25 ] ~ [ wine-0.9.24 ] ~ [ wine-0.9.23 ] ~ [ wine-0.9.22 ] ~ [ wine-0.9.21 ] ~ [ wine-0.9.20 ] ~ [ wine-0.9.19 ] ~ [ wine-0.9.18 ] ~ [ wine-0.9.17 ] ~ [ wine-0.9.16 ] ~ [ wine-0.9.15 ] ~ [ wine-0.9.14 ] ~ [ wine-0.9.13 ] ~ [ wine-0.9.12 ] ~ [ wine-0.9.11 ] ~ [ wine-0.9.10 ] ~ [ wine-0.9.9 ] ~ [ wine-0.9.8 ] ~ [ wine-0.9.7 ] ~ [ wine-0.9.6 ] ~ [ wine-0.9.5 ] ~ [ wine-0.9.4 ] ~ [ wine-0.9.3 ] ~ [ wine-0.9.2 ] ~ [ wine-0.9.1 ] ~ [ wine-0.9 ] ~ [ wine20050930 ] ~ [ wine20050830 ] ~ [ wine20050725 ] ~ [ wine20050628 ] ~ [ wine20050524 ] ~ [ wine20050419 ] ~ [ wine20050310 ] ~ [ wine20050211 ] ~ [ wine20050111 ] ~ [ wine20041201 ] ~ [ wine20041019 ] ~ [ wine20040914 ] ~ [ wine20040813 ] ~ [ wine20040716 ] ~ [ wine20040615 ] ~ [ wine20040505 ] ~ [ wine20040408 ] ~ [ wine20040309 ] ~ [ wine20040213 ] ~ [ wine20040121 ] ~ [ wine20031212 ] ~ [ wine20031118 ] ~ [ wine20031016 ] ~ [ wine20030911 ] ~ [ wine20030813 ] ~ [ wine20030709 ] ~ [ wine20030618 ] ~ [ wine20030508 ] ~ [ wine20030408 ] ~ [ wine20030318 ] ~ [ wine20030219 ] ~ [ wine20030115 ] ~ [ wine20021219 ] ~ [ wine20021125 ] ~ [ wine20021031 ] ~ [ wine20021007 ] ~ [ wine20020904 ] ~ [ wine20020804 ] ~ [ wine20020710 ] ~ [ wine20020605 ] ~ [ wine20020509 ] ~ [ wine20020411 ] ~ [ wine20020310 ] ~ [ wine20020228 ] ~ [ wine20011226 ] ~ [ wine20011108 ] ~ [ wine20011004 ] ~ [ wine20010824 ] ~ [ wine20010731 ] ~ [ wine20010629 ] ~ [ wine20010510 ] ~ [ wine20010418 ] ~ [ wine20010326 ] ~ [ wine20010305 ] ~ [ wine20010216 ] ~ [ wine20010112 ] ~ [ wine20001222 ] ~ [ wine20001202 ] ~ [ wine20001026 ] ~ [ wine20001002 ] ~ [ wine20000909 ] ~ [ wine20000821 ] ~ [ wine20000801 ] ~ [ wine20000716 ] ~ [ wine20000326 ] ~ [ wine20000227 ] ~ [ wine20000130 ] ~ [ wine20000109 ] ~

  1 /*
  2  *  Common Dialog Boxes interface (32 bit)
  3  *  Find/Replace
  4  *
  5  * Copyright 1999 Bertho A. Stultiens
  6  *
  7  * This library is free software; you can redistribute it and/or
  8  * modify it under the terms of the GNU Lesser General Public
  9  * License as published by the Free Software Foundation; either
 10  * version 2.1 of the License, or (at your option) any later version.
 11  *
 12  * This library is distributed in the hope that it will be useful,
 13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 15  * Lesser General Public License for more details.
 16  *
 17  * You should have received a copy of the GNU Lesser General Public
 18  * License along with this library; if not, write to the Free Software
 19  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
 20  */
 21 
 22 #include <stdarg.h>
 23 
 24 #include "windef.h"
 25 #include "winbase.h"
 26 #include "wingdi.h"
 27 #include "winuser.h"
 28 #include "commdlg.h"
 29 #include "cderr.h"
 30 #include "wine/debug.h"
 31 
 32 WINE_DEFAULT_DEBUG_CHANNEL(commdlg);
 33 
 34 #include "cdlg.h"
 35 
 36 
 37 HINSTANCE       COMDLG32_hInstance = 0;
 38 
 39 static DWORD COMDLG32_TlsIndex = TLS_OUT_OF_INDEXES;
 40 
 41 static HINSTANCE        SHELL32_hInstance;
 42 static HINSTANCE        SHFOLDER_hInstance;
 43 
 44 /* ITEMIDLIST */
 45 LPITEMIDLIST (WINAPI *COMDLG32_PIDL_ILClone) (LPCITEMIDLIST);
 46 LPITEMIDLIST (WINAPI *COMDLG32_PIDL_ILCombine)(LPCITEMIDLIST,LPCITEMIDLIST);
 47 LPITEMIDLIST (WINAPI *COMDLG32_PIDL_ILGetNext)(LPITEMIDLIST);
 48 BOOL (WINAPI *COMDLG32_PIDL_ILRemoveLastID)(LPCITEMIDLIST);
 49 BOOL (WINAPI *COMDLG32_PIDL_ILIsEqual)(LPCITEMIDLIST, LPCITEMIDLIST);
 50 UINT (WINAPI *COMDLG32_PIDL_ILGetSize)(LPCITEMIDLIST);
 51 
 52 /* SHELL */
 53 LPVOID (WINAPI *COMDLG32_SHAlloc)(DWORD);
 54 DWORD (WINAPI *COMDLG32_SHFree)(LPVOID);
 55 BOOL (WINAPI *COMDLG32_SHGetFolderPathA)(HWND,int,HANDLE,DWORD,LPSTR);
 56 BOOL (WINAPI *COMDLG32_SHGetFolderPathW)(HWND,int,HANDLE,DWORD,LPWSTR);
 57 
 58 /***********************************************************************
 59  *      DllMain  (COMDLG32.init)
 60  *
 61  *    Initialization code for the COMDLG32 DLL
 62  *
 63  * RETURNS:
 64  *      FALSE if sibling could not be loaded or instantiated twice, TRUE
 65  *      otherwise.
 66  */
 67 static const char GPA_string[] = "Failed to get entry point %s for hinst = %p\n";
 68 #define GPA(dest, hinst, name) \
 69         if(!(dest = (void*)GetProcAddress(hinst,name)))\
 70         { \
 71           ERR(GPA_string, debugstr_a(name), hinst); \
 72           return FALSE; \
 73         }
 74 
 75 BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD Reason, LPVOID Reserved)
 76 {
 77         TRACE("(%p, %d, %p)\n", hInstance, Reason, Reserved);
 78 
 79         switch(Reason)
 80         {
 81         case DLL_PROCESS_ATTACH:
 82                 COMDLG32_hInstance = hInstance;
 83                 DisableThreadLibraryCalls(hInstance);
 84 
 85                 SHELL32_hInstance = GetModuleHandleA("SHELL32.DLL");
 86 
 87                 if (!SHELL32_hInstance)
 88                 {
 89                         ERR("loading of shell32 failed\n");
 90                         return FALSE;
 91                 }
 92 
 93                 /* ITEMIDLIST */
 94                 GPA(COMDLG32_PIDL_ILIsEqual, SHELL32_hInstance, (LPCSTR)21L);
 95                 GPA(COMDLG32_PIDL_ILCombine, SHELL32_hInstance, (LPCSTR)25L);
 96                 GPA(COMDLG32_PIDL_ILGetNext, SHELL32_hInstance, (LPCSTR)153L);
 97                 GPA(COMDLG32_PIDL_ILClone, SHELL32_hInstance, (LPCSTR)18L);
 98                 GPA(COMDLG32_PIDL_ILRemoveLastID, SHELL32_hInstance, (LPCSTR)17L);
 99                 GPA(COMDLG32_PIDL_ILGetSize, SHELL32_hInstance, (LPCSTR)152L);
100 
101                 /* SHELL */
102 
103                 GPA(COMDLG32_SHAlloc, SHELL32_hInstance, (LPCSTR)196L);
104                 GPA(COMDLG32_SHFree, SHELL32_hInstance, (LPCSTR)195L);
105                 /* for the first versions of shell32 SHGetFolderPathA is in SHFOLDER.DLL */
106                 COMDLG32_SHGetFolderPathA = (void*)GetProcAddress(SHELL32_hInstance,"SHGetFolderPathA");
107                 if (!COMDLG32_SHGetFolderPathA)
108                 {
109                   SHFOLDER_hInstance = LoadLibraryA("SHFOLDER.DLL");
110                   GPA(COMDLG32_SHGetFolderPathA, SHFOLDER_hInstance,"SHGetFolderPathA");
111                 }
112 
113                 /* for the first versions of shell32 SHGetFolderPathW is in SHFOLDER.DLL */
114                 COMDLG32_SHGetFolderPathW = (void*)GetProcAddress(SHELL32_hInstance,"SHGetFolderPathW");
115                 if (!COMDLG32_SHGetFolderPathW)
116                 {
117                   SHFOLDER_hInstance = LoadLibraryA("SHFOLDER.DLL");
118                   GPA(COMDLG32_SHGetFolderPathW, SHFOLDER_hInstance,"SHGetFolderPathW");
119                 }
120 
121                 break;
122 
123         case DLL_PROCESS_DETACH:
124             if (COMDLG32_TlsIndex != TLS_OUT_OF_INDEXES) TlsFree(COMDLG32_TlsIndex);
125             if(SHFOLDER_hInstance) FreeLibrary(SHFOLDER_hInstance);
126             break;
127         }
128         return TRUE;
129 }
130 #undef GPA
131 
132 /***********************************************************************
133  *      COMDLG32_AllocMem                       (internal)
134  * Get memory for internal datastructure plus stringspace etc.
135  *      RETURNS
136  *              Success: Pointer to a heap block
137  *              Failure: null
138  */
139 LPVOID COMDLG32_AllocMem(
140         int size        /* [in] Block size to allocate */
141 ) {
142         LPVOID ptr = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size);
143         if(!ptr)
144         {
145                 COMDLG32_SetCommDlgExtendedError(CDERR_MEMALLOCFAILURE);
146                 return NULL;
147         }
148         return ptr;
149 }
150 
151 
152 /***********************************************************************
153  *      COMDLG32_SetCommDlgExtendedError        (internal)
154  *
155  * Used to set the thread's local error value if a comdlg32 function fails.
156  */
157 void COMDLG32_SetCommDlgExtendedError(DWORD err)
158 {
159         TRACE("(%08x)\n", err);
160         if (COMDLG32_TlsIndex == TLS_OUT_OF_INDEXES)
161           COMDLG32_TlsIndex = TlsAlloc();
162         if (COMDLG32_TlsIndex != TLS_OUT_OF_INDEXES)
163           TlsSetValue(COMDLG32_TlsIndex, (LPVOID)(DWORD_PTR)err);
164         else
165           FIXME("No Tls Space\n");
166 }
167 
168 
169 /***********************************************************************
170  *      CommDlgExtendedError                    (COMDLG32.@)
171  *      CommDlgExtendedError                    (COMMDLG.26)
172  *
173  * Get the thread's local error value if a comdlg32 function fails.
174  *      RETURNS
175  *              Current error value which might not be valid
176  *              if a previous call succeeded.
177  */
178 DWORD WINAPI CommDlgExtendedError(void)
179 {
180         if (COMDLG32_TlsIndex != TLS_OUT_OF_INDEXES)
181           return (DWORD_PTR)TlsGetValue(COMDLG32_TlsIndex);
182         else
183           return 0; /* we never set an error, so there isn't one */
184 }
185 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.