| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170 |
- {========================================================================}
- {= (c) 1995-98 SwiftSoft Ronald Dittrich =}
- {========================================================================}
- {= All Rights Reserved =}
- {========================================================================}
- {= D 01099 Dresden = Tel.: +0351-8012255 =}
- {= Loewenstr.7a = info@swiftsoft.de =}
- {========================================================================}
- {= Actual versions on http://www.swiftsoft.de/mmtools.html =}
- {========================================================================}
- {= This code is for reference purposes only and may not be copied or =}
- {= distributed in any format electronic or otherwise except one copy =}
- {= for backup purposes. =}
- {= =}
- {= No Delphi Component Kit or Component individually or in a collection=}
- {= subclassed or otherwise from the code in this unit, or associated =}
- {= .pas, .dfm, .dcu, .asm or .obj files may be sold or distributed =}
- {= without express permission from SwiftSoft. =}
- {= =}
- {= For more licence informations please refer to the associated =}
- {= HelpFile. =}
- {========================================================================}
- {= $Date: 20.01.1998 - 18:00:00 $ =}
- {========================================================================}
- unit MMUtils;
- {$I COMPILER.INC}
- interface
- uses
- {$IFDEF WIN32}
- Windows,
- Registry,
- {$ELSE}
- WinTypes,
- WinProcs,
- {$ENDIF}
- SysUtils,
- Controls,
- Classes,
- Forms,
- Dialogs,
- Graphics;
- {$I MMTYPES.INC}
- const
- InitCode : Longint = 0;
- ErrorCode: Longint = 0;
- SHandle : THandle = 0;
- var
- _Win95_ : Boolean;
- _WinNT3_ : Boolean;
- _WinNT4_ : Boolean;
- _CPU_ : integer;
- _MMX_ : Boolean;
- _USECPUEXT_: Boolean;
- const
- { Processor constants }
- PENTIUM = 0;
- PENTIUMPRO = 1;
- PENTIUMPRO2= 2;
- MAXLONG = 2000000000;
- {$IFNDEF WIN32}
- MAX_PATH = 260;
- cl3DLight = clBtnFace;
- procedure MoveWindowOrg(DC: HDC; DX, DY: Integer);
- {$ELSE}
- function GetFromRegistry(_RootKey:HKEY;_Localkey,_Field:String;Value:Variant): Variant;
- procedure SaveInRegistry(_RootKey:HKEY;_Localkey,_Field:String;Value:Variant);
- function GetCPUUsage: integer;
- function GetShortFileName(Name: TFileName): String;
- {$ENDIF}
- function HaveWin95: Boolean;
- function HaveWinNT: Boolean;
- function HaveWinNT4: Boolean;
- function GetCPUType: Word;
- function GetCPUFeatures: Longint;
- function GetCPUMode: integer;
- function GetCPUCycles: Comp;
- function TimeGetExactTime: Comp;
- procedure InitTimeMeasure;
- procedure StartTimeMeasure;
- function StopTimeMeasure(Scale: integer): string;
- procedure InitCyclesMeasure;
- procedure StartCyclesMeasure;
- function StopCyclesMeasure(Scale: integer): string;
- procedure Delay(ms: LongInt; ProcessMessages: Boolean);
- function NonClientHeight: integer;
- function BitsPerPixel: integer;
- function ClientToClient(Destination, Source: TControl; P: TPoint): TPoint;
- function GetFileSize(Name: TFileName): Longint;
- function GetDiskStats(const iDrive: Byte; var nFree, nSize: Comp): Boolean;
- function GetDiskFree(const iDrive: Byte; nBytes: Longint): Boolean;
- procedure ChangeColors(Bitmap: TBitmap; DrawInactive: Boolean;
- ForeColor, InactiveColor, BackColor: TColor);
- procedure GetBitmapSize(Bitmap: HBitmap; var W, H: integer);
- function GetTransparentColor(Bitmap: HBitmap): TColorRef;
- procedure DrawTransparentBitmap(DC: HDC; Bitmap: HBitmap;
- xStart, yStart: integer; Transparent: TColorRef);
- procedure TileBlt(DC: HDC; Bitmap: HBitmap; const aRect:TRect; ROP: Longint);
- function WinExecAndWait(FileName: TFileName): Boolean;
- procedure TimeDecode(Time: Longint; var Hour, Min, Sec, MSec: Word);
- function TimeToMask(Time: Longint): string;
- function MaskToTime(Mask: string): Longint;
- function TimeToString(Time: Longint): string;
- function VolumeToStringShort(Volume, Base: Longint; Precision: integer): string;
- function VolumeToString(Volume, Base: Longint; Precision: integer): string;
- function PanningToString(Panning,Base: Longint): String;
- procedure CalcVolume(Base,Volume,Panning: Longint; var Left, Right: Longint);
- function FormatBigNumber(dw: Longint): String;
- procedure DrawRubberband(Sender: TObject; aRect: TRect);
- procedure DrawRubberLine(Sender: TObject; aRect: TRect);
- procedure TextOutAligned(Canvas: TCanvas; X, Y: integer; Text: String;
- FontName: PChar; FontSize: integer; Align: Byte);
- function DesignMode: Boolean;
- function CheckPath(Path: string; Flag: Boolean): String;
- {$IFDEF WIN32}
- {$IFNDEF DELPHI3}
- type
- EWin32Error = class(Exception)
- public
- ErrorCode: DWORD;
- end;
- function SysErrorMessage(ErrorCode: Integer): string;
- procedure RaiseLastWin32Error;
- function Win32Check(RetVal: BOOL): BOOL;
- {$ENDIF}
- {$ENDIF}
- {========================================================================}
- var
- SwapSmall : procedure (var a, b: SmallInt);
- SwapInt : procedure (var a, b: integer);
- SwapLong : procedure (var a, b: Longint);
- Min : function (a, b: Longint): Longint;
- Max : function (a, b: Longint): Longint;
- MinMax : function (X, Min, Max: Longint): Longint;
- Limit : function (X, Min, Max: Longint): Longint;
- InMinMax : function (X, Min, Max: Longint): Boolean;
- InRange : function (X, Min, Max: Longint): Boolean;
- incHuge : procedure (Var Pointer; nBytes: Longint);
- GlobalFillMem : procedure (var X; Cnt: Longint; Value: Byte);
- GlobalFillLong : procedure (var X; Cnt: Longint; Value: Longint);
- GlobalMoveMem : procedure (const Source; var Dest; Cnt: Longint);
- GlobalCmpMem : function (const p1, p2; Cnt: Longint): Boolean;
- function GlobalAllocMem(Size: Longint): Pointer;
- procedure GlobalReAllocMem(var p: Pointer; Size: Longint);
- procedure GlobalFreeMem(var p: Pointer);
- function GlobalMemSize(const p: Pointer): Longint;
- implementation
|