@@ -967,6 +967,21 @@ impl QisHeliosInterface {
967967 ) -> Result < ( Library , Library ) , InterfaceError > {
968968 use std:: os:: windows:: ffi:: OsStrExt ;
969969
970+ // AddDllDirectory FFI - adds directories to the DLL search path
971+ // This is better than SetDllDirectoryW because it allows multiple directories
972+ type DllDirectoryCookie = * mut std:: ffi:: c_void ;
973+
974+ #[ link( name = "kernel32" ) ]
975+ unsafe extern "system" {
976+ fn AddDllDirectory ( path : * const u16 ) -> DllDirectoryCookie ;
977+ fn RemoveDllDirectory ( cookie : DllDirectoryCookie ) -> i32 ;
978+ fn SetDefaultDllDirectories ( flags : u32 ) -> i32 ;
979+ }
980+
981+ // LOAD_LIBRARY_SEARCH flags
982+ const LOAD_LIBRARY_SEARCH_DEFAULT_DIRS : u32 = 0x0000_1000 ;
983+ const LOAD_LIBRARY_SEARCH_USER_DIRS : u32 = 0x0000_0400 ;
984+
970985 // On Windows, there's no RTLD_GLOBAL flag. DLL dependencies need to be
971986 // findable via the standard DLL search order. For program.dll, we need
972987 // pecos_qis_ffi.dll and the shim DLL to be findable.
@@ -985,21 +1000,6 @@ impl QisHeliosInterface {
9851000 let dll_dirs: Vec < & std:: path:: Path > =
9861001 [ qis_ffi_dir, shim_dir] . into_iter ( ) . flatten ( ) . collect ( ) ;
9871002
988- // AddDllDirectory FFI - adds directories to the DLL search path
989- // This is better than SetDllDirectoryW because it allows multiple directories
990- type DllDirectoryCookie = * mut std:: ffi:: c_void ;
991-
992- #[ link( name = "kernel32" ) ]
993- unsafe extern "system" {
994- fn AddDllDirectory ( path : * const u16 ) -> DllDirectoryCookie ;
995- fn RemoveDllDirectory ( cookie : DllDirectoryCookie ) -> i32 ;
996- fn SetDefaultDllDirectories ( flags : u32 ) -> i32 ;
997- }
998-
999- // LOAD_LIBRARY_SEARCH flags
1000- const LOAD_LIBRARY_SEARCH_DEFAULT_DIRS : u32 = 0x00001000 ;
1001- const LOAD_LIBRARY_SEARCH_USER_DIRS : u32 = 0x00000400 ;
1002-
10031003 // Set the default search order to include user-added directories
10041004 unsafe {
10051005 SetDefaultDllDirectories (
@@ -1012,11 +1012,11 @@ impl QisHeliosInterface {
10121012 for dir in & dll_dirs {
10131013 let dir_wide: Vec < u16 > = dir. as_os_str ( ) . encode_wide ( ) . chain ( Some ( 0 ) ) . collect ( ) ;
10141014 let cookie = unsafe { AddDllDirectory ( dir_wide. as_ptr ( ) ) } ;
1015- if !cookie. is_null ( ) {
1015+ if cookie. is_null ( ) {
1016+ warn ! ( "Windows: Failed to add DLL directory: {}" , dir. display( ) ) ;
1017+ } else {
10161018 debug ! ( "Windows: Added DLL search directory: {}" , dir. display( ) ) ;
10171019 cookies. push ( cookie) ;
1018- } else {
1019- warn ! ( "Windows: Failed to add DLL directory: {}" , dir. display( ) ) ;
10201020 }
10211021 }
10221022
0 commit comments