Home Units Hierarchy Routines All identifiers

Unit unaUtils

DescriptionUsesClasses, Interfaces, Objects and RecordsFunctions and ProceduresTypesConstantsVariables

Description

Contains useful routines used by other units and classes.

Version 2.5.2008.10 + CodeGear RAD 2009 compatible; Version 2.5.2008.07 + aware of BDS 2006's and later improved memory manager; Version 2.5.2009.12 + removed variant stuff Version 2.5.2010.01 + some cleanup

Uses

Overview

Classes, Interfaces, Objects and Records

Name Description
Interface IEnumIDList  
Interface IMalloc  
Interface IShellFolder  
record tagPROCESSENTRY32W  
packed record tRGB  
record _browseinfoA  
record _browseinfoW output var: where to return the Image index.

Functions and Procedures

function min(A, B: int): int; overload;
function min(A, B: unsigned): unsigned; overload;
function min(A, B: int64): int64; overload;
function max(A, B: int64): int64; overload;
function max(A, B: int): int; overload;
function max(A, B: unsigned): unsigned; overload;
function max(A, B: double): double; overload;
function sshl(v: int; c: int): int;
function sshr(v: int; c: int): int;
function base64encode(data: pointer; size: unsigned): aString; overload;
function base64encode(const data: aString): aString; overload;
function base64decode(const data: aString): aString; overload;
function base64decode(data: pointer; len: unsigned): aString; overload;
function base64decode(const data: aString; out buf: pointer): unsigned; overload;
function crc32(const data: aString; crc: uint32 = $FFFFFFFF): uint32; overload;
function crc32(data: pointer; len: unsigned; crc: uint32 = $FFFFFFFF): uint32; overload;
function crc16(data: pointer; len: unsigned): uint16;
function crc8(data: pointer; len: unsigned): uint8;
function crc4(data: pointer; len: unsigned): uint8;
function cp2UTF8(cp: uint32): aString;
function highSurrogate(cp: uint32): uint16;
function lowSurrogate(cp: uint32): uint16;
function isHighSurrogate(w: uint16): bool;
function isLowSurrogate(w: uint16): bool;
function surrogate2cp(highSurrogate, lowSurrogate: uint16): uint32;
function UTF162UTF8(const w: wString): aString;
function UTF82UTF16(const s: aString): wString;
function wide2ansi(const w: wString; cp: unsigned = CP_ACP): aString;
function ReadFile(hFile: tHandle; buffer: pointer; nNumberOfBytesToRead: DWORD; lpNumberOfBytesRead: LPDWORD; lpOverlapped: POVERLAPPED): BOOL; stdcall;
function WriteFile(hFile: tHandle; buffer: pointer; nNumberOfBytesToWrite: DWORD; lpNumberOfBytesWritten: LPDWORD; lpOverlapped: POVERLAPPED): BOOL; stdcall;
function fileSize2str(sz: int64): string;
function fileExists(const name: wString): bool;
function fileCreate(const name: wString; truncate: bool = true; leaveOpen: bool = false; flags: DWORD = 0): tHandle;
function fileOpen(const name: wString; wantWrites: bool = false; allowSharedWrites: bool = true; flags: DWORD = FILE_ATTRIBUTE_NORMAL): tHandle;
function fileClose(f: tHandle): bool;
function fileTruncate(handle: tHandle; pos: unsigned = 0; posMode: unsigned = FILE_BEGIN): bool;
function writeToFile(const name: wString; buf: pointer; size: unsigned; pos: unsigned = 0; posMode: unsigned = FILE_END): int; overload;
function writeToFile(const name: wString; const buf: aString; pos: unsigned = 0; posMode: unsigned = FILE_END): int; overload;
function writeToFile(handle: tHandle; buf: pointer; size: unsigned; pos: unsigned = 0; posMode: unsigned = FILE_CURRENT): int; overload;
function writeToFile(handle: tHandle; const buf: aString; pos: unsigned = 0; posMode: unsigned = FILE_CURRENT): int; overload;
function readFromFile(const name: wString; buf: pointer; var size: unsigned; pos: unsigned = 0; posMode: unsigned = FILE_BEGIN): int; overload;
function readFromFile(const name: wString; pos: unsigned = 0; posMode: unsigned = FILE_BEGIN; len: int64 = 0): aString; overload;
function readFromFile(handle: tHandle; buf: pointer; var size: unsigned; pos: unsigned = 0; posMode: unsigned = FILE_CURRENT): int; overload;
function fileSize(const name: wString): int64; overload;
function fileSize(handle: tHandle): int64; overload;
function fileSeek(handle: tHandle; pos: int = 0; posMode: unsigned = FILE_BEGIN): int;
function fileMove(const oldName, newName: wString): bool;
function fileCopy(const oldName, newName: wString; failIfExists: bool): bool;
function fileDelete(const fileName: wString): bool;
function fileChecksum(f: tHandle; crc: uint32 = $FFFFFFFF): uint32; overload;
function fileChecksum(const fileName: wString): uint32; overload;
function fileModificationDateTime(const fileName: wString; useLocalTime: bool = true): SYSTEMTIME; overload;
function fileModificationDateTime(f: tHandle; useLocalTime: bool = true): SYSTEMTIME; overload;
function fileCreationDateTime(const fileName: wString; useLocalTime: bool = true): SYSTEMTIME; overload;
function fileCreationDateTime(f: tHandle; useLocalTime: bool = true): SYSTEMTIME; overload;
function directoryExists(const name: wString): bool;
function forceDirectories(const path: wString): bool;
function extractFilePath(const fileName: wString): wString;
function extractFileName(const fileName: wString): wString;
function changeFileExt(const fileName: wString; const ext: wString = '.txt'): wString;
function getLongPathName(shortPathName: wString): wString;
function SHGetMalloc(var ppMalloc: IMalloc): HResult; stdcall;
function SHGetDesktopFolder(var ppshf: IShellFolder): HResult; stdcall;
function SHBrowseForFolderA(var lpbi: TBrowseInfoA): PItemIDList; stdcall;
function SHBrowseForFolderW(var lpbi: TBrowseInfoW): PItemIDList; stdcall;
function SHGetPathFromIDListA(pidl: PItemIDList; pszPath: paChar): BOOL; stdcall;
function SHGetPathFromIDListW(pidl: PItemIDList; pszPath: pwChar): BOOL; stdcall;
function guiSelectDirectory(const caption, root: wString; var directory: wString; handle: hWnd = 0; flags: uint = BIF_RETURNONLYFSDIRS): bool;
function addBackSlash(const path: wString): wString;
function getTemporaryFileName(const prefix: wString = 'una'): wString;
function SHGetSpecialFolderPathA(owner: HWND; lpszPath: paChar; nFolder: int; fCreate: BOOL): BOOL; stdcall;
function SHGetSpecialFolderPathW(owner: HWND; lpszPath: pwChar; nFolder: int; fCreate: BOOL): BOOL; stdcall;
function getSpecialFolderPath(nFolder: int; owner: hWnd = 0; doCreate: bool = false): wString;
function getAppDataFolderPath(owner: hWnd = 0; doCreate: bool = false): wString;
function hostName(): wString;
procedure findFiles(const path, mask: wString; callback: proc_ffcallback; includeSubfolders: bool = false; sender: pointer = nil);
function folderRemoveFiles(const path: wString; includeSubfolders: bool = false; const mask: wString = '*.*'; removeSubfoldersAsWell: bool = false; SFONLY: bool = false; const omask: wString = ''): bool;
function folderRemove(const path: wString): bool;
function paramStrW(index: unsigned): wString;
function hasSwitch(const name: string; caseSensitive: bool = false): bool;
function switchValue(const name: string; caseSensitive: bool = false; defValue: int = 0): int; overload;
function switchValue(const name: string; caseSensitive: bool = false; const defValue: string = ''): string; overload;
function switchFileName(var index: int; mustExists: bool = true): wString;
function getDiskSpace(const path: wString; index: int): int64;
function bool2int(value: bool): int;
function int2bool(value: int): bool;
function bool2str(value: bool): string;
function bool2strStr(value: bool): string;
function ptr2str(value: pointer): string;
function int2str(value: int; base: unsigned = 10; split: unsigned = 0; splitchar: char = ' '): string; overload;
function int2str(const value: int64; base: unsigned = 10; split: unsigned = 0; splitchar: char = ' '): string; overload;
function int2str(value: unsigned; base: unsigned = 10; split: unsigned = 0; splitchar: char = ' '): string; overload;
function int2str(value: word; base: unsigned = 10; split: unsigned = 0; splitchar: char = ' '): string; overload;
function byteArray2str(value: pArray; count: int): string;
function intArray2str(value: pInt32Array): string;
function str2bool(const value: string; defValue: bool = false): bool;
function strStr2bool(const value: string; defValue: bool = false): bool;
function str2intByte(const value: string; defValue: byte = 0; base: unsigned = 10; ignoreTrails: bool = false): byte;
function str2intInt(const value: string; defValue: int = 0; base: unsigned = 10; ignoreTrails: bool = false): int;
function str2intUnsigned(const value: string; defValue: unsigned = 0; base: unsigned = 10; ignoreTrails: bool = false): unsigned;
function float2str(const value: extended): string;
function str2intInt64(const value: string; defValue: int64 = 0; base: unsigned = 10; ignoreTrails: bool = false): int64; overload;
function str2intInt64(value: pChar; maxLen: int; defValue: int64 = 0; base: unsigned = 10; ignoreTrails: bool = false): int64; overload;
function str2intArray(const value: string; subLevel: int = 0): pInt32Array;
function newGUID(): string;
function sameGUIDs(const g1, g2: tGuid): bool;
procedure ms2time(ms: int64; out dd, hh, mm, ss, mss: unsigned);
function encodeTime(hh, mm, ss, ms: unsigned): tDateTime;
function ms2dateTime(ms: int64): tDateTime;
function dateTime2b64str(const dateTime: tDateTime): string;
function b64str2dateTime(const date: string; const defValue: tDateTime = 0): tDateTime;
function sysTime2str(time: pSYSTEMTIME = nil; const format: wString = ''; locale: LCID = LOCALE_USER_DEFAULT; flags: DWORD = LOCALE_NOUSEROVERRIDE or TIME_NOSECONDS): wString; overload;
function sysTime2str(const time: SYSTEMTIME; const format: wString = ''; locale: LCID = LOCALE_USER_DEFAULT; flags: DWORD = LOCALE_NOUSEROVERRIDE or TIME_NOSECONDS): wString; overload;
function sysDate2str(date: pSYSTEMTIME = nil; const format: wString = ''; locale: LCID = LOCALE_USER_DEFAULT; flags: DWORD = 0): wString;
function sysDateTime2localDateTime(const sysDate: SYSTEMTIME; out localDate: SYSTEMTIME): bool;
function nowUTC(): SYSTEMTIME;
function utc2local(const dateTime: SYSTEMTIME): SYSTEMTIME;
function monthsPassed(const now, than: SYSTEMTIME): int;
function stDate2str(const st: SYSTEMTIME): string;
function stDateTime2str(const st: SYSTEMTIME): string;
function str2st(const date: string; out st: SYSTEMTIME): HRESULT;
function isLeapYear(y: int): boolean;
function percent(value, total: unsigned): unsigned; overload;
function percent(value, total: int64): int64; overload;
function trimS(const value: string; left: bool = true; right: bool = true): string; overload;
function lCase(value: char): char; overload;
function uCase(value: char): char; overload;
function loCase(const value: string): string; overload;
function upCase(const value: string): string; overload;
function compareStr(const str1, str2: string; ignoreCase: bool = false): int; overload;
function sameString(const str1, str2: string; doTrim: bool = true): bool; overload;
function revStr(const a: string): string;
function adjust(const value: string; len: int; fill: char = ' '; left: bool = true; truncate: bool = false): string; overload;
function padChar(pad: char; len: unsigned): string; overload;
function padChar(pad: aChar; len: unsigned): aString; overload;
function strCopy(dest, source: pChar; maxLen: int = -1): pChar; overload;
function strCopy(dest, source: paChar; maxLen: int = -1): paChar; overload;
function strCopyS(dest: pChar; const source: string; maxLen: int = -1): pChar; overload;
function strCopyS(dest: paChar; const source: aString; maxLen: int = -1): paChar; overload;
function strNew(const source: string): pChar; overload;
function strNew(const source: aString): paChar; overload;
function strNewA(str: paChar): paChar;
function str2arrayA(const src: aString; var A: array of aChar): int;
function str2arrayW(const src: wString; var A: array of wChar): int;
function array2strA(const A: array of aChar; out value: aString; startPos: int = low(int); length: int = -1): int;
function array2strW(const A: array of wChar; out value: wString; startPos: int = low(int); length: int = -1): int;
function array2str(const A: array of wChar; out value: wString; maxArrayLength: int = -1): int;
function strAllocA(size: uint): paChar;
function strDisposeA(var str: paChar): bool;
function strDisposeW(var str: pwChar): bool;
function strLenA(str: paChar): unsigned;
function strScanA(const str: paChar; chr: aChar): paChar;
function strPosA(const strSource, strToFind: paChar): paChar;
function lastDelimiter(const delimiters, s: wString): int;
function strEscape(const value: string; const specialCare: string = ''): string;
function strUnescape(const value: string): string;
function htmlEscape(const value: aString; strict: bool = true): aString;
function urlEncodeA(const value: aString): aString;
function urlDecodeA(const value: aString): aString;
function urlEncodeW(const value: wString): wString;
function urlDecodeW(const value: wString): wString;
function urlEncode(const value: string): string;
function urlDecode(const value: string): string;
function formatTemplate(const templ: string; const vars: string; unescapeVars: bool = true): string;
function nextToken(const text: wString; var startPos: int): wString;
function replaceTokens(var text: aString; const tokens: aString): int; overload;
function replaceTokens(var text: aString; const tokens: aString; var careSelStart: int): int; overload;
function replaceTokens(var text: wString; const tokens: wString; var careSelStart: int): int; overload;
function getIntValueFromStr(const str, paramName: string; defValue: int): int;
function guiMessageBox(owner: hWnd; const message, title: wString; flags: int = MB_OK): int; overload;
function guiMessageBox(const message, title: wString; flags: int = MB_OK; owner: hWnd = 0): int; overload;
function ShellAboutA(Wnd: HWND; szApp, szOtherStuff: paChar; Icon: HICON): Integer; stdcall;
function ShellAboutW(Wnd: HWND; szApp, szOtherStuff: pwChar; Icon: HICON): Integer; stdcall;
function guiAboutBox(const appName, otherStuff: wString; handle: tHandle = 0; icon: hIcon = $FFFFFFFF): int;
function getModuleFileNameExt(const ext: wString): wString;
function getModulePathName(const fileName: wString = ''): wString;
function assertLogMessage(const message: string; logToScreen: int = -1; logToFile: int = -1; logTimeMode: unaInfoMessage_logTimeModeEnum = unaLtm_default; logMemoryInfo: int = -1; logThreadId: int = -1): bool;
function infoMessage(const message: string; logToScreen: int = -1; logToFile: int = -1; logTimeMode: unaInfoMessage_logTimeModeEnum = unaLtm_default; logMemoryInfo: int = -1; logThreadId: int = -1; flags: int = 0): bool;
function logMessage(const message: string = ''; flags: int = c_logModeFlags_normal; logToScreen: int = -1; logToFile: int = -1; logTimeMode: unaInfoMessage_logTimeModeEnum = unaLtm_default; logMemoryInfo: int = -1; logThreadId: int = -1): bool;
function setInfoMessageMode(const logName: wString = ''; proc: infoMessageProc = nil; logToScreen: int = -1; logToFile: int = -1; logTimeMode: unaInfoMessage_logTimeModeEnum = unaLtm_default; logMemoryInfo: int = -1; logThreadId: int = -1; useWideStrings: bool = false; useSysTime: int = -1): wString;
function color2str(color: int): string;
function color2rgb(color: int): tRGB;
function colorShift(color: int; op: tunaColorOp): int;
function getRegValue(const path: aString; const keyName: aString; var buf; var size: DWORD; rootKey: HKEY = HKEY_CURRENT_USER): long; overload;
function setRegValue(const path: aString; const keyName: aString; const buf; size: DWORD; keyType: int; rootKey: HKEY = HKEY_CURRENT_USER): long; overload;
function getRegValue(const path: aString; const keyName: aString = ''; defValue: int = 0; rootKey: HKEY = HKEY_CURRENT_USER): int; overload;
function getRegValue(const path: aString; const keyName: aString = ''; defValue: unsigned = 0; rootKey: HKEY = HKEY_CURRENT_USER): unsigned; overload;
function setRegValue(const path: aString; const keyName: aString = ''; keyValue: int = 0; rootKey: HKEY = HKEY_CURRENT_USER): long; overload;
function setRegValue(const path: aString; const keyName: aString = ''; keyValue: unsigned = 0; rootKey: HKEY = HKEY_CURRENT_USER): long; overload;
function getRegValue(const path: aString; const keyName: aString = ''; const defValue: aString = ''; rootKey: HKEY = HKEY_CURRENT_USER): aString; overload;
function setRegValue(const path: aString; const keyName: aString = ''; const keyValue: aString = ''; rootKey: HKEY = HKEY_CURRENT_USER): long; overload;
function setRegValueW(const path: wString; const keyName: wString = ''; const keyValue: wString = ''; rootKey: HKEY = HKEY_CURRENT_USER): long; overload;
function enableAutorun(doEnable: bool = true; const appPath: wString = ''): bool;
function processMessages(wnd: hWnd = 0): unsigned;
function execApp(const moduleAndParams: wString = ''; waitForExit: bool = true; showFlags: WORD = SW_SHOW; redirectFromWOW64: bool = false): int; overload;
function execApp(const module: wString; const params: wString = ''; waitForExit: bool = true; showFlags: WORD = SW_SHOW; redirectFromWOW64: bool = false): int; overload;
function locateProcess(var procEntryW: PROCESSENTRY32W; const exeName: wString = ''): bool;
function locateProcesses(var procEntriesW: pprocessEntryArrayW; const exeName: wString = ''): int;
function windowsEnum(var wnds: pHandleArray): unsigned;
function windowGetFirstChild(parent: hWnd): hWnd;
function getProcessWindows(var wnds: pHandleArray; processId: unsigned = 0): unsigned;
function checkIfDuplicateProcess(doFlashWindow: bool = true): unsigned; overload;
function checkIfDuplicateProcess(const mutexName: wString; var mutex: tHandle; closeIfFound: bool = true): bool; overload;
function setPriority(value: int): int;
function getPriority(): int;
function putIntoClipboard(const data: aString; window: hWnd = 0): int;
function getNumCores(): int;
function ams(): int;
procedure mfill16(mem: pointer; count: unsigned; value: uint16 = 0);
function malloc(size: unsigned; doFill: bool = false; fill: byte = 0): pointer; overload;
function malloc(size: unsigned; data: pointer): pointer; overload;
procedure mrealloc(var data; newSize: unsigned = 0);
function mcompare(p1, p2: pointer; size: unsigned): bool;
function mscanb(buf: pointer; count: unsigned; value: uint8): pointer;
function mscanw(buf: pointer; count: unsigned; value: uint16): pointer;
function mscand(buf: pointer; count: unsigned; value: uint32): pointer;
function mscanp(buf: pointer; value: pointer; len: unsigned): pointer;
function mscanq(buf: pointer; count: unsigned; const value: int64): pointer;
function mscanbuf(buf: pointer; bufSize: unsigned; value: pointer; valueLen: unsigned): pointer;
procedure mswapbuf16(buf: pointer; len: int);
function swap16u(w: uint16): uint16;
function swap16i(w: int16): int16;
function swap32u(w: uint32): uint32;
function swap32i(w: int32): int32;
function swap64u(w: uint64): uint64;
function swap64i(w: int64): int64;
procedure freeAndNil(var objRef);
function waitForObject(handle: tHandle; timeout: tTimeout = 1): bool;
function _acquire32(var a: unaAcquireType): bool;
function acquire32Exclusive(var a: unaAcquireType): bool;
function acquire32NonExclusive(var a: unaAcquireType): bool;
procedure acquire32NE(var a: unaAcquireType);
function acquire32(var a: unaAcquireType; timeout: tTimeout): bool; overload;
function release32(var a: unaAcquireType): bool;
function hrpc_timeMark(): int64;
function hrpc_timeElapsed32(mark: int64): unsigned;
function hrpc_timeElapsed64(mark: int64): int64;
function hrpc_timeElapsed64ticks(mark: int64): int64;
function gtc(): uint64;
procedure markGTCLoop(loop: uint64);
function timeMarkU(): uint64;
function timeElapsed32U(mark: uint64): uint32;
function timeElapsed64U(mark: uint64): uint64;
function timeElapsedU(mark: uint64): unsigned;
function sanityCheck(var mark: uint64; maxSlice: unsigned = 300; sleepSlice: unsigned = 20; careMessages: bool = true): bool;
function sanityCheck64(var mark: uint64; maxSlice: int64 = 300000; sleepSlice: unsigned = 20; careMessages: bool = false): bool;
function getSysErrorText(errorCode: DWORD = 0; avoidGetCall: bool = false; includeErorCode: bool = true): wString;
function choice(value: bool; true_choice: char = ' '; false_choice: char = ' '): char; overload;
function choice(value: bool; true_choice: aChar = ' '; false_choice: aChar = ' '): aChar; overload;
function choice(value: bool; true_choice: int = 1; false_choice: int = 0): int; overload;
function choice(value: bool; true_choice: unsigned = 1; false_choice: unsigned = 0): unsigned; overload;
function choice(value: bool; const true_choice: string; const false_choice: string = ''): string; overload;
function choice(value: bool; const true_choice: aString; const false_choice: aString = ''): aString; overload;
function choice(value: bool; true_choice: boolean = true; false_choice: boolean = false): bool; overload;
function choice(value: bool; true_choice: tObject = nil; false_choice: tObject = nil): tObject; overload;
function choice(value: bool; true_choice: pointer = nil; false_choice: pointer = nil): pointer; overload;
function choiceD(value: bool; const true_choice: double = 0; false_choice: double = 0): double;
function choiceE(value: bool; const true_choice: extended = 0; false_choice: extended = 0): extended;
function gcd(a, b: unsigned): unsigned;
function getNullDacl(): PSecurityAttributes;

