Author: cwittich
Date: Mon Apr 20 10:23:46 2009
New Revision: 40603
URL:
http://svn.reactos.org/svn/reactos?rev=40603&view=rev
Log:
sync SetupGetTargetPathW with wine
fixes all setupapi query winetests
Modified:
trunk/reactos/dll/win32/setupapi/query.c
Modified: trunk/reactos/dll/win32/setupapi/query.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/setupapi/query.c…
==============================================================================
--- trunk/reactos/dll/win32/setupapi/query.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/setupapi/query.c [iso-8859-1] Mon Apr 20 10:23:46 2009
@@ -563,19 +563,25 @@
{'D','e','f','a','u','l','t','D','e','s','t','D','i','r',0};
INFCONTEXT ctx;
- WCHAR *dir;
- INT size;
+ WCHAR *dir, systemdir[MAX_PATH];
+ unsigned int size;
+ BOOL ret = FALSE;
TRACE("%p, %p, %s, %p, 0x%08x, %p\n", hinf, context, debugstr_w(section),
buffer,
buffer_size, required_size);
- if (context && !SetupFindFirstLineW( hinf, destination_dirs, NULL, context ))
return FALSE;
- else if (section && !SetupFindFirstLineW( hinf, section, NULL, &ctx ))
return FALSE;
- else if (!SetupFindFirstLineW( hinf, destination_dirs, default_dest_dir, &ctx ))
return FALSE;
-
- if (!(dir = PARSER_get_dest_dir( context ? context : &ctx ))) return FALSE;
-
- size = lstrlenW( dir ) + 1;
+ if (context) ret = SetupFindFirstLineW( hinf, destination_dirs, NULL, context );
+ else if (section)
+ {
+ if (!(ret = SetupFindFirstLineW( hinf, destination_dirs, section, &ctx )))
+ ret = SetupFindFirstLineW( hinf, destination_dirs, default_dest_dir, &ctx
);
+ }
+ if (!ret || !(dir = PARSER_get_dest_dir( context ? context : &ctx )))
+ {
+ GetSystemDirectoryW( systemdir, MAX_PATH );
+ dir = systemdir;
+ }
+ size = strlenW( dir ) + 1;
if (required_size) *required_size = size;
if (buffer)
@@ -589,7 +595,7 @@
return FALSE;
}
}
- HeapFree( GetProcessHeap(), 0, dir );
+ if (dir != systemdir) HeapFree( GetProcessHeap(), 0, dir );
return TRUE;
}