@@ -775,6 +775,19 @@ typedef enum _APPCOMPAT_USERFLAGS_HIGHPART
775775} APPCOMPAT_USERFLAGS_HIGHPART ;
776776//===reactos/sdk/include/ndk/pstypes.h==
777777
778+ void set_dll_path ()
779+ {
780+ WCHAR mod_path [MAX_PATH ];
781+ GetModuleFileNameW (NULL , mod_path , _countof (mod_path ));
782+ LPWSTR last = wcsrchr (mod_path , L'\\' );
783+ last [0 ] = 0 ;
784+ LPCWSTR dir = L"\\dll" ;
785+ if (wcslen (last ) + wcslen (dir ) + 1 >= MAX_PATH )
786+ return ;
787+ memcpy (last , dir , (wcslen (dir ) + 1 ) * sizeof (* dir ));
788+ SetDllDirectoryW (mod_path );
789+ }
790+
778791static BOOL set_peb_compatible_flag ()
779792{
780793 BOOL success = TRUE;
@@ -784,6 +797,7 @@ static BOOL set_peb_compatible_flag()
784797 APPCOMPAT_USERFLAGS_HIGHPART flags3 = (APPCOMPAT_USERFLAGS_HIGHPART )teb -> Peb -> AppCompatFlagsUser .HighPart ;
785798 APPCOMPAT_FLAGS f = NoPaddedBorder | NoGhost ;
786799 HMODULE user32 = GetModuleHandleA ("user32.dll" );
800+ set_dll_path ();
787801 if ((flags2 & f ) != f && user32 != NULL )
788802 {
789803 WINE_ERR ("user32.dll has already been loaded. (Anti-virus software may be the cause.)\n" );
@@ -1121,7 +1135,6 @@ int main( int argc, char *argv[] )
11211135
11221136 RestoreThunkLock (1 ); /* grab the Win16 lock */
11231137
1124- SetDllDirectoryA (argv [0 ]);
11251138 /* some programs assume mmsystem is always present */
11261139 LoadLibrary16 ( "gdi.exe" );
11271140 LoadLibrary16 ( "user.exe" );
0 commit comments