Types

TFNBFFCallBack = type BFFCALLBACK;
PBrowseInfoA = ˆTBrowseInfoA;
PBrowseInfoW = ˆTBrowseInfoW;
TBrowseInfoA = _browseinfoA;
BROWSEINFOA = _browseinfoA;
TBrowseInfoW = _browseinfoW;
BROWSEINFOW = _browseinfoW;
proc_ffcallback = function(sender: pointer; const path: wString; const fdw: WIN32_FIND_DATAW): bool;
tDayTable = array[1..12] of byte;
unaInfoMessage_logTimeModeEnum = (...);
infoMessageProc = procedure(const message: string);
pRGB = ˆtRGB;
tunaColorOp = (...);
PROCESSENTRY32W = tagPROCESSENTRY32W;
PPROCESSENTRY32W = ˆtagPROCESSENTRY32W;
LPPROCESSENTRY32W = ˆtagPROCESSENTRY32W;
TProcessEntry32W = tagPROCESSENTRY32W;
pprocessEntryArrayW = ˆprocessEntryArrayW;
processEntryArrayW = array[byte] of PROCESSENTRY32W;
pHandleArray = ˆhandleArray;
handleArray = array[byte] of tHandle;

Constants

BFFM_ENABLEOK = WM_USER + 101;
BFFM_INITIALIZED = 1;
BFFM_SELCHANGED = 2;
BFFM_SETSELECTION = BFFM_SETSELECTIONA;
BFFM_SETSELECTIONA = WM_USER + 102;
BFFM_SETSELECTIONW = WM_USER + 103;
BFFM_SETSTATUSTEXT = BFFM_SETSTATUSTEXTA;
BFFM_SETSTATUSTEXTA = WM_USER + 100;
BFFM_SETSTATUSTEXTW = WM_USER + 104;
BFFM_VALIDATEFAILED = BFFM_VALIDATEFAILEDA;
BFFM_VALIDATEFAILEDA = 3;
BFFM_VALIDATEFAILEDW = 4;
BIF_BROWSEFORCOMPUTER = $1000;
BIF_BROWSEFORPRINTER = $2000;
BIF_BROWSEINCLUDEFILES = $4000;
BIF_BROWSEINCLUDEURLS = $0080;
BIF_DONTGOBELOWDOMAIN = $0002;
BIF_EDITBOX = $0010;
BIF_NEWDIALOGSTYLE = $0040;
BIF_RETURNFSANCESTORS = $0008;
BIF_RETURNONLYFSDIRS = $0001;
BIF_SHAREABLE = $8000;
BIF_STATUSTEXT = $0004;
BIF_USENEWUI = BIF_NEWDIALOGSTYLE or BIF_EDITBOX;
BIF_VALIDATE = $0020;
CSIDL_ADMINTOOLS = $0030;
CSIDL_ALTSTARTUP = $001d;
CSIDL_APPDATA = $001a;
CSIDL_BITBUCKET = $000a;
CSIDL_CDBURN_AREA = $003b;
CSIDL_COMMON_ADMINTOOLS = $002f;
CSIDL_COMMON_ALTSTARTUP = $001e;
CSIDL_COMMON_APPDATA = $0023;
CSIDL_COMMON_DESKTOPDIRECTORY = $0019;
CSIDL_COMMON_DOCUMENTS = $002e;
CSIDL_COMMON_FAVORITES = $001f;
CSIDL_COMMON_MUSIC = $0035;
CSIDL_COMMON_PICTURES = $0036;
CSIDL_COMMON_PROGRAMS = $0017;
CSIDL_COMMON_STARTMENU = $0016;
CSIDL_COMMON_STARTUP = $0018;
CSIDL_COMMON_VIDEO = $0037;
CSIDL_COMPUTERSNEARME = $003d;
CSIDL_CONNECTIONS = $0031;
CSIDL_CONTROLS = $0003;
CSIDL_COOKIES = $0021;
CSIDL_DESKTOP = $0000;
CSIDL_DESKTOPDIRECTORY = $0010;
CSIDL_DRIVES = $0011;
CSIDL_FAVORITES = $0006;
CSIDL_FLAG_CREATE = $8000;
CSIDL_FONTS = $0014;
CSIDL_HISTORY = $0022;
CSIDL_INTERNET = $0001;
CSIDL_INTERNET_CACHE = $0020;
CSIDL_LOCAL_APPDATA = $001c;
CSIDL_MYPICTURES = $0027;
CSIDL_NETHOOD = $0013;
CSIDL_NETWORK = $0012;
CSIDL_PERSONAL = $0005;
CSIDL_PRINTERS = $0004;
CSIDL_PRINTHOOD = $001b;
CSIDL_PROFILE = $0028;
CSIDL_PROFILES = $003e;
CSIDL_PROGRAMS = $0002;
CSIDL_PROGRAM_FILES = $0026;
CSIDL_PROGRAM_FILES_COMMON = $002b;
CSIDL_RECENT = $0008;
CSIDL_SENDTO = $0009;
CSIDL_STARTMENU = $000b;
CSIDL_STARTUP = $0007;
CSIDL_SYSTEM = $0025;
CSIDL_TEMPLATES = $0015;
CSIDL_WINDOWS = $0024;
CSTR_EQUAL = 2;
CSTR_GREATER_THAN = 3;
CSTR_LESS_THAN = 1;
c_logModeFlags_critical = $0001;
c_logModeFlags_debug = $0004;
c_logModeFlags_normal = $0002;
monthDays: array [boolean] of tDayTable = ((31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31), (31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31));
REGSTR_PATH_EXPLORER = 'Software\Microsoft\Windows\CurrentVersion\Explorer';
REGSTR_PATH_SPECIAL_FOLDERS = REGSTR_PATH_EXPLORER + '\Shell Folders';
unicodeHighSurrogateEnd = $DBFF;
unicodeHighSurrogateStart = $D800;
unicodeLowSurrogateEnd = $DFFF;
unicodeLowSurrogateStart = $DC00;
WM_USER = $0400;
zeroWidthNonBreakingSpace = $FEFF;
zeroWidthNonBreakingSpaceUTF8 = #$EF#$BB#$BF;
zeroWidthNonBreakingSpaceW = wChar(zeroWidthNonBreakingSpace);

