Windows Only   (SYE_OS_API unit)

Reg_Folder_Exists

Checks whether a registry key (folder) exists under HKEY_CURRENT_USER.
Function Reg_Folder_Exists(Path: String): Boolean;

Parameters

  • Path: String; the subkey path relative to HKEY_CURRENT_USER.

Return Value

Returns True if the registry folder exists.
Returns False otherwise.

Reg_Read_Field

Reads a string value from a registry key under HKEY_CURRENT_USER.
Function Reg_Read_Field(Path, Name: String): String;

Parameters

  • Path: String; the subkey path under HKEY_CURRENT_USER.
  • Name: String; the name of the value to read.

Return Value

Returns the value as a string if found.
Returns an empty string when the name is empty or the key cannot be opened. Reading a missing value may raise a registry exception.

Reg_Write_Field

Writes a string value to a registry key under HKEY_CURRENT_USER.
Procedure Reg_Write_Field(Path, Name, Value: String);

Parameters

  • Path: String; the subkey path under HKEY_CURRENT_USER.
  • Name: String; the name of the value to write.
  • Value: String; the string content to write.

Reg_Delete_Folder

Deletes a named subkey (folder) from a registry path under HKEY_CURRENT_USER.
Function Reg_Delete_Folder(Path, Name: String): Boolean;

Parameters

  • Path: String; the base subkey under HKEY_CURRENT_USER.
  • Name: String; the name of the subkey to delete.

Return Value

Returns True if the subkey was deleted successfully.
Returns False if deletion failed.

Reg_Delete_Field

Deletes a named value (field) from a registry key under HKEY_CURRENT_USER.
Function Reg_Delete_Field(Path, Name: String): Boolean;

Parameters

  • Path: String; the key under HKEY_CURRENT_USER.
  • Name: String; the name of the value to delete.

Return Value

Returns True if the value was deleted successfully.
Returns False otherwise.

Reg_Delete_Fields_That_Contain_Str

Deletes registry values whose names contain a specific substring.
Function Reg_Delete_Fields_That_Contain_Str(Path, FindStr: String): Boolean;

Parameters

  • Path: String; the registry key to scan under HKEY_CURRENT_USER.
  • FindStr: String; the substring to search for in value names.

Return Value

Returns False if the key cannot be opened or has no values. Otherwise, returns True if all matching deletions succeed.
It can return True when the key contains values but none of their names match.

Reg_Read_BinField

Reads binary data from a registry value into a ThMemoryStream buffer (maximum 32 KB).
Procedure Reg_Read_BinField(Path, Name: String; Buff: ThMemoryStream);

Parameters

  • Path: String; the key path under HKEY_CURRENT_USER.
  • Name: String; the name of the binary value to read.
  • Buff: ThMemoryStream; buffer to receive up to 32KB of binary data.

Reg_Write_BinField

Writes binary data from a ThMemoryStream buffer into a registry field.
Procedure Reg_Write_BinField(Path, Name: String; Buff: ThMemoryStream);

Parameters

  • Path: String; the destination registry key under HKEY_CURRENT_USER.
  • Name: String; the name of the binary value to create or overwrite.
  • Buff: ThMemoryStream; the binary content to write. Its size is set to zero after a successful write.

Close_Handle

Closes a Windows system handle safely and sets it to zero if successful.
Optionally logs errors with a custom prefix.
Function Close_Handle(VAR HObject: THandle; LogErrorPrefix: RawByteString = ''): Boolean;

Parameters

  • HObject: THandle; the handle to be closed (will be set to 0 if closed).
  • LogErrorPrefix: RawByteString; optional text to prefix any logged error message.

Return Value

Returns True if the handle was successfully closed.
Returns True for an already zero or invalid handle. Returns False if closing a valid handle fails.

GetSpecialFolderPath

Returns the file system path of a Windows special folder by its identifier.
Function GetSpecialFolderPath(Rfid: TIID): String;

Parameters

  • Rfid: TIID; the KNOWNFOLDERID of the special folder (for example, FOLDERID_Documents).

Return Value

Returns the full path to the requested special folder, with a trailing path separator.
Returns an empty string if the folder is not available.

Get_Documents_Path

Retrieves the full path to the user's "Documents" folder.
Function Get_Documents_Path: String;

Return Value

Returns the path to the current user's documents folder.

