SETUPAPI: implement DIRID_PROGRAM_FILES and others
Mike McCormack
mike at codeweavers.com
Thu May 27 11:12:34 CDT 2004
ChangeLog:
* implement DIRID_PROGRAM_FILES and others
-------------- next part --------------
Index: dlls/setupapi/dirid.c
===================================================================
RCS file: /home/wine/wine/dlls/setupapi/dirid.c,v
retrieving revision 1.7
diff -u -r1.7 dirid.c
--- dlls/setupapi/dirid.c 5 May 2004 22:01:10 -0000 1.7
+++ dlls/setupapi/dirid.c 27 May 2004 15:03:32 -0000
@@ -33,6 +33,8 @@
#include "setupapi_private.h"
#include "wine/debug.h"
+#include "shlobj.h"
+
WINE_DEFAULT_DEBUG_CHANNEL(setupapi);
#define MAX_SYSTEM_DIRID DIRID_PRINTPROCESSOR
@@ -48,6 +50,8 @@
static struct user_dirid *user_dirids;
static const WCHAR *system_dirids[MAX_SYSTEM_DIRID+1];
+static BOOL store_user_dirid( HINF hinf, int id, WCHAR *str );
+
/* retrieve the string for unknown dirids */
static const WCHAR *get_unknown_dirid(void)
{
@@ -146,6 +150,79 @@
return str;
}
+WCHAR *DIRID_get_csidl_dir( int dirid )
+{
+ DWORD csidl;
+ WCHAR buffer[MAX_PATH+32], *str;
+ int len;
+ typeof (SHGetSpecialFolderPathW) *pSHGetSpecialFolderPathW;
+ HMODULE hShell32;
+ static const WCHAR szShell32[] = { 'S','H','E','L','L','3','2',0 };
+ BOOL r;
+
+ hShell32 = LoadLibraryW( szShell32 );
+ if( !hShell32 )
+ return NULL;
+
+ pSHGetSpecialFolderPathW =
+ GetProcAddress( hShell32, "SHGetSpecialFolderPathW" );
+ if( !pSHGetSpecialFolderPathW )
+ return NULL;
+
+ switch( dirid )
+ {
+ case DIRID_PROGRAM_FILES:
+ csidl = CSIDL_PROGRAM_FILES;
+ break;
+ case DIRID_COMMON_STARTMENU:
+ csidl = CSIDL_COMMON_STARTMENU;
+ break;
+ case DIRID_COMMON_PROGRAMS:
+ csidl = CSIDL_COMMON_PROGRAMS;
+ break;
+ case DIRID_COMMON_STARTUP:
+ csidl = CSIDL_COMMON_STARTUP;
+ break;
+ case DIRID_COMMON_DESKTOPDIRECTORY:
+ csidl = CSIDL_COMMON_DESKTOPDIRECTORY;
+ break;
+ case DIRID_COMMON_FAVORITES:
+ csidl = CSIDL_COMMON_FAVORITES;
+ break;
+ case DIRID_COMMON_APPDATA:
+ csidl = CSIDL_COMMON_APPDATA;
+ break;
+ case DIRID_SYSTEM_X86:
+ csidl = CSIDL_SYSTEMX86;
+ break;
+ case DIRID_PROGRAM_FILES_X86:
+ csidl = CSIDL_PROGRAM_FILESX86;
+ break;
+ case DIRID_PROGRAM_FILES_COMMON:
+ csidl = CSIDL_PROGRAM_FILES_COMMON ;
+ break;
+ case DIRID_PROGRAM_FILES_COMMONX86:
+ csidl = CSIDL_PROGRAM_FILES_COMMONX86;
+ break;
+ case DIRID_COMMON_TEMPLATES:
+ csidl = CSIDL_COMMON_TEMPLATES;
+ break;
+ case DIRID_COMMON_DOCUMENTS:
+ csidl = CSIDL_COMMON_DOCUMENTS;
+ break;
+ default:
+ return NULL;
+ }
+
+ r = pSHGetSpecialFolderPathW( NULL, buffer, CSIDL_PROGRAM_FILES, TRUE );
+ FreeLibrary( hShell32 );
+ if( !r )
+ return NULL;
+ len = (strlenW(buffer) + 1) * sizeof(WCHAR);
+ if ((str = HeapAlloc( GetProcessHeap(), 0, len ))) memcpy( str, buffer, len );
+ return str;
+}
+
/* retrieve the string corresponding to a dirid, or NULL if none */
const WCHAR *DIRID_get_string( HINF hinf, int dirid )
{
@@ -153,16 +230,29 @@
if (dirid == DIRID_ABSOLUTE || dirid == DIRID_ABSOLUTE_16BIT) dirid = DIRID_NULL;
- if (dirid >= DIRID_USER)
+ if (dirid > MAX_SYSTEM_DIRID)
{
+ WCHAR *str;
+
for (i = 0; i < nb_user_dirids; i++)
if (user_dirids[i].id == dirid) return user_dirids[i].str;
- ERR("user id %d not found\n", dirid );
- return NULL;
+ if (dirid >= DIRID_USER)
+ {
+ ERR("user id %d not found\n", dirid );
+ return NULL;
+ }
+ str = DIRID_get_csidl_dir( dirid );
+ if( str )
+ {
+ TRACE("Got CSIDL path %d -> %s\n", dirid, debugstr_w(str) );
+ store_user_dirid( hinf, dirid, str );
+ return str;
+ }
+ ERR("CSIDL id %d not found\n", dirid );
+ return get_unknown_dirid();
}
else
{
- if (dirid > MAX_SYSTEM_DIRID) return get_unknown_dirid();
if (dirid == DIRID_SRCPATH) return PARSER_get_src_root( hinf );
if (!system_dirids[dirid]) system_dirids[dirid] = create_system_dirid( dirid );
return system_dirids[dirid];
More information about the wine-patches
mailing list