home *** CD-ROM | disk | FTP | other *** search
-
- {*******************************************************}
- { }
- { MiTeC Common Routines }
- { version 1.9 for Delphi 5,6 }
- { }
- { Copyright ⌐ 1997,2002 Michal Mutl }
- { }
- {*******************************************************}
-
- {$INCLUDE MITEC_DEF.INC}
-
- unit MiTeC_Routines;
-
- interface
-
- uses Windows, Classes, SysUtils, ShlObj;
-
- type
- TTerminateStatus = (tsError,tsClose,tsTerminate);
-
- TConnectionType = (ctNone, ctLAN, ctDialup);
-
- TOSVersion = (osUnknown, os95, os95OSR2, os98, os98SE, osME, osNT3, osNT4, os2K, osXP);
-
- TVersionInfo = record
- FileName,
- Version,
- ProductName,
- CompanyName,
- Description,
- Comments,
- Copyright: string;
- Major,
- Minor,
- Release,
- Build: DWORD;
- end;
-
- TMediaType = (dtUnknown, dtNotExists, dtRemovable, dtFixed, dtRemote, dtCDROM, dtRAMDisk);
-
- TFileFlag = (fsCaseIsPreserved, fsCaseSensitive, fsUnicodeStoredOnDisk,
- fsPersistentAcls, fsFileCompression, fsVolumeIsCompressed,
- fsLongFileNames,
- // following flags are valid only for Windows2000
- fsEncryptedFileSystemSupport, fsObjectIDsSupport, fsReparsePointsSupport,
- fsSparseFilesSupport, fsDiskQuotasSupport);
- TFileFlags = set of TFileFlag;
-
- TDiskSign = string[2];
-
- TDiskInfo = record
- Sign: TDiskSign;
- MediaType: TMediaType;
- FileFlags: TFileFlags;
- SectorsPerCluster,
- BytesPerSector,
- FreeClusters,
- TotalClusters,
- Serial: DWORD;
- Capacity,
- FreeSpace: Int64;
- VolumeLabel,
- SerialNumber,
- FileSystem: string;
- end;
-
- PWindow = ^TWindow;
- TWindow = record
- ClassName,
- Text :string;
- Handle,
- Process,
- Thread :longword;
- ParentWin,
- WndProc,
- Instance,
- ID,
- UserData,
- Style,
- ExStyle :longint;
- Rect,
- ClientRect :TRect;
- Atom,
- ClassBytes,
- WinBytes,
- ClassWndProc,
- ClassInstance,
- Background,
- Cursor,
- Icon,
- ClassStyle :longword;
- Styles,
- ExStyles,
- ClassStyles :tstringlist;
- Visible :boolean;
- end;
-
- TFileInfo = record
- Name: string;
- FileType: string;
- Size :DWORD;
- Created,
- Accessed,
- Modified :TDateTime;
- Attributes :DWORD;
- BinaryType: string;
- IconHandle: THandle;
- end;
-
- {$IFNDEF D6PLUS}
- function ReverseString(const AText: string): string;
- function DirectoryExists(const Directory: string): Boolean;
- {$ENDIF}
-
- function ExpandEnvVars(ASource: string): string;
- function GetErrorMessage(ErrorCode: integer): string;
- function GetUser :string;
- function GetMachine :string;
- function GetOS(var CSD: string) :TOSVersion;
- function ReadRegInfo(ARoot :hkey; AKey, AValue :string) :string;
- function GetFileVerInfo(const fn :string; var VI:TVersionInfo): boolean;
- function GetFileVersion(const fn: string): string;
- function GetFileProduct(const fn: string): string;
- function GetClassDevices(AStartKey,AClassName,AValueName :string; var AResult :TStrings) :string;
- procedure GetEnvironment(var EnvList :tstrings);
- function GetWinDir :string;
- function GetSysDir :string;
- function GetTempDir :string;
- function GetWinSysDir: string;
- function GetProfilePath: string;
- function GetWindowInfo(wh: hwnd): PWindow;
- function GetUniqueFilename(Prefix: string; Unique: DWORD; Temp: Boolean = False): string;
- function ResolveLink(const LinkFile: TFileName; var FileName, Arguments: string): HRESULT;
- function GetSpecialFolder(Handle: Hwnd; nFolder: Integer): string;
- function KillProcess(ProcessID: DWORD; Timeout: Integer = INFINITE): TTerminateStatus;
- function IsProcessActive(APID: integer): Boolean;
- function GetFontRes: DWORD;
- function CreateDOSProcessRedirected(const CommandLine, InputFile, OutputFile,ErrMsg :string): Boolean;
- function FileExistsEx(const FileName: string): Boolean;
- function FileTimeToDateTimeStr(FileTime: TFileTime): string;
- function FiletimeToDateTime(FT: FILETIME): TDateTime;
- procedure GetFileInfo(const AFilename: string; var AFileInfo: TFileInfo);
- function GetFileSize(const AFilename: string): integer;
- function HasAttr(const AFileName: string; AAttr: Word): Boolean;
- function GetBinType(const AFilename :string) :string;
- function ExtractUNCFilename(ASource :string) :string;
- function DequoteStr(Source: string; Quote: Char = '"'): string;
- function ExtractFilenameFromStr(Source: string): string;
- function ExtractName(const AFilename: string): string;
- function FileCopy(const AFileName, ADestName: string): boolean;
- function FileMove(const AFileName, ADestName: string): boolean;
- function GetMediaTypeStr(MT: TMediaType): string;
- function GetMediaPresent(Value: TDiskSign) :Boolean;
- function GetDiskInfo(Value: TDiskSign): TDiskInfo;
- function GetAvailDisks :string;
- procedure GetCDs(cds :tstrings);
- function OpenMailSlot(Const Server, Slot : String): THandle;
- function SendToMailSlot(Const Server, Slot, Mail : String) : Boolean;
- function SendToWinpopup(Server, Reciever, Sender, Msg : String) : Boolean;
- function IsBitOn(Value: Integer; Bit: Byte): Boolean;
- procedure RunAtStartup(AKey: HKEY; Flag: Boolean; Name,Cmdline: string);
- function CheckRunAtStartup(Akey: HKEY; Name,CmdLine: string): Boolean;
- function GetDefaultMailClient: string;
- function GetDefaultBrowser: string;
- function GetConnectionType: TConnectionType;
- function GetProxyServer: string;
- function Init9xPerfData(ObjCounter: string): Boolean;
- function Get9xPerfData(ObjCounter: string): integer;
- function Release9xPerfData(ObjCounter: string): Boolean;
- function WinExecAndWait32(FileName,Parameters: String; Visibility: integer): DWORD;
- function IsAdmin: Boolean;
-
- const
- DescValue = 'DriverDesc';
-
- CSIDL_COMMON_ALTSTARTUP = $001e;
- CSIDL_COMMON_FAVORITES = $001f;
- CSIDL_INTERNET_CACHE = $0020;
- CSIDL_COOKIES = $0021;
- CSIDL_HISTORY = $0022;
- CSIDL_INTERNET = $0001;
-
- FILE_SUPPORTS_ENCRYPTION = 32;
- FILE_SUPPORTS_OBJECT_IDS = 64;
- FILE_SUPPORTS_REPARSE_POINTS = 128;
- FILE_SUPPORTS_SPARSE_FILES = 256;
- FILE_VOLUME_QUOTAS = 512;
-
- StartStat = 'PerfStats\StartStat';
- StatData = 'PerfStats\StatData';
- StopStat = 'PerfStats\StopStat';
-
- var
- Fileversion, CSD, OSVersion, OSVersionEx, ClassKey: string;
- IsNT,Is95,Is98,Is2K,IsOSR2,IsSE,IsME,IsXP: Boolean;
- Profilepath, WindowsUser, MachineName: string;
- OS: TOSVersion;
- Memory: Integer;
-
- implementation
-
-
-