function ComputerName: KOLString;
Returns computer name.
Returns user name (login).
Returns a list of users currently logined to a system. Don't forget to free it when it is not more necessary!
function IsUserAdmin( s: KOLString ): TUserRights;
Returns TRUE if a user (given by s) has administrator rights on a computer.
type TWindowChildKind =( wcActive, wcFocus, wcCapture, wcMenuOwner, wcMoveSize, wcCaret );
Type of window child kind. Used in function GetWindowChild.
function GetWindowChild( Wnd: HWnd; Kind: TWindowChildKind ): HWnd;
Returns child of given top-level window, having given characteristics. For example, it is possible to get know for foreground window, which of its child window has focus. This function does not work in old Windows 95 (returns Wnd in that case). But for Windows 98, Windows NT/2000 this function works fine. To obtain focused child of the window, use GetFocusedWindow, which is independant from Windows version.
function GetFocusedChild( Wnd: HWnd ): HWnd;
Returns focused child of given window (which should be foreground and active, certainly). 0 is returned either if Wnd is not active or Wnd has no focused child window.
function ForceSetForegroundWindow: Integer;
Calls AllowSetForegroundWindow (if available) and changes SPI_SETFOREGROUNDLOCKTIMEOUT to 0, returning previus value got by SPI_GETFOREGROUNDLOCKTIMEOUT. If failed, -1 is returned
Delay time while passing keys using Stroke2Window and Stroke2WindowEx.
function Stroke2Window( Wnd: HWnd; const S: AnsiString ): Boolean;
Posts characters from string S to those child window of Wnd, which has focus now (top-level window Wnd must be foreground, and have focused edit-aware control to receive the stroke).
This function allows only to post typeable characters (including such special symbols as #13 (Enter), #9 (Tab), #8 (BackSpace), etc.
See also function Stroke2WindowEx, which allows to post any key down and up events, simulating keyboard for given (automated) application.
function Stroke2WindowEx( Wnd: HWnd; const S: AnsiString; Wait: Boolean ): Boolean;
In addition to function Stroke2Window, this one can send special keys to given window, including functional keys and navigation keys. To post special key to target window, place a combination of names of such key together with keys, which should be passed simultaneously, between square or figure brackets. For example, [Ctrl F1], [Alt Shift Home], [Ctrl E]. For letters and usual characters, it is not necessary to simulate pressing it with determining all Shift combinations and it is sufficient to pass characters as is. (E.g., not '[Shift 1]', but '!').
function SendCommands2Wnd( WndHandle: Hwnd; const s: KOLString ): Boolean;
Sends commands to a window "as is" (e.g. #13 for Enter). Can pass up to 4K key commands at a time vewry fast.
function FindWindowByThreadID( ThreadID: DWORD ): HWnd;
Searches for window, belonging to a given thread.
function DesktopPixelFormat: TPixelFormat;
Returns the pixel format correspondent to current desktop color resolution. Use this function to decide which format to use for converting bitmap, planned to draw transparently using TBitmap.DrawTransparent or TBitmap.StretchDrawTransparent methods.
function ListMonitors: TRectsArray;
Lists all monitors in system, returns an array of rectangles with its coordinates and sizes.
function MonitorAt( X, Y: Integer ): TRect;
Returns monitor where given point (X,Y) is located. If not found, main monitor bounds is returned.
function GetDesktopRect: TRect;
Returns rectangle of screen, free of taskbar and other similar app-bars, which reduces size of available desktop when created.
function GetWorkArea: TRect;
The same as GetDesktopRect, but obtained calling SystemParametersInfo.
function ExecuteWait( const AppPath, CmdLine, DfltDirectory: KOLString; Show: DWORD; TimeOut: DWORD; ProcID: PDWORD ): Boolean;
Allows to execute an application and wait when it is finished. Pass INFINITE constant as TimeOut, if You sure that application is finished anyway. If another value passed as a TimeOut (in milliseconds), and application was not finished for that time, ExecuteWait is returning FALSE, and if ProcID is not nil, than ProcID^ contains started process handle (it can be used to wait it more, or to terminate it using TerminateProcess API function).
Launching application can be console or GUI - it does not matter. Pass SW_SHOW, SW_HIDE or other SW_XXX constant as Show parameter as appropriate.
True is returned only in case when application specified was launched successfully and finished for TimeOut specified. Otherwise, check ProcID^ variable: if it is 0, process could not be launched (and it is possible to get information about error using GetLastError API function in a such case). You can freely pass nil in place of ProcID parameter, but this is acually correct only when TimeOut is INFINITE.
function ExecuteIORedirect( const AppPath, CmdLine, DfltDirectory: KOLString; Show: DWORD; ProcID: PDWORD; InPipe, OutPipeWr, OutPipeRd: PHandle ): Boolean;
Executes an application with its console input and output redirection. Terminating of the application is not waiting, but if ProcID pointer is defined, it receives process Id launched, so it is possible to call WaitForSingleObject for it. InPipe is a pointer to THandle variable which receives a handle to input pipe of the console redirected. The same is for OutPipeWr and OutPipeRd, but for output of the console redirected. Before reading from OutPipeRd^, first close OutPipeWr^. If you run simple console application, for which you want to read results after its termination, you can use ExecuteConsoleAppIORedirect instead.
Notes: if your application is not console and it does not create console using AllocConsole, this function will fail to redirect input-output.
function ExecuteConsoleAppIORedirect( const AppPath, CmdLine, DfltDirectory: KOLString; Show: DWORD; const InStr: KOLString; var OutStr: KOLString; WaitTimeout: DWORD ): Boolean;
Executes an application, redirecting its console input and output. After redirecting input and output and launching the application, content of InStr is written to input stream of the application, then the application is waiting for its termination (WaitTimeout milliseconds or INFINITE, as passed) and console output of the application is read to OutStr. TRUE is returned only in case, when all these tasks are completed successfully.
Notes: if your application is not console and it does not create console using AllocConsole, this function will fail to redirect input-output.
function WindowsShutdown( const Machine: KOLString; Force, Reboot: Boolean ): Boolean;
Shut down of Windows NT. Pass Machine = '' to shutdown this PC. Pass Reboot = True to reboot immediatelly after shut down.
function WindowsLogoff( Force: Boolean ): Boolean;
Logoff of Windows.
type TWindowsVersion =( wv31, wv95, wv98, wvME, wvNT, wvY2K, wvXP, wvServer2003, wvVista, wvSeven );
Windows versions constants.
type TWindowsVersions = Set of TWindowsVersion;
Set of Windows version (e.g. to define a range of versions supported by the application).
function WinVer: TWindowsVersion;
Returns Windows version.
function IsWinVer( Ver: TWindowsVersions ): Boolean;
Returns True if Windows version is in given range of values.
function ParamStr( Idx: Integer ): KOLString;
Returns command-line parameter by index. This function supersides standard ParamStr function.
Returns number of parameters in command line.
type TOnAnotherInstance = procedure( const CmdLine: KOLString ) of object;
Event type to use in JustOneNotify function.
function JustOne( Wnd: PControl; const Identifier: KOLString ): Boolean;
Returns True, if this is a first instance. For all other instances (application is already running), False is returned.
function JustOneNotify( Wnd: PControl; const Identifier: KOLString; const aOnAnotherInstance: TOnAnotherInstance ): Boolean;
Returns True, if this is a first instance. For all other instances (application is already running), False is returned. If handler aOnAnotherInstance passed, it is called (in first instance) every time when another instance of an application is started, receiving command line used to run it.