Get_AppData_Local_Path

Returns the path to the user's Local AppData folder.
Function Get_AppData_Local_Path: String;

Return Value

Returns the path to the Local Application Data directory.

Get_AppData_Roaming_Path

Returns the path to the user's Roaming AppData folder.
Function Get_AppData_Roaming_Path: String;

Return Value

Returns the path to the Roaming Application Data directory.

Get_Desktop_Path

Returns the file system path to the user's desktop folder.
Function Get_Desktop_Path: String;

Return Value

Returns the full path to the desktop folder of the current user.

Get_Windows_Path

Returns the path to the Windows system folder.
Function Get_Windows_Path: String;

Return Value

Returns the path to the Windows directory (usually C:\Windows\).

Get_Pictures_Path

Returns the path to the user's "Pictures" folder.
Function Get_Pictures_Path: String;

Return Value

Returns the full path to the pictures directory.

Get_Programs_Path

Returns the full path to the "Program Files" or "Program Files (x86)" folder.
Function Get_Programs_Path(X86: Boolean = False): String;

Parameters

  • X86: Boolean; if True, returns the 32-bit Program Files folder. If False, returns the standard one.

Return Value

Returns the full path to the appropriate Program Files directory.

Disk_Free_Bytes_Available_To_User

Returns the number of free bytes available on the disk containing the specified path.
Function Disk_Free_Bytes_Available_To_User(DirectoryName: String): Int64;

Parameters

  • DirectoryName: String; a path on the disk to query.

Return Value

Returns the number of free bytes available to the calling user account.
Returns 0 if the Windows disk-space query fails; the function also writes a log entry.

Set_File_Write_Time_UTC

Sets the creation, last access, and last write timestamps of a file to the specified UTC time.
Function Set_File_Write_Time_UTC(FileName: String; Last_Update_UTC: TDateTime): Boolean;

Parameters

  • FileName: String; the path to the file whose timestamp will be updated.
  • Last_Update_UTC: TDateTime; the UTC value applied to all three file timestamps.

Return Value

Returns True if the time was successfully updated.
Returns False if the file does not exist or update failed.

WinApi_SelectFolder

Displays a standard Windows folder selection dialog.
If the user selects a folder, it updates the Directory parameter and returns True.
Function WinApi_SelectFolder(VAR Directory: String; Note: String = ''; Handle: HWnd = 0): Boolean;

Parameters

  • Directory: String; variable to receive the selected folder path.
  • Note: String; optional description or hint to show in the dialog.
  • Handle: HWnd; optional parent window handle for modal positioning.

Return Value

Returns True if a folder was selected.
Returns False if the dialog was canceled or failed.

IS_Process_Exists

Checks the executable paths of processes associated with top-level windows.
Function IS_Process_Exists(CONST Full_File_Name: String): Boolean;

Parameters

  • Full_File_Name: String; full path and file name of the target process.

Return Value

Returns True when a matching process is found. It also returns True if an exception occurs during the search.
Returns False when no matching process is found.

IF_Process_Exists_Kill_It

Checks whether a process is running by its full path and kills it if found.
Function IF_Process_Exists_Kill_It(CONST Full_File_Name: String): Boolean;

Parameters

  • Full_File_Name: String; full path and file name of the process to terminate.

Return Value

Returns True if a matching process was found; termination itself is not confirmed.
Returns False if the process was not found.

IS_Process_Exists_Without_Path

Checks if a process with the specified executable name is running (path is ignored).
Function IS_Process_Exists_Without_Path(ExeName: String): Boolean;

Parameters

  • ExeName: String; the name of the process (e.g. 'notepad.exe').

Return Value

Returns True if a matching process is running.
Returns False otherwise.

Show_All_Windows_Captions

Displays a popup containing the nonempty captions of top-level windows.
Procedure Show_All_Windows_Captions;

Find_Window_Handle_When_Caption_Cont_String

Searches for a window whose caption contains the specified string, optionally restoring it if found.
Function Find_Window_Handle_When_Caption_Cont_String(ContStr: String; Restore_Window_IF_Found: Boolean): Cardinal;

Parameters

  • ContStr: String; the substring to look for in window captions.
  • Restore_Window_IF_Found: Boolean; if True, minimizes, restores, maximizes, and flashes the matching window.

Return Value

Returns the handle of the found window.
Returns 0 if no matching window is found.