Variables

g_isWOW64: bool;
g_OSVersion: OSVERSIONINFOW;
hrpc_Freq: int64 = 0;
hrpc_FreqFail: bool = false;
hrpc_FreqMs: int64 = 0;

Description

Functions and Procedures

function min(A, B: int): int; overload;

Returms minimal value of two signed integers.

Returns

A if A < B, or B otherwise.

function min(A, B: unsigned): unsigned; overload;

Returms minimal value of two unsigned integers.

Returns

A if A < B, or B otherwise.

function min(A, B: int64): int64; overload;

Returms minimal value of two signed 64 bits integers.

Returns

A if A < B, B otherwise.

function max(A, B: int64): int64; overload;

Returns maximal value of two signed 64 bits integers.

Returns

A if A > B, B otherwise.

function max(A, B: int): int; overload;

Returns maximal value of two signed integers.

Returns

A if A > B, B otherwise.

function max(A, B: unsigned): unsigned; overload;

Returns maximal value of two unsigned integers.

Returns

A if A > B, B otherwise.

function max(A, B: double): double; overload;

Returns maximal value of two floating-point.

Returns

A if A > B, B otherwise.

function sshl(v: int; c: int): int;

signed shift left

function sshr(v: int; c: int): int;

signed shift right

function base64encode(data: pointer; size: unsigned): aString; overload;

Encodes data with base64 method.

