MMUTILS.INT 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. {========================================================================}
  2. {= (c) 1995-98 SwiftSoft Ronald Dittrich =}
  3. {========================================================================}
  4. {= All Rights Reserved =}
  5. {========================================================================}
  6. {= D 01099 Dresden = Tel.: +0351-8012255 =}
  7. {= Loewenstr.7a = info@swiftsoft.de =}
  8. {========================================================================}
  9. {= Actual versions on http://www.swiftsoft.de/mmtools.html =}
  10. {========================================================================}
  11. {= This code is for reference purposes only and may not be copied or =}
  12. {= distributed in any format electronic or otherwise except one copy =}
  13. {= for backup purposes. =}
  14. {= =}
  15. {= No Delphi Component Kit or Component individually or in a collection=}
  16. {= subclassed or otherwise from the code in this unit, or associated =}
  17. {= .pas, .dfm, .dcu, .asm or .obj files may be sold or distributed =}
  18. {= without express permission from SwiftSoft. =}
  19. {= =}
  20. {= For more licence informations please refer to the associated =}
  21. {= HelpFile. =}
  22. {========================================================================}
  23. {= $Date: 20.01.1998 - 18:00:00 $ =}
  24. {========================================================================}
  25. unit MMUtils;
  26. {$I COMPILER.INC}
  27. interface
  28. uses
  29. {$IFDEF WIN32}
  30. Windows,
  31. Registry,
  32. {$ELSE}
  33. WinTypes,
  34. WinProcs,
  35. {$ENDIF}
  36. SysUtils,
  37. Controls,
  38. Classes,
  39. Forms,
  40. Dialogs,
  41. Graphics;
  42. {$I MMTYPES.INC}
  43. const
  44. InitCode : Longint = 0;
  45. ErrorCode: Longint = 0;
  46. SHandle : THandle = 0;
  47. var
  48. _Win95_ : Boolean;
  49. _WinNT3_ : Boolean;
  50. _WinNT4_ : Boolean;
  51. _CPU_ : integer;
  52. _MMX_ : Boolean;
  53. _USECPUEXT_: Boolean;
  54. const
  55. { Processor constants }
  56. PENTIUM = 0;
  57. PENTIUMPRO = 1;
  58. PENTIUMPRO2= 2;
  59. MAXLONG = 2000000000;
  60. {$IFNDEF WIN32}
  61. MAX_PATH = 260;
  62. cl3DLight = clBtnFace;
  63. procedure MoveWindowOrg(DC: HDC; DX, DY: Integer);
  64. {$ELSE}
  65. function GetFromRegistry(_RootKey:HKEY;_Localkey,_Field:String;Value:Variant): Variant;
  66. procedure SaveInRegistry(_RootKey:HKEY;_Localkey,_Field:String;Value:Variant);
  67. function GetCPUUsage: integer;
  68. function GetShortFileName(Name: TFileName): String;
  69. {$ENDIF}
  70. function HaveWin95: Boolean;
  71. function HaveWinNT: Boolean;
  72. function HaveWinNT4: Boolean;
  73. function GetCPUType: Word;
  74. function GetCPUFeatures: Longint;
  75. function GetCPUMode: integer;
  76. function GetCPUCycles: Comp;
  77. function TimeGetExactTime: Comp;
  78. procedure InitTimeMeasure;
  79. procedure StartTimeMeasure;
  80. function StopTimeMeasure(Scale: integer): string;
  81. procedure InitCyclesMeasure;
  82. procedure StartCyclesMeasure;
  83. function StopCyclesMeasure(Scale: integer): string;
  84. procedure Delay(ms: LongInt; ProcessMessages: Boolean);
  85. function NonClientHeight: integer;
  86. function BitsPerPixel: integer;
  87. function ClientToClient(Destination, Source: TControl; P: TPoint): TPoint;
  88. function GetFileSize(Name: TFileName): Longint;
  89. function GetDiskStats(const iDrive: Byte; var nFree, nSize: Comp): Boolean;
  90. function GetDiskFree(const iDrive: Byte; nBytes: Longint): Boolean;
  91. procedure ChangeColors(Bitmap: TBitmap; DrawInactive: Boolean;
  92. ForeColor, InactiveColor, BackColor: TColor);
  93. procedure GetBitmapSize(Bitmap: HBitmap; var W, H: integer);
  94. function GetTransparentColor(Bitmap: HBitmap): TColorRef;
  95. procedure DrawTransparentBitmap(DC: HDC; Bitmap: HBitmap;
  96. xStart, yStart: integer; Transparent: TColorRef);
  97. procedure TileBlt(DC: HDC; Bitmap: HBitmap; const aRect:TRect; ROP: Longint);
  98. function WinExecAndWait(FileName: TFileName): Boolean;
  99. procedure TimeDecode(Time: Longint; var Hour, Min, Sec, MSec: Word);
  100. function TimeToMask(Time: Longint): string;
  101. function MaskToTime(Mask: string): Longint;
  102. function TimeToString(Time: Longint): string;
  103. function VolumeToStringShort(Volume, Base: Longint; Precision: integer): string;
  104. function VolumeToString(Volume, Base: Longint; Precision: integer): string;
  105. function PanningToString(Panning,Base: Longint): String;
  106. procedure CalcVolume(Base,Volume,Panning: Longint; var Left, Right: Longint);
  107. function FormatBigNumber(dw: Longint): String;
  108. procedure DrawRubberband(Sender: TObject; aRect: TRect);
  109. procedure DrawRubberLine(Sender: TObject; aRect: TRect);
  110. procedure TextOutAligned(Canvas: TCanvas; X, Y: integer; Text: String;
  111. FontName: PChar; FontSize: integer; Align: Byte);
  112. function DesignMode: Boolean;
  113. function CheckPath(Path: string; Flag: Boolean): String;
  114. {$IFDEF WIN32}
  115. {$IFNDEF DELPHI3}
  116. type
  117. EWin32Error = class(Exception)
  118. public
  119. ErrorCode: DWORD;
  120. end;
  121. function SysErrorMessage(ErrorCode: Integer): string;
  122. procedure RaiseLastWin32Error;
  123. function Win32Check(RetVal: BOOL): BOOL;
  124. {$ENDIF}
  125. {$ENDIF}
  126. {========================================================================}
  127. var
  128. SwapSmall : procedure (var a, b: SmallInt);
  129. SwapInt : procedure (var a, b: integer);
  130. SwapLong : procedure (var a, b: Longint);
  131. Min : function (a, b: Longint): Longint;
  132. Max : function (a, b: Longint): Longint;
  133. MinMax : function (X, Min, Max: Longint): Longint;
  134. Limit : function (X, Min, Max: Longint): Longint;
  135. InMinMax : function (X, Min, Max: Longint): Boolean;
  136. InRange : function (X, Min, Max: Longint): Boolean;
  137. incHuge : procedure (Var Pointer; nBytes: Longint);
  138. GlobalFillMem : procedure (var X; Cnt: Longint; Value: Byte);
  139. GlobalFillLong : procedure (var X; Cnt: Longint; Value: Longint);
  140. GlobalMoveMem : procedure (const Source; var Dest; Cnt: Longint);
  141. GlobalCmpMem : function (const p1, p2; Cnt: Longint): Boolean;
  142. function GlobalAllocMem(Size: Longint): Pointer;
  143. procedure GlobalReAllocMem(var p: Pointer; Size: Longint);
  144. procedure GlobalFreeMem(var p: Pointer);
  145. function GlobalMemSize(const p: Pointer): Longint;
  146. implementation