Post_Message_When_Caption_Same_String

Posts a Windows message to a window whose caption exactly matches a given string.
Procedure Post_Message_When_Caption_Same_String(SameStr: String; Msg: Cardinal; WParam, LParam: NativeInt);

Parameters

  • SameStr: String; exact window caption to search for.
  • Msg: Cardinal; message identifier to send (e.g. WM_CLOSE).
  • WParam: NativeInt; first message parameter.
  • LParam: NativeInt; second message parameter.

List_All_Windows_Captions

Returns a list of all top-level window captions currently visible on the system.
Function List_All_Windows_Captions: ThStringList;

Parameters

None

Return Value

Returns a new ThStringList containing nonempty top-level window captions. Each item's Data_Int stores its window handle.
The caller owns the returned list and must free it.

Call_Window_Handle_To_Front

Brings a specified window handle to the front of the screen and focuses it.
Procedure Call_Window_Handle_To_Front(Whnd: Cardinal);

Parameters

  • Whnd: Cardinal; handle of the window to bring to front.

Set_Application_Priority

Sets the process priority level for the current application.
Procedure Set_Application_Priority(Level: Byte = 1);

Parameters

  • Level: Byte; priority value (0 = Idle, 1 = Normal, 2 = High, 3 = RealTime).

Disable_Windows_UI_Effects

Disables Windows visual effects such as animations and fades.
When requested, writes the new settings to the user profile. This procedure does not save the previous settings for restoration.
Procedure Disable_Windows_UI_Effects(Save_This_Settings: Boolean);

Parameters

  • Save_This_Settings: Boolean; if True, persists the changed settings through Windows.

Set_Windows_Wallpaper

Enables or disables the desktop wallpaper based on a Boolean flag.
Function Set_Windows_Wallpaper(Enable_Wallpaper: Boolean): Boolean;

Parameters

  • Enable_Wallpaper: Boolean; True to enable wallpaper, False to disable it.

Return Value

Returns True if the wallpaper setting was changed successfully.
Returns False otherwise.

Windows_Form_Borders_Handler

Handles the non-client hit test message to allow dragging or restricting border interaction on forms.
Procedure Windows_Form_Borders_Handler(VAR Msg: TWMNCHitTest; CONST Form: TForm; CONST AllowMove: Boolean = False);

Parameters

  • Msg: TWMNCHitTest; the Windows message to process (passed by reference).
  • Form: TForm; the target form whose borders are being handled.
  • AllowMove: Boolean; if True, enables window dragging (default is False).

Execute_Browser_On_LocalHost

Launches a specific browser and navigates to the given local URL.
Function Execute_Browser_On_LocalHost(CONST Http_URL: String; CONST Incognito: Boolean; CONST BrowserType: Byte): Boolean;

Parameters

  • Http_URL: String; the localhost URL to open.
  • Incognito: Boolean; if True, launches browser in private/incognito mode.
  • BrowserType: Byte; 0 = Chrome, 1 = Edge, 2 = Internet Explorer, 3 = Excel.

Return Value

Returns True when the executable is found. The function does not verify whether launching it succeeded.

Execute_Browser_By_OS_Priority

Opens a URL using the preferred browser based on OS/browser availability order.
Function Execute_Browser_By_OS_Priority(Http_URL: String; Incognito: Boolean): Boolean;

Parameters

  • Http_URL: String; the target URL to launch.
  • Incognito: Boolean; if True, attempts incognito mode where supported.

Return Value

Returns True when a browser executable is found or the operating system accepts the URL.
Finding a browser does not confirm that its launch succeeded.

Start_Whatsapp

Opens a WhatsApp URL with a prefilled message to a specific phone number through the browser priority routine.
Procedure Start_Whatsapp(TargetPhone, Text: String);

Parameters

  • TargetPhone: String; the destination phone number (in international format).
  • Text: String; the prefilled message text. This routine does not URL-encode it.

ExecURL

Executes the given URL using the system's registered handler (e.g. browser).
Function ExecURL(CONST URL: String; CONST Param: String = ''): Boolean;

Parameters

  • URL: String; the URL or protocol string to execute.
  • Param: String; optional command or arguments to pass (default is empty).

Return Value

Returns True if the ShellExecute call succeeds using open or its edit fallback.

EditURL