Parameters
data
Data to be encoded.
len
Size of buffer pointed by data.
Returns

Encoded value as string.

function base64encode(const data: aString): aString; overload;

Encodes string with base64 method.

Parameters
data
String of bytes to be encoded.
Returns

Encoded value as string.

function base64decode(const data: aString): aString; overload;

Decodes string encoded with base64 method.

Parameters
data
String of bytes to be decoded.
Returns

Decoded value as string.

function base64decode(data: pointer; len: unsigned): aString; overload;

Decodes data encoded with base64 method.

Parameters
data
Data to be decoded.
len
Size of buffer pointed by data.
Returns

Decoded value as string.

function base64decode(const data: aString; out buf: pointer): unsigned; overload;

Decodes string encoded with base64 method. NOTE: buf will be allocated (not reallocated!).

Parameters
data
String of bytes to be decoded.
buf
Output buffer. Use mrealloc() to deallocate memory pointed by buf.
Returns

Number of bytes in output buffer.

function crc32(const data: aString; crc: uint32 = $FFFFFFFF): uint32; overload;

Calculates CRC32 checksum. Based on Hagen Reddmann code. NOTE: It is not fully compatible with standard CRC32!

Parameters
data
String of bytes to calculate CRC32 of.
crc
Initial CRC value, do not change.
Returns

CRC32 value.

function crc32(data: pointer; len: unsigned; crc: uint32 = $FFFFFFFF): uint32; overload;

Calculates CRC32 checksum. Based on Hagen Reddmann code. NOTE: It is not fully compatible with standard CRC32!

Parameters
data
Pointer to array of bytes to calculate CRC32 of.
len
Size of array pointed by data.
crc
Initial CRC value, do not change.
Returns

CRC32 value.

function crc16(data: pointer; len: unsigned): uint16;

Calculates "CRC16" checksum. CRC16 is defined as "(crc shr 16) xor (crc and $FFFF)" where crc is standard CRC32 value.

Parameters
data
Pointer to array of bytes to calculate CRC16 of.
len
Size of array pointed by data.
Returns

CRC16 value.

function crc8(data: pointer; len: unsigned): uint8;

Calculates "CRC8" checksum.

Parameters
data
Pointer to array of bytes to calculate CRC8 of.
len
Size of array pointed by data.
Returns

CRC8 value.

function crc4(data: pointer; len: unsigned): uint8;

Calculates "CRC4" checksum.

Parameters
data
Pointer to array of bytes to calculate CRC4 of.
len
Size of array pointed by data.
Returns

CRC4 value.

function cp2UTF8(cp: uint32): aString;
 
function highSurrogate(cp: uint32): uint16;
 
function lowSurrogate(cp: uint32): uint16;
 
function isHighSurrogate(w: uint16): bool;
 
function isLowSurrogate(w: uint16): bool;
 
function surrogate2cp(highSurrogate, lowSurrogate: uint16): uint32;
 
function UTF162UTF8(const w: wString): aString;

Converts UCS-2 to UTF-8 string.

Parameters
w
UTF16 string.
Returns

UTF8 string.

function UTF82UTF16(const s: aString): wString;

Converts UTF-8 to low-endian UCS-2 string.

Parameters
s
UTF-8 string to be converted.
Returns

UCS-2 string.

function wide2ansi(const w: wString; cp: unsigned = CP_ACP): aString;

Converts multi-byte string into ANSI string using wCharToMultiByte().

Parameters
w
Multi-byte string to be converted.
cp
code page to use for conversion, default is CP_ACP.
Returns

ANSI string (single-byte string).

function ReadFile(hFile: tHandle; buffer: pointer; nNumberOfBytesToRead: DWORD; lpNumberOfBytesRead: LPDWORD; lpOverlapped: POVERLAPPED): BOOL; stdcall;

FILES

Borland had "misspelled" the declarations of the below functions a little, so we re-define them here.

function WriteFile(hFile: tHandle; buffer: pointer; nNumberOfBytesToWrite: DWORD; lpNumberOfBytesWritten: LPDWORD; lpOverlapped: POVERLAPPED): BOOL; stdcall;
 
function fileSize2str(sz: int64): string;

Returns nice string representing file size.

Parameters
sz
File size.
Returns

String representation of sz.

function fileExists(const name: wString): bool;

Checks if specified file exists.

Parameters
name
File name.
Returns

True if specified file exists.

function fileCreate(const name: wString; truncate: bool = true; leaveOpen: bool = false; flags: DWORD = 0): tHandle;

Creates a file. If file already exists, truncates it to zero-length file (if truncate is true).

Parameters
name
Name of file to be created (opened).
truncate
True if existing file must be truncated afer opening (default is True).
leaveOpen
Do not close file handle after creation (default is False).
flags
Creation flags (refer to MSDN for details).
Returns

file handle if file was created successfully, and leaveOpen was True.

function fileOpen(const name: wString; wantWrites: bool = false; allowSharedWrites: bool = true; flags: DWORD = FILE_ATTRIBUTE_NORMAL): tHandle;

Opens a file.

Parameters
name
Name of file to be opened.
wantWrites
Try to open a file with WRITE access if True, or READONLY if False (default is False).
allowSharedWrites
Allow others to write to opened file (default is True).
flags
Any additional flags. For example, specify FILE_FLAG_BACKUP_SEMANTICS flag when opening directories.
Returns

INVALID_HANDLE_VALUE if file does not exist, or some other error occured, valid file handle otherwise.

function fileClose(f: tHandle): bool;

Closes file handle.

function fileTruncate(handle: tHandle; pos: unsigned = 0; posMode: unsigned = FILE_BEGIN): bool;

Truncates file at specified position.

Returns

False if truncation has been failed for some reason.

function writeToFile(const name: wString; buf: pointer; size: unsigned; pos: unsigned = 0; posMode: unsigned = FILE_END): int; overload;

Writes data into a file specified by name at specified position. Creates the file if it does not exists.

Returns

-4 if number of bytes written does not equal to given size.

function writeToFile(const name: wString; const buf: aString; pos: unsigned = 0; posMode: unsigned = FILE_END): int; overload;

Writes data into a file specified by name at specified position. Creates the file if it does not exists.

Returns

-4 if number of bytes written does not equal to given size.

function writeToFile(handle: tHandle; buf: pointer; size: unsigned; pos: unsigned = 0; posMode: unsigned = FILE_CURRENT): int; overload;

Writes data into a file specified by handle at specified position. Creates the file if it does not exists.

Returns

-4 if number of bytes written does not equal to given size.

function writeToFile(handle: tHandle; const buf: aString; pos: unsigned = 0; posMode: unsigned = FILE_CURRENT): int; overload;

Writes data into a file specified by handle at specified position. Creates the file if it does not exists.

Returns

-4 if number of bytes written does not equal to given size.

function readFromFile(const name: wString; buf: pointer; var size: unsigned; pos: unsigned = 0; posMode: unsigned = FILE_BEGIN): int; overload;

Reads data from a file specified by name at specified position.

Parameters
name
File name.
buf
Buffer to place data into.
size
Number of bytes to read. Buffer must be at least of that size. This parameter will be set to number of bytes actually read from the file, or to 0 if some error has occured.
pos
Offset in file to read data from (actual offset depends on posMode).
posMode
How to calculate the real offset in the file (default is FILE_BEGIN, refer to MSDN for mode details).
Returns

size parameter will be set to number of bytes actually read from the file, or to 0 if some error occured.

function readFromFile(const name: wString; pos: unsigned = 0; posMode: unsigned = FILE_BEGIN; len: int64 = 0): aString; overload;

Reads data from a file specified by name at specified position.

Parameters
name
File name.
pos
Offset in file to read data from (actual offset depends on posMode).
posMode
How to calculate the real offset in the file (default is FILE_BEGIN, refer to MSDN for mode details).
len
How many bytes to read (default is 0, means read all the file).
Returns

Read data as string of bytes.

function readFromFile(handle: tHandle; buf: pointer; var size: unsigned; pos: unsigned = 0; posMode: unsigned = FILE_CURRENT): int; overload;

Reads data from a file specified by handle at specified position.

Parameters
handle
File handle.
buf
Buffer to place data into.
size
Number of bytes to read. Buffer must be at least of that size. Will be set to number of bytes actually read from the file, or to 0 if some error has occured.
pos
Offset in file to read data from (actual offset depends on posMode).
posMode
How to calculate the real offset in the file (default is FILE_CURRENT, refer to MSDN for mode details).
Returns

-4 if number of bytes read does not equal to given size (file is too short). Not a fatal error in most cases.

function fileSize(const name: wString): int64; overload;
 
Returns

file size in bytes, or -1 if file does not exists.

function fileSize(handle: tHandle): int64; overload;
 
Returns

file size in bytes, or -1 if file does not exists.

function fileSeek(handle: tHandle; pos: int = 0; posMode: unsigned = FILE_BEGIN): int;

Seeks the file to specified position.

Returns

Resulting file position or -1 if file handle is invalid.

function fileMove(const oldName, newName: wString): bool;

Renames the file.

function fileCopy(const oldName, newName: wString; failIfExists: bool): bool;

Copies the file content to a new file.

function fileDelete(const fileName: wString): bool;

Removes the file.

function fileChecksum(f: tHandle; crc: uint32 = $FFFFFFFF): uint32; overload;

Calculates CRC32 checksum of a file.

function fileChecksum(const fileName: wString): uint32; overload;

Calculates CRC32 checksum of a file.

function fileModificationDateTime(const fileName: wString; useLocalTime: bool = true): SYSTEMTIME; overload;

Returns file modification time.

function fileModificationDateTime(f: tHandle; useLocalTime: bool = true): SYSTEMTIME; overload;

Returns file modification time.

function fileCreationDateTime(const fileName: wString; useLocalTime: bool = true): SYSTEMTIME; overload;

Returns file creation time.

function fileCreationDateTime(f: tHandle; useLocalTime: bool = true): SYSTEMTIME; overload;

Returns file creation time.

function directoryExists(const name: wString): bool;

Returns True if specified directory exists.

