1 % (c) 2009-2024 Lehrstuhl fuer Softwaretechnik und Programmiersprachen,
2 % Heinrich Heine Universitaet Duesseldorf
3 % This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html)
4
5 :- module(dll_path, [set_dll_directory/1]).
6
7 :- use_module(probsrc(tools_platform), [host_platform/1]).
8
9 :- if((host_platform(windows), predicate_property(load_foreign_resource(_), _))).
10
11 :- use_module(probsrc(pathes_lib), [safe_load_foreign_resource/2]).
12
13 foreign_resource(dll_path, [set_dll_directory_c]).
14 foreign(set_dll_directory_c, c, set_dll_directory_c(+string)).
15
16 :- dynamic loaded/0.
17
18 init :-
19 loaded,
20 !.
21 init :-
22 safe_load_foreign_resource(dll_path, dll_path),
23 assertz(loaded).
24
25 % Simple Prolog wrapper around the Win32 function SetDllDirectory.
26 set_dll_directory(Dir) :-
27 init,
28 set_dll_directory_c(Dir).
29
30 :- else.
31
32 % Not on Windows or foreign resources not supported (e. g. SWI currently), so do nothing.
33 set_dll_directory(_).
34
35 :- endif.