Launches a given URL with the "edit" verb to open it in an editor (e.g. Notepad for text files).
Function EditURL(CONST URL: String; CONST Param: String = ''): Boolean;

Parameters

  • URL: String; the target file or URL to open in edit mode.
  • Param: String; optional arguments (default is empty).

Return Value

Returns True if the ShellExecute call succeeds using edit or its open fallback.

ExecAppl

Executes an external application with parameters and advanced options like waiting or hiding.
Function ExecAppl(Path, FileName, Param: String; WaitforProcess_In_Sec: Word = 0; EditMode: Boolean = False; Hidden: Boolean = False; LogThis: Boolean = False): Boolean;

Parameters

  • Path: String; working directory or application path.
  • FileName: String; name of the executable file.
  • Param: String; parameters to pass to the executable.
  • WaitforProcess_In_Sec: Word; wait time in seconds for the process to exit (0 = no wait).
  • EditMode: Boolean; if True, opens in "edit" verb mode (default is False).
  • Hidden: Boolean; if True, runs the process hidden from the user.
  • LogThis: Boolean; if True, logs the execution call.

Return Value

Returns True if the application started successfully.

ExecAppl2

Executes a command string using ShellExecute with an optional target path override.
Function ExecAppl2(FullCommandStr, ForcePathTo: String; Command: String = 'open'): Boolean;

Parameters

  • FullCommandStr: String; the full command to run.
  • ForcePathTo: String; optional directory to execute in.
  • Command: String; verb to use (e.g. 'open', 'edit', etc).

Return Value

Returns True if the ShellExecute call succeeded.

ExecAppl3_Into_File

Runs an external executable and redirects its output into a file.
Function ExecAppl3_Into_File(CONST Executable, Arguments, OutputFile: String; WaitforProcess_In_Sec: Word): Boolean;

Parameters

  • Executable: String; the full path to the executable.
  • Arguments: String; the command-line arguments to pass.
  • OutputFile: String; file to capture the output of the process.
  • WaitforProcess_In_Sec: Word; maximum time to wait for process to complete.

Return Value

Returns True if the process finished within the time limit with exit code 0.
Standard output and standard error go to OutputFile; the minimum wait is five seconds.

Show_File_Properties

Displays the Windows Properties dialog for a specific file.
Function Show_File_Properties(FileName: String): Boolean;

Parameters

  • FileName: String; the full path to the file.

Return Value

Returns True if the properties dialog was successfully opened.
Returns False if the dialog could not be shown.

Check_CmdLine_Switch

Checks whether a command-line switch (flag) exists in the current application's parameters.
Function Check_CmdLine_Switch(_Switch: RawByteString): Boolean;

Parameters

  • _Switch: RawByteString; switch name without a leading - or /, for example silent.

Return Value

Returns True if the command line contains - or / followed by the switch text.
This is a substring search; it does not check parameter boundaries.
Returns False otherwise.

Get_CmdLine_Param_Value

Extracts the value of a named command-line parameter.
Function Get_CmdLine_Param_Value(Name: String): String;

Parameters

  • Name: String; the name of the parameter to locate (case-insensitive).

Return Value

Returns the string that follows the '=' after the matching parameter name.
Returns an empty string if not found or malformed.

ParamStrW

Returns a Unicode-safe version of ParamStr for retrieving command-line arguments.
Function ParamStrW(Index: Byte): String;

Parameters

  • Index: Byte; the parameter index to retrieve (starting at 0).

Return Value

Returns the parameter string at the specified index as UTF-16.

GetShortcut_FN

Builds the full file name of a shortcut based on its title and target folder.
Function GetShortcut_FN(Title: String; Folder_ID: Byte): String;

Parameters

  • Title: String; the name (without extension) of the shortcut.
  • Folder_ID: Byte; 0 = Desktop, 1 = user's Programs, 2 = common Programs, 3 = user's Startup.

Return Value

Returns the full .lnk path to the shortcut if the folder is valid.
Returns an empty string on failure.

CreateShortcut

Creates a Windows shortcut (.lnk) pointing to a target file with optional parameters.
Function CreateShortcut(Title, TargetFile, Parameters: String; Folder_ID: Byte; Maximized: Boolean): Boolean;

Parameters

  • Title: String; the shortcut's display name (without extension).
  • TargetFile: String; the executable or file to run.
  • Parameters: String; optional parameters to pass to the executable.
  • Folder_ID: Byte; 0 = Desktop, 1 = user's Programs, 2 = common Programs, 3 = user's Startup.
  • Maximized: Boolean; if True, the shortcut will launch in maximized window mode.

Return Value

Returns True if the shortcut was created successfully.

GetWindowsVersion

Returns a numeric Windows version derived from Windows version information.
Function GetWindowsVersion: Double;

Parameters

None

Return Value

Returns a floating-point value indicating the Windows version.

Application_Terms_OR_HALT

Checks the Windows version. If its numeric value is 6 or lower, displays or logs a compatibility message and halts with exit code 2.
Procedure Application_Terms_OR_HALT;

Prevent_Multi_Instances_By_Mutex

Checks a named mutex for another instance of this application. If one exists, reports it and requests application termination.
Procedure Prevent_Multi_Instances_By_Mutex;

Get_Joystick_Button_Down

Polls a joystick and reports a newly pressed single button among buttons 1 through 20.
Function Get_Joystick_Button_Down(Device_Index: Byte): Byte;

Parameters

  • Device_Index: Byte; the index of the joystick device to poll (usually 0).

Return Value

Returns the button number (1–20) when it differs from the previous result for this device.
Returns 0 when there is no new single-button press or the device cannot be read.

Simulate_Keyboard_Clicks

Simulates typing text as if it were input by the keyboard.
Procedure Simulate_Keyboard_Clicks(Text: String);

Parameters

  • Text: String; the text string to simulate keystrokes for.

Get_File_Version

Retrieves the file version of a specified executable or DLL and extracts its numeric version string and high 32-bit segment.
Function Get_File_Version(_FileName: String; VAR FourNumText: String; VAR MostSignif: Cardinal): Boolean;

Parameters

  • _FileName: String; full path to the file whose version is to be read.
  • FourNumText: String; output string in the format "x.x.x.x".
  • MostSignif: Cardinal; output high-order version number for numeric comparison.

Return Value

Returns True if version info was successfully extracted.
Returns False if the file lacks version information or cannot be read.

hv_Version

Returns a formatted version number derived from the running application's executable.
Function hv_Version: String;

Parameters

None

Return Value

Returns a formatted string derived from the executable's version resource, or an empty string when it cannot be read.

Files_List_Into_String

Returns a single string with the names of all matching files, separated by line breaks.
Function Files_List_Into_String(Path, FileMask: String; IncFileExt, StopAfterFirstFile: Boolean): String;

Parameters

  • Path: String; path to search in.
  • FileMask: String; pattern to match (e.g. '*.dat').
  • IncFileExt: Boolean; include extensions in output if True.
  • StopAfterFirstFile: Boolean; stop after first match if True.

Return Value

Returns a string with file names separated by CRLF. Only files of at least three bytes with a UTC file date of at least 1000 are included.

Process_Drop_Files_Message

Processes a WM_DROPFILES message and extracts dropped file paths into a ThStringList.
Function Process_Drop_Files_Message(VAR Msg: TWMDROPFILES; VAR SL: ThStringList): Boolean;

Parameters

  • Msg: TWMDROPFILES; the Windows drop-files message (passed by reference).
  • SL: ThStringList; receives the dropped full file paths.

Return Value

Returns True when at least one dropped file path was extracted. The caller owns the returned list and must free it.
Returns False when no files were found or parsing failed.

Get_Copied_Files_From_Clipboard

Reads file paths from clipboard data (CF_HDROP) into a ThStringList.
Function Get_Copied_Files_From_Clipboard(VAR SL: ThStringList): Boolean;

Parameters

  • SL: ThStringList; receives the copied full file paths.

Return Value

Returns True when clipboard file paths were read successfully. The caller owns the returned list and must free it.
Returns False when clipboard does not contain file-drop data or read fails.

Kill_Directories_When_Empty_From_Files

Recursively removes a directory tree only when it contains no ordinary files.
The function leaves directories containing files in place. Its Boolean result describes the scan, not whether Windows removed the directory successfully.
Function Kill_Directories_When_Empty_From_Files(Path: String): Boolean;

Parameters

  • Path: String; the directory to inspect, including its subdirectories.

Return Value

Returns True when no file is found, including when the path does not exist. Entries whose names begin with a dot are skipped by the scan.
Returns False when a file is found in this directory or a descendant.