function forceDirectories(const path: wString): bool;

Ensures that specified path exists. Recursively creates directories as required.

function extractFilePath(const fileName: wString): wString;

Returns file path (without file name).

function extractFileName(const fileName: wString): wString;

Returns file name (without file path).

function changeFileExt(const fileName: wString; const ext: wString = '.txt'): wString;

Replaces the file extension with given one.

function getLongPathName(shortPathName: wString): wString;

Expands short file name to long one.

function SHGetMalloc(var ppMalloc: IMalloc): HResult; stdcall;
 
function SHGetDesktopFolder(var ppshf: IShellFolder): HResult; stdcall;
 
function SHBrowseForFolderA(var lpbi: TBrowseInfoA): PItemIDList; stdcall;
 
function SHBrowseForFolderW(var lpbi: TBrowseInfoW): PItemIDList; stdcall;
 
function SHGetPathFromIDListA(pidl: PItemIDList; pszPath: paChar): BOOL; stdcall;
 
function SHGetPathFromIDListW(pidl: PItemIDList; pszPath: pwChar): BOOL; stdcall;
 
function guiSelectDirectory(const caption, root: wString; var directory: wString; handle: hWnd = 0; flags: uint = BIF_RETURNONLYFSDIRS): bool;

Opens directory selection dialog.

Parameters
caption
Dialog caption.
root
Root folder to build tree from.
directory
Start brofsing from this directory ('' = root). Returns selected directory if selection was successfull.
handle
Handle of parent window.
flags
Flags for the dialog.
Returns

True if selection was successfull.

function addBackSlash(const path: wString): wString;

Ensures you can safely add a file name to the given path. Adds '\' character to the end of path as necessary. Exaples: C:\temp\ => C:\temp\ C:\temp => C:\temp\ C:\ => C:\ C: => C: C:\temp/ => C:\temp/

function getTemporaryFileName(const prefix: wString = 'una'): wString;

Returns temporary file name.

function SHGetSpecialFolderPathA(owner: HWND; lpszPath: paChar; nFolder: int; fCreate: BOOL): BOOL; stdcall;
 
function SHGetSpecialFolderPathW(owner: HWND; lpszPath: pwChar; nFolder: int; fCreate: BOOL): BOOL; stdcall;
 
function getSpecialFolderPath(nFolder: int; owner: hWnd = 0; doCreate: bool = false): wString;

Returns special folder path.

function getAppDataFolderPath(owner: hWnd = 0; doCreate: bool = false): wString;

Returns Application Data folder path.

function hostName(): wString;
 
Returns

host name.

procedure findFiles(const path, mask: wString; callback: proc_ffcallback; includeSubfolders: bool = false; sender: pointer = nil);

Finds all files according to path and mask, optionally travelling in subdirs. For each file or subfolder found it calls the specified callback routime.

function folderRemoveFiles(const path: wString; includeSubfolders: bool = false; const mask: wString = '*.*'; removeSubfoldersAsWell: bool = false; SFONLY: bool = false; const omask: wString = ''): bool;

Removes all files in a folder (and optionally subfolders) according to file mask specified. All empty subfolders may be removed too, making it easy to clean up all contect of a folder. SFONLY and omask are internal parameters and must not be specified.

function folderRemove(const path: wString): bool;

Returns True if folder was successfully removed. Folder must not contain subfolders or files. Use folderRemoveFiles() to remove subfolders and/or files.

function paramStrW(index: unsigned): wString;

Returns specified (by index) command line parameter as wide string.

function hasSwitch(const name: string; caseSensitive: bool = false): bool;

Returns True if command line contains given switch.

function switchValue(const name: string; caseSensitive: bool = false; defValue: int = 0): int; overload;

Returns value of a given command line switch.

function switchValue(const name: string; caseSensitive: bool = false; const defValue: string = ''): string; overload;
 
function switchFileName(var index: int; mustExists: bool = true): wString;

Returns a possible file name specified in parameters.

function getDiskSpace(const path: wString; index: int): int64;

index means: 0 - FreeBytesAvailable 1 - TotalNumberOfBytes 2 - TotalNumberOfFreeBytes

function bool2int(value: bool): int;

Converts boolean value to integer. Returns 0 if value = false and 1 otherwise.

function int2bool(value: int): bool;

Converts integer value to boolean. Returns false if value = 0 and true otherwise.

function bool2str(value: bool): string;

Converts boolean value to string. Returns '0' if value = false and '1' otherwise.

function bool2strStr(value: bool): string;

Converts boolean value to string. Returns 'false' if value = false and 'true' otherwise.

function ptr2str(value: pointer): string;

Converts pointer value to string. See int2str(int) for description of other parameters.

function int2str(value: int; base: unsigned = 10; split: unsigned = 0; splitchar: char = ' '): string; overload;

Converts integer value to a string. For example, when split = 3 and splitchar is ' ', instead of '12345' this function returns '12 345'.

Parameters
base
base for conversion (10 or 16 for example, max is 69).
split
if split > 0, the result will be divided on groups of digits, with at least split digits in every group.
splitchar
delimiter char used to separate one group from other (when split > 0).
function int2str(const value: int64; base: unsigned = 10; split: unsigned = 0; splitchar: char = ' '): string; overload;

Converts int64 value to a string. See int2str(int) for description of other parameters.

function int2str(value: unsigned; base: unsigned = 10; split: unsigned = 0; splitchar: char = ' '): string; overload;

Converts unsigned value to a string. See int2str(int) for description of other parameters.

function int2str(value: word; base: unsigned = 10; split: unsigned = 0; splitchar: char = ' '): string; overload;

Converts word value to string. See int2str(int) for description of other parameters.

function byteArray2str(value: pArray; count: int): string;

Converts array of bytes into hex string.

function intArray2str(value: pInt32Array): string;

Converts array of integer values into a comma-separated string. Assumes first [0] element contains number of items in array.

function str2bool(const value: string; defValue: bool = false): bool;

Converts string value to a boolean value.

Returns

False if value = '0' and true otherwise.

function strStr2bool(const value: string; defValue: bool = false): bool;

Converts string value to boolean.

Returns

true if value = 'true', false if value = 'false' and defValue otherwise.

function str2intByte(const value: string; defValue: byte = 0; base: unsigned = 10; ignoreTrails: bool = false): byte;

Converts string value to byte.

Returns

defValue if conversion fails.

function str2intInt(const value: string; defValue: int = 0; base: unsigned = 10; ignoreTrails: bool = false): int;

Converts string value to integer.

Returns

defValue if conversion fails.

function str2intUnsigned(const value: string; defValue: unsigned = 0; base: unsigned = 10; ignoreTrails: bool = false): unsigned;

Converts string value to unsigned.

Returns

defValue if conversion fails.

function float2str(const value: extended): string;

Simple version of float2str()

function str2intInt64(const value: string; defValue: int64 = 0; base: unsigned = 10; ignoreTrails: bool = false): int64; overload;

Converts string value to int64.

Returns

defValue if conversion fails.

function str2intInt64(value: pChar; maxLen: int; defValue: int64 = 0; base: unsigned = 10; ignoreTrails: bool = false): int64; overload;

Converts string value to int64.

Returns

defValue if conversion fails.

function str2intArray(const value: string; subLevel: int = 0): pInt32Array;

Converts comma-separated string into array of integer values.

Parameters
value
Comma-separated string.
subLevel
Internal, do not specify.
Returns

Pointer to new allocated array of integers (or nil).

function newGUID(): string;

Returns new GUID.

function sameGUIDs(const g1, g2: tGuid): bool;

Compares two GUIDs.

procedure ms2time(ms: int64; out dd, hh, mm, ss, mss: unsigned);

Converts milliseconds to days, hours, minutes, seconds and milliseconds.

function encodeTime(hh, mm, ss, ms: unsigned): tDateTime;

Encodes hours, minutes seconds and milliseconds to tDateTime value. Same as SysUtils.encodeTime() routine.

function ms2dateTime(ms: int64): tDateTime;

Converts milliseconds to tDateTime value

function dateTime2b64str(const dateTime: tDateTime): string;

Converts tDateTime value into string. Uses base64encode() to encode dateTime value.

function b64str2dateTime(const date: string; const defValue: tDateTime = 0): tDateTime;

Converts a string into tDateTime value. Uses base64dencode() to dencode date value.

function sysTime2str(time: pSYSTEMTIME = nil; const format: wString = ''; locale: LCID = LOCALE_USER_DEFAULT; flags: DWORD = LOCALE_NOUSEROVERRIDE or TIME_NOSECONDS): wString; overload;

Converts system time into a string.

function sysTime2str(const time: SYSTEMTIME; const format: wString = ''; locale: LCID = LOCALE_USER_DEFAULT; flags: DWORD = LOCALE_NOUSEROVERRIDE or TIME_NOSECONDS): wString; overload;

Converts system time into a string.

function sysDate2str(date: pSYSTEMTIME = nil; const format: wString = ''; locale: LCID = LOCALE_USER_DEFAULT; flags: DWORD = 0): wString;

Converts system date into a string.

function sysDateTime2localDateTime(const sysDate: SYSTEMTIME; out localDate: SYSTEMTIME): bool;

Converts system date/time from UTC into a local system date/time. Uses FileTimeToLocalFileTime().

function nowUTC(): SYSTEMTIME;

Returns current system time UTC timescale.

function utc2local(const dateTime: SYSTEMTIME): SYSTEMTIME;

Converts system date/time from UTC into a local system date/time. Uses SystemTimeToTzSpecificLocalTime().

function monthsPassed(const now, than: SYSTEMTIME): int;

Returns number of full months passed between two dates.

function stDate2str(const st: SYSTEMTIME): string;

Converts system date to string.

function stDateTime2str(const st: SYSTEMTIME): string;

Converts system date and time to string.

function str2st(const date: string; out st: SYSTEMTIME): HRESULT;
 
function isLeapYear(y: int): boolean;

Returns true if specified year is leap. Same as SysUtils.isLeapYear() routine.

function percent(value, total: unsigned): unsigned; overload;

