SystemInfo 1.0 與大家分享 |
|
GoldBoy
一般會員 發表:7 回覆:13 積分:4 註冊:2004-06-08 發送簡訊給我 |
請大家看完,如果就空餘時間清幫我解決一下這兩個問題! http://delphi.ktop.com.tw/topic.php?TOPIC_ID=52975
http://delphi.ktop.com.tw/topic.php?TOPIC_ID=52950 {
unit DHJSW_SystemInfo; interface uses
SysUtils, Windows, Classes,Registry, MMSystem, WinSock, Printers;//, DsgnIntf; const
cAbout = 'Dong Haojie Software Component of SystemInfo 1.0 - Copyright ?2001-2002 Dong Haojie'; cSystem = 0;
cGDI = 1;
cUSER = 2; type
{$IFDEF VER130}
{$DEFINE D4PLUS}
{$ENDIF}
{$IFDEF VER120}
{$DEFINE D4PLUS}
{$ENDIF} {$IFDEF D4PLUS}
TLargInt = _LARGE_INTEGER;
{$ELSE}
TLargInt = TLargeInteger;
Int64 = TLargeInteger;
LongWord = DWORD;
{$ENDIF} TStrBuf = array[0..11] of char; TPlatFormType = (os9x,osNT4,os2K); TCPUFeatures = class(TPersistent)
private
FSYSENTERExt: boolean;
FMTRR: boolean;
FModSpecReg: boolean;
FPageSizeExt: boolean;
FTimeStampCnt: boolean;
FMachineChkExc: boolean;
FMMX: boolean;
FPageAttrTable: boolean;
FPhysAddrExt: boolean;
FFXInstr: boolean;
FVirtModExt: boolean;
FPageGlobalExt: boolean;
FCMOVccOpcode: boolean;
FFPU: boolean;
FCMPXCHG8B: boolean;
FMachineCheck: boolean;
FAPIC: boolean;
FDebugExt: boolean;
FPageSizeExt36bit: boolean;
public
procedure GetFeaturesStr(AClear :boolean; AFeatures :TStringList);
published
property FXInstr :Boolean read FFXInstr write FFxInstr stored false;
property MMX :Boolean read FMMX write FMMX stored false;
property PageSizeExt36bit :Boolean read FPageSizeExt36bit write FPageSizeExt36bit stored false;
property PageAttrTable :Boolean read FPageAttrTable write FPageAttrTable stored false;
property CMOVccOpcode :Boolean read FCMOVccOpcode write FCMOVccOpcode stored false;
property MachineCheck :Boolean read FMachineCheck write FMachineCheck stored false;
property PageGloablExt :Boolean read FPageGlobalExt write FPageGlobalExt stored false;
property MTRR :Boolean read FMTRR write FMTRR stored false;
property SYSENTERExt :Boolean read FSYSENTERExt write FSYSENTERExt stored false;
property APIC :Boolean read FAPIC write FAPIC stored false;
property CMPXCHG8B :Boolean read FCMPXCHG8B write FCMPXCHG8B stored false;
property MachineChkExc :Boolean read FMachineChkExc write FMachineChkExc stored false;
property PhysAddrExt :Boolean read FPhysAddrExt write FPhysAddrExt stored false;
property ModSpecReg :Boolean read FModSpecReg write FModSpecReg stored false;
property TimeStampCnt :Boolean read FTimeStampCnt write FTimeStampCnt stored false;
property PageSizeExt :Boolean read FPageSizeExt write FPageSizeExt stored false;
property DebugExt :Boolean read FDebugExt write FDebugExt stored false;
property VirtModExt :Boolean read FVirtModExt write FVirtModExt stored false;
property FPU :Boolean read FFPU write FFPU stored false;
end; TCPU = class(TPersistent)
private
FVendorID,
FVendor,
FSubModel: string;
FModel,
FCount,
FArchitecture,
FLevel,
FStepping,
FFamily,
FTyp,
FVendorNo,
FFreq :integer;
FCPUID :boolean;
FFeatures: TCPUFeatures;
function CPUIDExists: boolean;
procedure GetCPUID;
function GetCPUIDLevel :integer;
function GetCPUType :integer;
function GetCPUVendor :string;
function GetCPUVendorID :string;
function GetCPUFreqEx :extended;
function GetSubModel :string;
public
constructor Create;
destructor Destroy; override;
procedure GetInfo;
procedure Report(var sl :TStringList);
published
property CPUID :Boolean read FCPUID write FCPUID stored false;
property Architecture :integer read FArchitecture write FArchitecture stored false;
property Level :integer read FLevel write FLevel stored false;
property Count :integer read FCount write FCount stored false;
property Vendor :string read FVendor write FVendor stored false;
property VendorID :string read FVendorID write FVendorID stored false;
property Freq :integer read FFreq write FFreq stored false;
property Family :integer read FFamily write FFamily stored false;
property Stepping :integer read FStepping write FStepping stored false;
property Model :integer read FModel write FModel stored false;
property Typ :integer read FTyp write FTyp stored false;
property Features :TCPUFeatures read FFeatures write FFeatures;
property SubModel :string read FSubModel write FSubModel stored false;
end; TMemory = class(TPersistent)
private
FMaxAppAddress: integer;
FVirtualTotal: integer;
FPageFileFree: integer;
FVirtualFree: integer;
FPhysicalFree: integer;
FAllocGranularity: integer;
FMinAppAddress: integer;
FMemoryLoad: integer;
FPhysicalTotal: integer;
FPageFileTotal: integer;
FPageSize: integer;
public
procedure GetInfo;
procedure Report(var sl :TStringList);
published
property PhysicalTotal :integer read FPhysicalTotal write FPhysicalTotal stored false;
property PhysicalFree :integer read FPhysicalFree write FPhysicalFree stored false;
property VirtualTotal :integer read FVirtualTotal write FVirtualTotal stored false;
property VirtualFree :integer read FVirtualFree write FVirtualFree stored false;
property PageFileTotal :integer read FPageFileTotal write FPageFileTotal stored false;
property PageFileFree :integer read FPageFileFree write FPageFileFree stored false;
property MemoryLoad :integer read FMemoryLoad write FMemoryLoad stored false;
property AllocGranularity :integer read FAllocGranularity write FAllocGranularity stored false;
property MaxAppAddress :integer read FMaxAppAddress write FMaxAppAddress stored false;
property MinAppAddress :integer read FMinAppAddress write FMinAppAddress stored false;
property PageSize :integer read FPageSize write FPageSize stored false;
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; TOperatingSystem = class(TPersistent)
private
FBuildNumber: integer;
FMajorVersion: integer;
FMinorVersion: integer;
FPlatform: string;
FCSD: string;
FVersion: string;
FRegUser: string;
FSerialNumber: string;
FRegOrg: string;
FTimeZone: string;
FEnv: TStrings;
FTempDir: string;
FWinDir: string;
FSysDir: string; function GetSystemRes: Byte;
function GetGDIRes: Byte;
function GetUSERRes: Byte; procedure GetEnvironment;
protected
procedure SetNone(Value: Byte);
public
constructor Create;
destructor Destroy; override;
procedure GetInfo;
procedure Report(var sl :TStringList);
published
property MajorVersion :integer read FMajorVersion write FMajorVersion stored false;
property MinorVersion :integer read FMinorVersion write FMinorVersion stored false;
property BuildNumber :integer read FBuildNumber write FBuildNumber stored false;
property Platform :string read FPlatform write FPlatform stored false;
property Version :string read FVersion write FVersion stored false;
property CSD :string read FCSD write FCSD stored false;
property SerialNumber :string read FSerialNumber write FSerialNumber stored false;
property RegisteredUser :string read FRegUser write FRegUser stored false;
property RegisteredOrg :string read FRegOrg write FRegOrg stored false;
property TimeZone :string read FTimeZone write FTimeZone stored false;
property Environment :TStrings read FEnv write FEnv stored false;
property WinDir :string read FWinDir write FWinDir stored false;
property SysDir :string read FSysDir write FSysDir stored false;
property TempDir :string read FTempDir write FTempDir stored false;
// property SystemRes: Byte read GetSystemRes write SetNone;
// property GDIRes: Byte read GetGDIRes write SetNone;
// property UserRes: Byte read GetUserRes write SetNone;
end; TFileFlag = (fsCaseIsPreserved, fsCaseSensitive, fsUnicodeStoredOnDisk,
fsPersistentAcls, fsFileCompression, fsVolumeIsCompressed,
fsLongFileNames,
// following flags are valid only for Windows2000
fsEncryptedFileSystemSupport, fsObjectIDsSupport, fsReparsePointsSupport,
fsSparseFilesSupport, fsDiskQuotasSupport);
TFileFlags = set of TFileFlag; TDriveType = (dtUnknown, dtNotExists, dtRemovable, dtFixed, dtRemote, dtCDROM, dtRAMDisk); TDiskSign = string[2]; TDisk = class(TPersistent)
private
FDisk: TDiskSign;
FMediaPresent: Boolean;
FDriveType: TDriveType;
FSectorsPerCluster: DWORD;
FBytesPerSector: DWORD;
FFreeClusters: DWORD;
FTotalClusters: DWORD;
FFileFlags: TFileFlags;
FVolumeLabel: string;
FSerialNumber: string;
FFileSystem: string;
FFreeSpace: int64;
FCapacity: int64;
FAvailDisks: string;
FSerial: dword;
FModel: string;
function GetMediaPresent: Boolean;
protected
procedure SetDisk(const Value: TDiskSign);
public
procedure GetInfo;
function GetDriveTypeStr(dt :TDriveType) :string;
procedure GetFileFlagsStr(AClear :boolean; var AFileFlags :TStringList);
procedure Report(var sl :TStringList);
function GetCD :byte;
property Serial :dword read FSerial write FSerial stored false;
published
property Drive :TDiskSign read FDisk write SetDisk stored false;
property AvailableDisks :string read FAvailDisks write FAvailDisks stored false;
property MediaPresent :Boolean read GetMediaPresent write FMediaPresent stored false;
property DriveType :TDriveType read FDriveType write FDriveType stored false;
property FileFlags :TFileFlags read FFileFlags write FFileFlags stored false;
property FileSystem :string read FFileSystem write FFileSystem stored false;
property FreeClusters :DWORD read FFreeClusters write FFreeClusters stored false;
property TotalClusters :DWORD read FTotalClusters write FTotalClusters stored false;
// FreeSpace and Capacity returns good results for Win95 OSR2, Win98, NT and 2000
// for Win95 there can be bad sizes for drives over 2GB
property FreeSpace :int64 read FFreeSpace write FFreeSpace stored false;
property Capacity :int64 read FCapacity write FCapacity stored false;
property SerialNumber :string read FSerialNumber write FSerialNumber stored false;
property VolumeLabel :string read FVolumeLabel write FVolumeLabel stored false;
property SectorsPerCluster :DWORD read FSectorsPerCluster write FSectorsPerCluster stored false;
property BytesPerSector :DWORD read FBytesPerSector write FBytesPerSector stored false;
property Model: string read FModel write FModel stored False;
end; TWorkstation = class(TPersistent)
private
FName: string;
FLastBoot: TDatetime;
FUser: string;
FSystemUpTime: Extended;
FBIOSExtendedInfo: string;
FBIOSCopyright: string;
FBIOSName: string;
FBIOSDate: string;
FScrollLock: Boolean;
FNumLock: Boolean;
FCapsLock: Boolean;
function GetSystemUpTime: Extended;
public
procedure GetInfo;
procedure Report(var sl :TStringList);
published
property Name :string read FName write FName stored false;
property User :string read FUser write FUser stored false;
property SystemUpTime :Extended read FSystemUpTime write FSystemUpTime stored false;
property LastBoot :TDatetime read FLastBoot write FLastBoot stored false;
property BIOSCopyright :string read FBIOSCopyright write FBIOSCopyright stored false;
property BIOSDate :string read FBIOSDate write FBIOSDate stored false;
property BIOSExtendedInfo :string read FBIOSExtendedInfo write FBIOSExtendedInfo stored false;
property BIOSName :string read FBIOSName write FBIOSName stored false;
property CapsLock: Boolean read FCapsLock write FCapsLock stored false;
property NumLock: Boolean read FNumLock write FNumLock stored false;
property ScrollLock: Boolean read FScrollLock write FScrollLock stored false;
end; TWinsock = class(TPersistent)
private
FDesc: string;
FStat: string;
FMajVer: word;
FMinVer: word;
public
procedure GetInfo;
published
property Description: string read FDesc write FDesc stored False;
property MajorVersion: word read FMajVer write FMajVer stored False;
property MinorVersion: word read FMinVer write FMinVer stored False;
property Status: string read FStat write FStat stored False;
end; TNetwork = class(TPersistent)
private
FIPAddress: string;
FAdapter: TStrings;
FWinsock: TWinsock;
function GetLocalIP :string;
public
constructor Create;
destructor Destroy; override;
procedure GetInfo;
procedure Report(var sl :TStringList);
published
property IPAddress :string read FIPAddress write FIPAddress stored false;
property Adapter :TStrings read FAdapter write FAdapter stored false;
property WinSock: TWinsock read FWinsock write FWinsock;
end; TCurveCap = (ccCircles,ccPieWedges,ccChords,ccEllipses,ccWideBorders,ccStyledBorders,
ccWideStyledBorders,ccInteriors,ccRoundedRects);
TLineCap = (lcPolylines,lcMarkers,lcMultipleMarkers,lcWideLines,lcStyledLines,
lcWideStyledLines,lcInteriors);
TPolygonCap = (pcAltFillPolygons,pcRectangles,pcWindingFillPolygons,pcSingleScanlines,
pcWideBorders,pcStyledBorders,pcWideStyledBorders,pcInteriors);
TRasterCap = (rcRequiresBanding,rcTranserBitmaps,rcBitmaps64K,rcSetGetDIBits,
rcSetDIBitsToDevice,rcFloodfills,rcWindows2xFeatures,rcPaletteBased,
rcScaling,rcStretchBlt,rcStretchDIBits);
TTextCap = (tcCharOutPrec,tcStrokeOutPrec,tcStrokeClipPrec,tcCharRotation90,
tcCharRotationAny,tcScaleIndependent,tcDoubledCharScaling,tcIntMultiScaling,
tcAnyMultiExactScaling,tcDoubleWeightChars,tcItalics,tcUnderlines,
tcStrikeouts,tcRasterFonts,tcVectorFonts,tcNoScrollUsingBlts); TCurveCaps = set of TCurveCap;
TLineCaps = set of TLineCap;
TPolygonCaps = set of TPolygonCap;
TRasterCaps = set of TRasterCap;
TTextCaps = set of TTextCap; TVideo = class(TPersistent)
private
FVertRes: integer;
FColorDepth: integer;
FHorzRes: integer;
FBIOSDate: string;
FBIOSVersion: string;
FPixelDiagonal: integer;
FPixelHeight: integer;
FVertSize: integer;
FPixelWidth: integer;
FHorzSize: integer;
FTechnology: string;
FCurveCaps: TCurveCaps;
FLineCaps: TLineCaps;
FPolygonCaps: TPolygonCaps;
FRasterCaps: TRasterCaps;
FTextCaps: TTextCaps;
FMemory: TStrings;
FChipset: TStrings;
FAdapter: TStrings;
FDAC: TStrings;
FAcc: TStrings;
public
constructor Create;
destructor Destroy; override;
procedure GetInfo;
procedure GetCurveCapsStr(AClear :boolean; ACaps :TStringList);
procedure GetLineCapsStr(AClear :boolean; ACaps :TStringList);
procedure GetPolygonCapsStr(AClear :boolean; ACaps :TStringList);
procedure GetRasterCapsStr(AClear :boolean; ACaps :TStringList);
procedure GetTextCapsStr(AClear :boolean; ACaps :TStringList);
procedure Report(var sl :TStringList);
published
property Adapter :TStrings read FAdapter write FAdapter stored false;
property Accelerator :TStrings read FAcc write FAcc stored false;
property DAC :TStrings read FDAC write FDAC stored false;
property Chipset :TStrings read FChipset write FChipset stored false;
property Memory :TStrings read FMemory write FMemory stored false;
property HorzRes :integer read FHorzRes write FHorzRes stored false;
property VertRes :integer read FVertRes write FVertRes stored false;
property ColorDepth :integer read FColorDepth write FColorDepth stored false;
// BIOS info is available only under NT
property BIOSVersion :string read FBIOSVersion write FBIOSVersion stored false;
property BIOSDate :string read FBIOSDate write FBIOSDate stored false;
property Technology :string read FTechnology write FTechnology stored false;
// property HorzSize :integer read FHorzSize write FHorzSize stored false;
// property VertSize :integer read FVertSize write FVertSize stored false;
property PixelWidth :integer read FPixelWidth write FPixelWidth stored false;
property PixelHeight :integer read FPixelHeight write FPixelHeight stored false;
property PixelDiagonal :integer read FPixelDiagonal write FPixelDiagonal stored false;
property RasterCaps :TRasterCaps read FRasterCaps write FRasterCaps stored false;
property CurveCaps :TCurveCaps read FCurveCaps write FCurveCaps stored false;
property LineCaps :TLineCaps read FLineCaps write FLineCaps stored false;
property PolygonCaps :TPolygonCaps read FPolygonCaps write FPolygonCaps stored false;
property TextCaps :TTextCaps read FTextCaps write FTextCaps stored false;
end; TMedia = class(TPersistent)
private
FDevice: TStrings;
FAUX: string;
FMIDIIn: string;
FMixer: string;
FWAVEOut: string;
FWAVEIn: string;
FMIDIOut: string;
public
constructor Create;
destructor Destroy; override;
procedure GetInfo;
procedure Report(var sl :TStringList);
published
property Device :TStrings read FDevice write FDevice stored false;
property WAVEIn :string read FWAVEIn write FWAVEIn stored false;
property WAVEOut :string read FWAVEOut write FWAVEOut stored false;
property MIDIIn :string read FMIDIIn write FMIDIIn stored false;
property MIDIOut :string read FMIDIOut write FMIDIOut stored false;
property AUX :string read FAUX write FAUX stored false;
property Mixer :string read FMixer write FMixer stored false;
end; TDevices = class(TPersistent)
private
FKeyboard: string;
FMouse: string;
FSD: TStrings;
FSCSI: TStrings;
FUSB: TStrings;
FModem: TStrings;
FMonitor: TStrings;
FPrinter: TStrings;
FPort: TStrings;
public
constructor Create;
destructor Destroy; override;
procedure GetInfo;
procedure Report(var sl :TStringList);
published
property Monitor :TStrings read FMonitor write FMonitor stored false;
property Printer :TStrings read FPrinter write FPrinter stored false;
property Keyboard :string read FKeyboard write FKeyboard stored false;
property Mouse :string read FMouse write FMouse stored false;
property SystemDevice :TStrings read FSD write FSD stored false;
property USB :TStrings read FUSB write FUSB stored false;
property SCSI :TStrings read FSCSI write FSCSI stored false;
property Modem :TStrings read FModem write FModem stored false;
property Port :TStrings read FPort write FPort stored false;
end; TEngines = class(TPersistent)
private
FBDE: string;
FODBC: string;
public
procedure GetInfo;
procedure Report(var sl :TStringList);
published
property ODBC :string read FODBC write FODBC stored false;
property BDE :string read FBDE write FBDE stored false;
end; TAPM = class(TPersistent)
private
FBatteryLifePercent: Byte;
FBatteryLifeFullTime: DWORD;
FBatteryLifeTime: DWORD;
FACPowerStatus: string;
FBatteryChargeStatus: string;
public
procedure GetInfo;
procedure Report(var sl :TStringList);
published
property ACPowerStatus :string read FACPowerStatus write FACPowerStatus stored false;
property BatteryChargeStatus :string read FBatteryChargeStatus write FBatteryChargeStatus stored false;
property BatteryLifePercent :Byte read FBatteryLifePercent write FBatteryLifePercent stored false;
property BatteryLifeTime :DWORD read FBatteryLifeTime write FBatteryLifeTime stored false;
property BatteryLifeFullTime :DWORD read FBatteryLifeFullTime write FBatteryLifeFullTime stored false;
end; TDirectX = class(TPersistent)
private
FVersion: string;
FDirect3D: TStrings;
FDirectPlay: TStrings;
FDirectMusic: TStrings;
public
constructor Create;
destructor Destroy; override;
procedure GetInfo;
procedure Report(var sl :TStringList);
published
property Version :string read FVersion write FVersion stored false;
property Direct3D :TStrings read FDirect3D write FDirect3D stored false;
property DirectPlay :TStrings read FDirectPlay write FDirectPlay stored false;
property DirectMusic :TStrings read FDirectMusic write FDirectMusic stored false;
end; DSSystemInfo = class(TComponent)
private
FCPU: TCPU;
FMemory: TMemory;
FOS :TOperatingSystem;
FDisk :TDisk;
FWorkstation: TWorkstation;
FNetwork: TNetwork;
FVideo: TVideo;
FEngines: TEngines;
FDevices: TDevices;
FAPM :TAPM;
FAbout: string;
FDirectX: TDirectX;
FMedia: TMedia;
procedure SetAbout(const Value: string);
public
constructor Create(AOwner :TComponent); override;
destructor Destroy; override;
procedure Refresh; procedure WkstaInfoRefresh;
procedure OSInfoRefresh;
procedure CPUInfoRefresh;
procedure MemoryInfoRefresh;
procedure DisplayInfoRefresh;
procedure APMInfoRefresh;
procedure MediaInfoRefresh;
procedure NetInfoRefresh;
procedure DeviceInfoRefresh;
procedure EngInfoRefresh;
procedure DriveInfoRefresh;
procedure DiskInfoRefresh; procedure Report(var sl :TStringList);
published
property About :string read FAbout write SetAbout;
property CPU :TCPU read FCPU write FCPU;
property Memory :TMemory read FMemory write FMemory;
property OS :TOperatingSystem read FOS write FOS;
property Disk :TDisk read FDisk write FDisk;
property Workstation :TWorkstation read FWorkstation write FWorkstation;
property Network :TNetwork read FNetwork write FNetwork;
property Video :TVideo read FVideo write FVideo;
property Media :TMedia read FMedia write FMedia;
property Devices :TDevices read FDevices write FDevices;
property Engines :TEngines read FEngines write FEngines;
property APM :TAPM read FAPM write FAPM;
property DirectX :TDirectX read FDirectX write FDirectX;
end; function FormatSeconds(TotalSeconds :comp; WholeSecondsOnly,
DisplayAll, DTFormat :Boolean) :String;
function ReadVerInfo(const fn :string; var Desc :string) :string;
function ReadRegInfo(ARoot :hkey; AKey, AValue :string) :string;
function GetTimeStamp :TLargInt;
function GetTicksPerSecond(Iterations :Word) :Comp;
function GetWindowInfo(wh: hwnd): PWindow;
function GetFreeSysRes(SysRes: Word): Word;
procedure GetEnvironment(EnvList :tstringlist);
function GetWinSysDir: string; procedure Register; const
ID_Bit = $200000; // EFLAGS ID bit CPUVendorIDs :array[0..5] of string = ('GenuineIntel',
'UMC UMC UMC',
'AuthenticAMD',
'CyrixInstead',
'NexGenDriven',
'CentaurHauls'); CPUVendors :array[0..5] of string = ('Intel',
'UMC',
'AMD',
'Cyrix',
'NexGen',
'CentaurHauls'); {
FILE_SUPPORTS_ENCRYPTION =
FILE_SUPPORTS_OBJECT_IDS =
FILE_SUPPORTS_REPARSE_POINTS =
FILE_SUPPORTS_SPARSE_FILES =
FILE_VOLUME_QUOTAS =
} var
IsNT,IS95,Is98,Is2000,IsOSR2: Boolean;
WindowsUser, MachineName: string;
Platform: TPlatformType; implementation type
TLoadLibrary16 = function (LibraryName: PChar): THandle; stdcall;
TFreeLibrary16 = procedure (HInstance: THandle); stdcall;
TGetProcAddress16 = function (Hinstance: THandle; ProcName: PChar): Pointer; stdcall;
TQT_Thunk = procedure; cdecl; var
VLevel, VFamily, VModel, VStepping, VTyp :Byte;
VFeatures :LongInt; _LoadLibrary16 :TLoadLibrary16;
_FreeLibrary16 :TFreeLibrary16;
_GetProcAddress16 :TGetProcAddress16;
_QT_Thunk :TQT_Thunk;
hInst16: THandle;
SR: Pointer;
HKernel :Thandle;
idxLoadLibrary16,
idxFreeLibrary16,
idxGetProcAddress16 :dword; procedure LoadKernel16;
begin
HKernel:=GetModuleHandle('kernel32.dll');
idxLoadLibrary16:=35;
idxFreeLibrary16:=36;
idxGetProcAddress16:=37;
if HKernel<>0 then begin
@_LoadLibrary16:=getprocaddress(HKernel,@idxLoadLibrary16);
@_FreeLibrary16:=getprocaddress(HKernel,@idxFreeLibrary16);
@_GetProcAddress16:=getprocaddress(HKernel,@idxGetProcAddress16);
@_QT_Thunk:=getprocaddress(HKernel,pchar('QT_Thunk'));
end;
end; procedure FreeLibrary16(HInstance: THandle);
begin
if assigned(_FreeLibrary16) then
_FreeLibrary16(HInstance);
end; function GetProcAddress16(HInstance: THandle;
ProcName: PChar): Pointer;
begin
if assigned(_GetProcAddress16) then
result:=_GetProcAddress16(HInstance,ProcName)
else
result:=nil;
end; function LoadLibrary16(LibraryName: PChar): THandle;
begin
if assigned(_LoadLibrary16) then
result:=_LoadLibrary16(LibraryName)
else
result:=0;
end; procedure QT_Thunk;
begin
if assigned(_QT_Thunk) then
_QT_Thunk;
end; function GetFreeSysRes(SysRes: Word): Word;
var
Thunks: Array[0..$20] of Word;
begin
result:=0;
if HKernel=0 then
LoadKernel16;
Thunks[0]:=hInst16;
hInst16:=LoadLibrary16('user.exe');
if hInst16>32 then begin
FreeLibrary16(hInst16);
SR:=GetProcAddress16(hInst16,'GetFreeSystemResources');
if assigned(SR) then
asm
push SysRes // push arguments
mov edx, SR // load 16-bit procedure pointer
call QT_Thunk // call thunk
mov Result, ax // save the result
end
else
//raise Exception.Create('Can''t get address of GetFreeSystemResources!');
end else
//raise Exception.Create('Can''t load USER.EXE!');
end; procedure GetEnvironment(EnvList :tstringlist);
var
c,i :dword;
b :pchar;
s :string;
begin
EnvList.Clear;
c:=1024;
b:=GetEnvironmentStrings;
i:=0;
s:='';
while i
|
GoldBoy
一般會員 發表:7 回覆:13 積分:4 註冊:2004-06-08 發送簡訊給我 |
{ TMemory } procedure TMemory.GetInfo;
var
//*SI :TSysteminfo
SI :_SYSTEM_INFO;
MS :TMemoryStatus;
begin
ZeroMemory(@MS,SizeOf(MS));
MS.dwLength:=SizeOf(MS);
GlobalMemoryStatus(MS);
MemoryLoad:=MS.dwMemoryLoad;
PhysicalTotal:=MS.dwTotalPhys;
PhysicalFree:=MS.dwAvailPhys;
VirtualTotal:=MS.dwTotalVirtual;
VirtualFree:=MS.dwAvailVirtual;
PageFileTotal:=MS.dwTotalPageFile;
PageFileFree:=MS.dwAvailPageFile;
ZeroMemory(@SI,SizeOf(SI));
GetSystemInfo(SI);
AllocGranularity:=SI.dwAllocationGranularity;
MaxAppAddress:=DWORD(SI.lpMaximumApplicationAddress);
MinAppAddress:=DWORD(SI.lpMinimumApplicationAddress);
PageSize:=DWORD(SI.dwPageSize);
end; procedure TMemory.Report(var sl: TStringList);
begin
with sl do begin
add(formatfloat('Physical Memory Total: #,## B',PhysicalTotal));
add(formatfloat('Physical Memory Free: #,## B',PhysicalFree));
add(formatfloat('Page File Total: #,## B',PageFileTotal));
add(formatfloat('Page File Free: #,## B',PageFileFree));
add(formatfloat('Virtual Memory Total: #,## B',VirtualTotal));
add(formatfloat('Virtual Memory Free: #,## B',VirtualFree));
add('');
add(formatfloat('Allocation Granularity: #,## B',AllocGranularity));
add(format('Application Addres Range: %s - %s',[inttohex(MinAppAddress,8),inttohex(MaxAppAddress,8)]));
add(formatfloat('Page Size: #,## B',PageSize));
end;
end; { TOperatingSystem } constructor TOperatingSystem.Create;
begin
inherited;
FEnv:=TStringList.Create;
end; destructor TOperatingSystem.Destroy;
begin
FEnv.Free;
inherited;
end; procedure TOperatingSystem.GetEnvironment;
var
c,i :dword;
b :pchar;
s :string;
begin
FEnv.Clear;
c:=1024;
b:=GetEnvironmentStrings;
i:=0;
s:='';
while i
|
pcboy
版主 發表:177 回覆:1838 積分:1463 註冊:2004-01-13 發送簡訊給我 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |