4.35.1 Windows-specific Operating System Interaction
The predicates in this section are only available on the Windows version of SWI-Prolog. Their use is discouraged if there are portably alternatives. For example, win_exec/2 and win_shell/2 can often be replaced by the more portable shell/2 or the more powerful process_create/3.
- win_exec(+Command, +Show)
- Windows only. Spawns a Windows task without waiting for its completion. Show
is one of the Win32
SW_*
constants written in lowercase without theSW_*
:hide
maximize
minimize
restore
show
showdefault
showmaximized
showminimized
showminnoactive
showna
shownoactive
shownormal
. In addition,iconic
is a synonym forminimize
andnormal
forshownormal
. - win_shell(+Operation, +File, +Show)
- Windows only. Opens the document File using the Windows shell
rules for doing so. Operation is one of
open
,print
orexplore
or another operation registered with the shell for the given document type. On modern systems it is also possible to pass a URL as File, opening the URL in Windows default browser. This call interfaces to the Win32 API ShellExecute(). The Show argument determines the initial state of the opened window (if any). See win_exec/2 for defined values. - win_shell(+Operation, +File)
- Same as
win_shell(Operation, File, normal)
- win_registry_get_value(+Key, +Name, -Value)
- Windows only. Fetches the value of a Windows registry key. Key
is an atom formed as a path name describing the desired registry key.
Name is the desired attribute name of the key. Value
is unified with the value. If the value is of type
DWORD
, the value is returned as an integer. If the value is a string, it is returned as a Prolog atom. Other types are currently not supported. The default `root' isHKEY_CURRENT_USER
. Other roots can be specified explicitly asHKEY_CLASSES_ROOT
,HKEY_CURRENT_USER
,HKEY_LOCAL_MACHINE
orHKEY_USERS
. The example below fetches the extension to use for Prolog files (seeREADME.TXT
on the Windows version):?- win_registry_get_value( 'HKEY_LOCAL_MACHINE/Software/SWI/Prolog', fileExtension, Ext). Ext = pl
- win_folder(?Name, -Directory)
- True if Name is the Windows `CSIDL' of Directory.
If
Name is unbound, all known Windows special paths are
generated.
Name is the CSIDL after deleting the leading
CSIDL_
and mapping the constant to lowercase. Check the Windows documentation for the function SHGetSpecialFolderPath() for a description of the defined constants. This example extracts the `My Documents' folder:?- win_folder(personal, MyDocuments). MyDocuments = 'C:/Documents and Settings/jan/My Documents'
- win_add_dll_directory(+AbsDir)
- This predicate adds a directory to the search path for dependent DLL
files. If possible, this is achieved with win_add_dll_directory/2.
Otherwise,
%PATH%
is extended with the provided directory. AbsDir may be specified in the Prolog canonical syntax. See prolog_to_os_filename/2. Note that use_foreign_library/1 passes an absolute path to the DLL if the destination DLL can be located from the specification using absolute_file_name/3. - win_add_dll_directory(+AbsDir, -Cookie)
- This predicate adds a directory to the search path for dependent DLL
files. If the call is successful it unifies Cookie with a
handle that must be passed to win_remove_dll_directory/1
to remove the directory from the search path. Error conditions:
- This predicate is available in the Windows port of SWI-Prolog starting from 6.3.8/6.2.6.
- This predicate fails if Windows does not yet support the underlying primitives. These are available in recently patched Windows 7 systems and later.
- This predicate throws an acception if the provided path is invalid or the underlying Windows API returns an error.
If open_shared_object/2 is passed an absolute path to a DLL on a Windows installation that supports AddDllDirectory() and friends,130Windows 7 with up-to-date patches or Windows 8. SWI-Prolog uses LoadLibraryEx() with the flags
LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR
andLOAD_LIBRARY_SEARCH_DEFAULT_DIRS
. In this scenario, directories from%PATH%
and not searched. Additional directories can be added using win_add_dll_directory/2. - win_remove_dll_directory(-Cookie)
- Remove a DLL search directory installed using win_add_dll_directory/2.