Converts value and total into percentage. For example, if value is 1, and total is 50 result will be 2.

function percent(value, total: int64): int64; overload;

Converts value and total into percentage. For example, if value is 10, and total is 50 result will be 20.

function trimS(const value: string; left: bool = true; right: bool = true): string; overload;

Trims the specified value by removing all control or space characters from left (beginning) and right (ending) of the string.

function lCase(value: char): char; overload;

Plain simple lowercase for ASCII chars $00..$7F.

function uCase(value: char): char; overload;

Plain simple uppercase for ASCII chars $00..$7F.

function loCase(const value: string): string; overload;

Converts all character in given string into lower case.

function upCase(const value: string): string; overload;

Converts all character in given string into upper case.

function compareStr(const str1, str2: string; ignoreCase: bool = false): int; overload;

Compares two strings with regard (ignoreCase = False) or not (ignoreCase = True) to the case of characters in the string.

@return

  • 0 - strings are identical

  • -1 - str1 is shorter or lower then str2

  • +1 - str2 is shorter or lower then str1

NOTE: only Latin characters from ASCII table are converted when ignoreCase = true.

function sameString(const str1, str2: string; doTrim: bool = true): bool; overload;
 
function revStr(const a: string): string;

Reverses characters in a string

function adjust(const value: string; len: int; fill: char = ' '; left: bool = true; truncate: bool = false): string; overload;

Adjusts a string length to the len value, by adding additional character at the beginning (left = true) or at the end (left = false) of the string.

function padChar(pad: char; len: unsigned): string; overload;

Returns a string containing specified number of specified character.

function padChar(pad: aChar; len: unsigned): aString; overload;

Returns a string containing specified number of specified character.

function strCopy(dest, source: pChar; maxLen: int = -1): pChar; overload;

Copies source string into dest pChat. dest must be large enough to store the source.

Parameters
maxLen
limit the number of characters to copy.
Returns

dest.

function strCopy(dest, source: paChar; maxLen: int = -1): paChar; overload;
 
function strCopyS(dest: pChar; const source: string; maxLen: int = -1): pChar; overload;

Copies source string into dest pChat. dest must be large enough to store the source.

Parameters
maxLen
limit the number of characters to copy.
Returns

dest.

function strCopyS(dest: paChar; const source: aString; maxLen: int = -1): paChar; overload;
 
function strNew(const source: string): pChar; overload;

Allocates new pChar value and copies the source string into it.

function strNew(const source: aString): paChar; overload;
 
function strNewA(str: paChar): paChar;

Allocates memory for a new string. Use unaUtils.strDispose() to release the memory.

function str2arrayA(const src: aString; var A: array of aChar): int;
 
Returns

number of chars being copied.

function str2arrayW(const src: wString; var A: array of wChar): int;
 
Returns

number of chars being copied.

function array2strA(const A: array of aChar; out value: aString; startPos: int = low(int); length: int = -1): int;

//

function array2strW(const A: array of wChar; out value: wString; startPos: int = low(int); length: int = -1): int;

//

function array2str(const A: array of wChar; out value: wString; maxArrayLength: int = -1): int;

If maxArrayLength is specified, assumes that it includes the last NULL character.

Returns

number of wide chars being copied.

function strAllocA(size: uint): paChar;

Allocates memory for a new string.

function strDisposeA(var str: paChar): bool;

Deallocates memory taken by a string. Do not mix SysUtils.strNew() and unaUtils.strDispose().

function strDisposeW(var str: pwChar): bool;

Deallocates memory taken by a string. Do not mix SysUtils.strNew() and unaUtils.strDispose().

function strLenA(str: paChar): unsigned;
 
Returns

length of a string.

function strScanA(const str: paChar; chr: aChar): paChar;

Scans the src string for specified character.

Returns

pointer on position in the string where this character was found, or nil otherwise.

function strPosA(const strSource, strToFind: paChar): paChar;
 
function lastDelimiter(const delimiters, s: wString): int;

Search is performed from the end of string. Returns length of s if no characters were found.

Returns

position (starting from 1) in the s where one of the characters given in delimiters was found.

function strEscape(const value: string; const specialCare: string = ''): string;

Makes value safe to pass as "plain" string, by escaping special characters with "/" symbol. Examples:

  • ("Lake"#9"Una" – "Lake/tUna")

  • ("Line1"#13#10"Line2" – "Line1/r/nLine2")

  • ("C:\TEMP/" – "C:\TEMP//")

  • ("PAGE"#12"FEED" – "PAGE/012FEED")

function strUnescape(const value: string): string;

Converts "escaped" value back to "plain" string. Examples:

"Lake/tUna" –> "Lake"#9"Una" "Line1/r/nLine2" –> "Line1"#13#10"Line2" "C:\TEMP//" –> "C:\TEMP/" "PAGE/012FEED" –> "PAGE"#12"FEED"

function htmlEscape(const value: aString; strict: bool = true): aString;

//

function urlEncodeA(const value: aString): aString;

//

function urlDecodeA(const value: aString): aString;
 
function urlEncodeW(const value: wString): wString;
 
function urlDecodeW(const value: wString): wString;
 
function urlEncode(const value: string): string;
 
function urlDecode(const value: string): string;
 
function formatTemplate(const templ: string; const vars: string; unescapeVars: bool = true): string;

Substitues variable fields in the template with given values. Example: templ = "Hello from %name% %last name%, take the 10%% of text." vars = "name"#9"Lake"#10"last name"#9"Una" result = "Hello from Lake Una, take the 10% of text."

Use the strEscape() function to ensure there are no #9 or #10 characters in the values.

function nextToken(const text: wString; var startPos: int): wString;
 
function replaceTokens(var text: aString; const tokens: aString): int; overload;

Returns number of tokens replaced.

function replaceTokens(var text: aString; const tokens: aString; var careSelStart: int): int; overload;
 
function replaceTokens(var text: wString; const tokens: wString; var careSelStart: int): int; overload;
 
function getIntValueFromStr(const str, paramName: string; defValue: int): int;

param1=value1#9param2=value2

Parameters
str
must have the following format:
Returns

integer parameter value (or defValue);

function guiMessageBox(owner: hWnd; const message, title: wString; flags: int = MB_OK): int; overload;

A wrapper for MessageBox() function.

function guiMessageBox(const message, title: wString; flags: int = MB_OK; owner: hWnd = 0): int; overload;

A wrapper for MessageBox() function.

function ShellAboutA(Wnd: HWND; szApp, szOtherStuff: paChar; Icon: HICON): Integer; stdcall;
 
function ShellAboutW(Wnd: HWND; szApp, szOtherStuff: pwChar; Icon: HICON): Integer; stdcall;
 
function guiAboutBox(const appName, otherStuff: wString; handle: tHandle = 0; icon: hIcon = $FFFFFFFF): int;

Wrapper for ShellAbout function

function getModuleFileNameExt(const ext: wString): wString;

Returns name of executable module with given extension.

function getModulePathName(const fileName: wString = ''): wString;

Produces file name with the same path as executable module.

function assertLogMessage(const message: string; logToScreen: int = -1; logToFile: int = -1; logTimeMode: unaInfoMessage_logTimeModeEnum = unaLtm_default; logMemoryInfo: int = -1; logThreadId: int = -1): bool;

Calls infoMessage() or does nothing if <STRONG>DEBUG</STRONG> symbol was not defined.

function infoMessage(const message: string; logToScreen: int = -1; logToFile: int = -1; logTimeMode: unaInfoMessage_logTimeModeEnum = unaLtm_default; logMemoryInfo: int = -1; logThreadId: int = -1; flags: int = 0): bool;

Displays the message on the screen, adds it to debug log file and/or passes it to the infoMessageProc. See setInfoMessageMode() for details.

function logMessage(const message: string = ''; flags: int = c_logModeFlags_normal; logToScreen: int = -1; logToFile: int = -1; logTimeMode: unaInfoMessage_logTimeModeEnum = unaLtm_default; logMemoryInfo: int = -1; logThreadId: int = -1): bool;

Same as infoMessage() but also checks mode parameter. If (mode > infoLogMessageMode) does nothing.

function setInfoMessageMode(const logName: wString = ''; proc: infoMessageProc = nil; logToScreen: int = -1; logToFile: int = -1; logTimeMode: unaInfoMessage_logTimeModeEnum = unaLtm_default; logMemoryInfo: int = -1; logThreadId: int = -1; useWideStrings: bool = false; useSysTime: int = -1): wString;

Specifies the name of debug log and infoMessageProc procedure to be used by the infoMessage() routine.

function color2str(color: int): string;
 
function color2rgb(color: int): tRGB;
 
function colorShift(color: int; op: tunaColorOp): int;
 
function getRegValue(const path: aString; const keyName: aString; var buf; var size: DWORD; rootKey: HKEY = HKEY_CURRENT_USER): long; overload;

Reads data from registry.

function setRegValue(const path: aString; const keyName: aString; const buf; size: DWORD; keyType: int; rootKey: HKEY = HKEY_CURRENT_USER): long; overload;

Writes data to registry.

function getRegValue(const path: aString; const keyName: aString = ''; defValue: int = 0; rootKey: HKEY = HKEY_CURRENT_USER): int; overload;

Reads integer value from registry.

function getRegValue(const path: aString; const keyName: aString = ''; defValue: unsigned = 0; rootKey: HKEY = HKEY_CURRENT_USER): unsigned; overload;
 
function setRegValue(const path: aString; const keyName: aString = ''; keyValue: int = 0; rootKey: HKEY = HKEY_CURRENT_USER): long; overload;

Writes integer value into registry.

function setRegValue(const path: aString; const keyName: aString = ''; keyValue: unsigned = 0; rootKey: HKEY = HKEY_CURRENT_USER): long; overload;
 
function getRegValue(const path: aString; const keyName: aString = ''; const defValue: aString = ''; rootKey: HKEY = HKEY_CURRENT_USER): aString; overload;

Reads aString value from registry.

function setRegValue(const path: aString; const keyName: aString = ''; const keyValue: aString = ''; rootKey: HKEY = HKEY_CURRENT_USER): long; overload;

Writes string value into registry.

function setRegValueW(const path: wString; const keyName: wString = ''; const keyValue: wString = ''; rootKey: HKEY = HKEY_CURRENT_USER): long; overload;
 
function enableAutorun(doEnable: bool = true; const appPath: wString = ''): bool;

Enables or disables autorun of specified appication (current module will be used by default).

function processMessages(wnd: hWnd = 0): unsigned;

Processes messages waiting to be processed by application or window.

Returns

number of messages being processed.

function execApp(const moduleAndParams: wString = ''; waitForExit: bool = true; showFlags: WORD = SW_SHOW; redirectFromWOW64: bool = false): int; overload;

Runs an external application.

Parameters
moduleAndParams
Module name along with paremeteres.
waitForExit
should the function wait till module terminates?
showFlags
how should application appear on screen
redirectFromWOW64
under WOW64 will redirect from %windir%\SysWOW64 to %windir%\Sysnative. Usefull only for calling system 64-bit apps from 32-bit process.
Returns

0 if succeeded or GetLastError() otherwise.

function execApp(const module: wString; const params: wString = ''; waitForExit: bool = true; showFlags: WORD = SW_SHOW; redirectFromWOW64: bool = false): int; overload;

Runs an external application.

Parameters
module
Module name (with optional full path).
params
Parameters (optional).
waitForExit
should the function wait till module terminates?
showFlags
how should application appear on screen
redirectFromWOW64
under WOW64 will redirect from %windir%\SysWOW64 to %windir%\Sysnative. Usefull only for calling system 64-bit apps from 32-bit process.
Returns

0 if succeeded or GetLastError() otherwise.

function locateProcess(var procEntryW: PROCESSENTRY32W; const exeName: wString = ''): bool;
 
function locateProcesses(var procEntriesW: pprocessEntryArrayW; const exeName: wString = ''): int;
 
function windowsEnum(var wnds: pHandleArray): unsigned;
 
function windowGetFirstChild(parent: hWnd): hWnd;
 
function getProcessWindows(var wnds: pHandleArray; processId: unsigned = 0): unsigned;
 
function checkIfDuplicateProcess(doFlashWindow: bool = true): unsigned; overload;

returns processId of first process with same module name, or 0 if no such proccess was found.

function checkIfDuplicateProcess(const mutexName: wString; var mutex: tHandle; closeIfFound: bool = true): bool; overload;

Returns false if no mutex with given name was created by the time of this function execution.

Creates mutex if it was not created before and returns its handle.

If mutex already exists, returns true (mutex handle will be valid only when closeIfFound is false).

function setPriority(value: int): int;
 
function getPriority(): int;
 
function putIntoClipboard(const data: aString; window: hWnd = 0): int;

Returns 0 if successfull.

function getNumCores(): int;

Returns number of cores.

function ams(): int;
 
Returns

allocated memory size.

procedure mfill16(mem: pointer; count: unsigned; value: uint16 = 0);

Fills memory block with specified word value.

Parameters
count
count of words (not bytes)
function malloc(size: unsigned; doFill: bool = false; fill: byte = 0): pointer; overload;

Allocates block of memory.

Parameters
size
size of block to allocate.
doFill
specifies wether to fill allocated memory block with some value (default is false).
fill
specifies the value to fill the allocated block with.
Returns

pointer to allocated memory block.

function malloc(size: unsigned; data: pointer): pointer; overload;

Allocates block of memory.

Parameters
size
size of block to allocate.
data
pointer to a data buffer to be copied into allocated block (must contain at least size bytes).
Returns

pointer to allocated memory block.

procedure mrealloc(var data; newSize: unsigned = 0);

Reallocates block of memory. Has same functionality as ReallocMem() routine.

Returns

the resulting pointer.

function mcompare(p1, p2: pointer; size: unsigned): bool;

Compares two memory blocks.

Parameters
p1
pointer to first block.
p2
pointer to second block.
Returns

true if at least size bytes are equal.

function mscanb(buf: pointer; count: unsigned; value: uint8): pointer;

Scans memory for a byte value. Count is number of bytes in buf array.

function mscanw(buf: pointer; count: unsigned; value: uint16): pointer;

Scans memory for a word value. Count is a number of words in buf array.

function mscand(buf: pointer; count: unsigned; value: uint32): pointer;

Scans memory for a double word value. Count is a number of double words in buf array.

function mscanp(buf: pointer; value: pointer; len: unsigned): pointer;

Scans memory for a pointer value. Assumes elements are aligned to sizeof(pointer)

Parameters
value
value to scan for
len
size of buffer in bytes
function mscanq(buf: pointer; count: unsigned; const value: int64): pointer;

Scans memory for a quad word value. Count is a number of quad words in buf array.

function mscanbuf(buf: pointer; bufSize: unsigned; value: pointer; valueLen: unsigned): pointer;

Scans memory for array of bytes, pointed by value. bufSize is number of bytes in buf array. valueLen is number of bytes in value array.

procedure mswapbuf16(buf: pointer; len: int);

Swaps int16/uint16 values in a buffer. Len is in bytes and should be even.

function swap16u(w: uint16): uint16;

LSB16 <-> MSB16, sorts 2 bytes in reverse order.

function swap16i(w: int16): int16;
 
function swap32u(w: uint32): uint32;

LSB32 <-> MSB32, sorts 4 bytes in reverse order.

function swap32i(w: int32): int32;
 
function swap64u(w: uint64): uint64;

LSB64 <-> MSB64, sorts 8 bytes in reverse order.

function swap64i(w: int64): int64;
 
procedure freeAndNil(var objRef);

Disposes an object.

Assigns nil value to the object reference.

function waitForObject(handle: tHandle; timeout: tTimeout = 1): bool;

Waits specified amount of time for event to be sent in signaled state.

Returns

true if event was sent to signaled state.

function _acquire32(var a: unaAcquireType): bool;

internal, do not use

function acquire32Exclusive(var a: unaAcquireType): bool;

Tries to acquire an object (interger counter). If acquisition failed, releases the object, so there is no need to call release32() if this function returns false. There is no timeout parameter, so function fails or succeed immediately. Don't forget to call release32() if this function returns True.

Parameters
a
Object to acquire.
Returns

true if counter was equal 0 exactly at this acquisition attempt.

function acquire32NonExclusive(var a: unaAcquireType): bool;

Acquires an object (interger counter).

This acquire always succeeds, simply marking an object as "locked". Don't forget to call release32() when object is no longer needed to be marked as "locked".

Parameters
a
Object to acquire.
Returns

True if a was 0 at the moment of acquition.

procedure acquire32NE(var a: unaAcquireType);

Acquires an object (interger counter).

This acquire always success, simply marking an object as "locked". Don't forget to call release32() when object is no longer needed to be "locked".

Parameters
a
Object to acquire.
function acquire32(var a: unaAcquireType; timeout: tTimeout): bool; overload;

Acquires an object (interger counter) and returns true if counter was 0 exactly at this acquisition attempt.

If acquisition failed, releases the object, so there is no need to call release32() if this function returns false.

Parameters
a
Object to acquire.
timeout
Time in ms to spend trying to acquire. 0 means give up without waiting.
Returns

True if object was acquired exactly at this acquisition attempt.

function release32(var a: unaAcquireType): bool;

Releases object, acquired with successfull acquire32XXXXXXX(). (If exclusive parameter was false, object must always be released).

Release always succeeds. Return value simply indicates if object counter reached 0 after release, so it would be possible to maintain a, for example, number of acquired objects.

Parameters
acquire
Object to release.
Returns

True if object ref count has reached 0.

function hrpc_timeMark(): int64;

"Marks" current time. Uses high-resolution performance counter (HPRC) if possible or GetTickCount() otherwise.

function hrpc_timeElapsed32(mark: int64): unsigned;

Returns number of milliseconds passed between given mark and current time. Uses high-resolution performance counter (HPRC) if available, or GetTickCount() otherwise.

function hrpc_timeElapsed64(mark: int64): int64;

Returns number of milliseconds passed between given mark and current time. Uses high-resolution performance counter (HPRC) if available, or GetTickCount() otherwise.

function hrpc_timeElapsed64ticks(mark: int64): int64;

Returns number of internal ticks passed between given mark and current time. Uses high-resolution performance counter (HPRC) if available.

function gtc(): uint64;

"smart" GetTickCount()

Returns

Number of milliseconds since boot, resolution is about 1 ms

procedure markGTCLoop(loop: uint64);

Internal, do not use. Must be declared in interface so other timeXXXX() could be compiled inline.

function timeMarkU(): uint64;

Marks current time.

function timeElapsed32U(mark: uint64): uint32;

Number of milliseconds passed between given mark and current time.

Parameters
mark
Time mark made before
Returns

MS passed since mark

function timeElapsed64U(mark: uint64): uint64;

Number of milliseconds passed between given mark and current time.

Parameters
mark
Time mark made before
Returns

MS passed since mark

function timeElapsedU(mark: uint64): unsigned;

Returns number of milliseconds passed between given mark and current time.

function sanityCheck(var mark: uint64; maxSlice: unsigned = 300; sleepSlice: unsigned = 20; careMessages: bool = true): bool;
 
function sanityCheck64(var mark: uint64; maxSlice: int64 = 300000; sleepSlice: unsigned = 20; careMessages: bool = false): bool;
 
function getSysErrorText(errorCode: DWORD = 0; avoidGetCall: bool = false; includeErorCode: bool = true): wString;

Returns string describing last error.

Parameters
errorCode
if 0 (default) GetLastError() value will be called (unless avoidGetCall is true)
avoidGetCall
do not call GetLastError()
includeErorCode
show error code as well
Returns

Windows system error message string for given error code.

function choice(value: bool; true_choice: char = ' '; false_choice: char = ' '): char; overload;

Returns one of the choices depending on value of boolean selector.

function choice(value: bool; true_choice: aChar = ' '; false_choice: aChar = ' '): aChar; overload;

Returns one of the choices depending on value of boolean selector.

function choice(value: bool; true_choice: int = 1; false_choice: int = 0): int; overload;

Returns one of the choices depending on value of boolean selector.

function choice(value: bool; true_choice: unsigned = 1; false_choice: unsigned = 0): unsigned; overload;

Returns one of the choices depending on value of boolean selector.

function choice(value: bool; const true_choice: string; const false_choice: string = ''): string; overload;

Returns one of the choices depending on value of boolean selector.

function choice(value: bool; const true_choice: aString; const false_choice: aString = ''): aString; overload;
 
function choice(value: bool; true_choice: boolean = true; false_choice: boolean = false): bool; overload;

Returns one of the choices depending on value of boolean selector.

function choice(value: bool; true_choice: tObject = nil; false_choice: tObject = nil): tObject; overload;

Returns one of the choices depending on value of boolean selector.

function choice(value: bool; true_choice: pointer = nil; false_choice: pointer = nil): pointer; overload;

Returns one of the choices depending on value of boolean selector.

function choiceD(value: bool; const true_choice: double = 0; false_choice: double = 0): double;

Returns one of the choices depending on value of boolean selector.

function choiceE(value: bool; const true_choice: extended = 0; false_choice: extended = 0): extended;

Returns one of the choices depending on value of boolean selector.

function gcd(a, b: unsigned): unsigned;

Returns greatest common divider.

For example, if a=11025 and b=1000 the result will be 25.

function getNullDacl(): PSecurityAttributes;

Creates NULL DACL.

Types

TFNBFFCallBack = type BFFCALLBACK;
 
PBrowseInfoA = ˆTBrowseInfoA;
 
PBrowseInfoW = ˆTBrowseInfoW;
 
TBrowseInfoA = _browseinfoA;

output var: where to return the Image index.

BROWSEINFOA = _browseinfoA;
 
TBrowseInfoW = _browseinfoW;
 
BROWSEINFOW = _browseinfoW;
 
proc_ffcallback = function(sender: pointer; const path: wString; const fdw: WIN32_FIND_DATAW): bool;

Callback routine for findFiles().

Returns

True if process should continue.

tDayTable = array[1..12] of byte;

– –

unaInfoMessage_logTimeModeEnum = (...);

– –

Values
  • unaLtm_default:  
  • unaLtm_none:  
  • unaLtm_date:  
  • unaLtm_time:  
  • unaLtm_dateTime:  
  • unaLtm_timeDelta:  
  • unaLtm_dateTimeDelta:  
  • unaLtm_dateTimeDelta64:  
infoMessageProc = procedure(const message: string);

This procedure type is used by infoMessage() routine.

Parameters
message
Message to be logged/displayed.
pRGB = ˆtRGB;

colors

– color –

tunaColorOp = (...);

– color ops –

Values
  • unaco_invalid:  
  • unaco_wearOut:  
PROCESSENTRY32W = tagPROCESSENTRY32W;

Path

PPROCESSENTRY32W = ˆtagPROCESSENTRY32W;
 
LPPROCESSENTRY32W = ˆtagPROCESSENTRY32W;
 
TProcessEntry32W = tagPROCESSENTRY32W;
 
pprocessEntryArrayW = ˆprocessEntryArrayW;
 
processEntryArrayW = array[byte] of PROCESSENTRY32W;
 
pHandleArray = ˆhandleArray;
 
handleArray = array[byte] of tHandle;
 

Constants

BFFM_ENABLEOK = WM_USER + 101;
 
BFFM_INITIALIZED = 1;

message from browser

BFFM_SELCHANGED = 2;
 
BFFM_SETSELECTION = BFFM_SETSELECTIONA;
 
BFFM_SETSELECTIONA = WM_USER + 102;
 
BFFM_SETSELECTIONW = WM_USER + 103;
 
BFFM_SETSTATUSTEXT = BFFM_SETSTATUSTEXTA;
 
BFFM_SETSTATUSTEXTA = WM_USER + 100;
 
BFFM_SETSTATUSTEXTW = WM_USER + 104;
 
BFFM_VALIDATEFAILED = BFFM_VALIDATEFAILEDA;
 
BFFM_VALIDATEFAILEDA = 3;
 
BFFM_VALIDATEFAILEDW = 4;

lParam:szPath ret:1(cont),0(EndDialog)

BIF_BROWSEFORCOMPUTER = $1000;
 
BIF_BROWSEFORPRINTER = $2000;

Browsing for Computers

BIF_BROWSEINCLUDEFILES = $4000;

Browsing for Printers

BIF_BROWSEINCLUDEURLS = $0080;
 
BIF_DONTGOBELOWDOMAIN = $0002;

For finding a folder to start document searching

BIF_EDITBOX = $0010;
 
BIF_NEWDIALOGSTYLE = $0040;

insist on valid result (or CANCEL)

BIF_RETURNFSANCESTORS = $0008;
 
BIF_RETURNONLYFSDIRS = $0001;

Browsing for directory.

BIF_SHAREABLE = $8000;

Browsing for Everything

BIF_STATUSTEXT = $0004;

For starting the Find Computer

BIF_USENEWUI = BIF_NEWDIALOGSTYLE or BIF_EDITBOX;
 
BIF_VALIDATE = $0020;
 
CSIDL_ADMINTOOLS = $0030;

<user name>\Start Menu\Programs\Administrative Tools

CSIDL_ALTSTARTUP = $001d;
 
CSIDL_APPDATA = $001a;
 
CSIDL_BITBUCKET = $000a;
 
CSIDL_CDBURN_AREA = $003b;

All Users\My Video

CSIDL_COMMON_ADMINTOOLS = $002f;

All Users\Start Menu\Programs\Administrative Tools

CSIDL_COMMON_ALTSTARTUP = $001e;

DBCS

CSIDL_COMMON_APPDATA = $0023;

All Users\Application Data

CSIDL_COMMON_DESKTOPDIRECTORY = $0019;
 
CSIDL_COMMON_DOCUMENTS = $002e;

All Users\Documents

CSIDL_COMMON_FAVORITES = $001f;

DBCS

CSIDL_COMMON_MUSIC = $0035;

Network and Dial-up Connections

CSIDL_COMMON_PICTURES = $0036;

All Users\My Music

CSIDL_COMMON_PROGRAMS = $0017;
 
CSIDL_COMMON_STARTMENU = $0016;
 
CSIDL_COMMON_STARTUP = $0018;
 
CSIDL_COMMON_VIDEO = $0037;

All Users\My Pictures

CSIDL_COMPUTERSNEARME = $003d;

USERPROFILE\Local Settings\Application Data\Microsoft\CD Burning

CSIDL_CONNECTIONS = $0031;

USERPROFILE

CSIDL_CONTROLS = $0003;
 
CSIDL_COOKIES = $0021;
 
CSIDL_DESKTOP = $0000;
 
CSIDL_DESKTOPDIRECTORY = $0010;
 
CSIDL_DRIVES = $0011;
 
CSIDL_FAVORITES = $0006;
 
CSIDL_FLAG_CREATE = $8000;

new for Win2K, or this in to force creation of folder

CSIDL_FONTS = $0014;
 
CSIDL_HISTORY = $0022;
 
CSIDL_INTERNET = $0001;
 
CSIDL_INTERNET_CACHE = $0020;
 
CSIDL_LOCAL_APPDATA = $001c;
 
CSIDL_MYPICTURES = $0027;

My Pictures, new for Win2K

CSIDL_NETHOOD = $0013;
 
CSIDL_NETWORK = $0012;
 
CSIDL_PERSONAL = $0005;
 
CSIDL_PRINTERS = $0004;
 
CSIDL_PRINTHOOD = $001b;
 
CSIDL_PROFILE = $0028;
 
CSIDL_PROFILES = $003e;

Computers Near Me (computered from Workgroup membership)

CSIDL_PROGRAMS = $0002;
 
CSIDL_PROGRAM_FILES = $0026;

C:\Program Files

CSIDL_PROGRAM_FILES_COMMON = $002b;

C:\Program Files\Common

CSIDL_RECENT = $0008;
 
CSIDL_SENDTO = $0009;
 
CSIDL_STARTMENU = $000b;
 
CSIDL_STARTUP = $0007;
 
CSIDL_SYSTEM = $0025;

GetSystemDirectory()

CSIDL_TEMPLATES = $0015;
 
CSIDL_WINDOWS = $0024;

GetWindowsDirectory()

CSTR_EQUAL = 2;

string 1 equal to string 2

CSTR_GREATER_THAN = 3;

string 1 greater than string 2

CSTR_LESS_THAN = 1;

string 1 less than string 2

c_logModeFlags_critical = $0001;
 
c_logModeFlags_debug = $0004;
 
c_logModeFlags_normal = $0002;
 
monthDays: array [boolean] of tDayTable = ((31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31), (31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31));

– –

REGSTR_PATH_EXPLORER = 'Software\Microsoft\Windows\CurrentVersion\Explorer';
 
REGSTR_PATH_SPECIAL_FOLDERS = REGSTR_PATH_EXPLORER + '\Shell Folders';

registry entries for special paths are kept in :

unicodeHighSurrogateEnd = $DBFF;
 
unicodeHighSurrogateStart = $D800;
 
unicodeLowSurrogateEnd = $DFFF;
 
unicodeLowSurrogateStart = $DC00;
 
WM_USER = $0400;

messages to browser

zeroWidthNonBreakingSpace = $FEFF;

UTF8/UTF16/UNICODE functions

zeroWidthNonBreakingSpaceUTF8 = #$EF#$BB#$BF;
 
zeroWidthNonBreakingSpaceW = wChar(zeroWidthNonBreakingSpace);
 

Variables

g_isWOW64: bool;

Are we running unser WOW64?

g_OSVersion: OSVERSIONINFOW;

OS version information

hrpc_Freq: int64 = 0;

– HRPC/WINDOWS TIMER –

hrpc_FreqFail: bool = false;

ticks per second

hrpc_FreqMs: int64 = 0;

true if we cannot use HRPP

Author

(c) 2012 Lake of Soft


Generated by PasDoc 0.12.1 on 2012-10-09