09. december 2001 - 22:39Der er
42 kommentarer og 2 løsninger
CPUSpeed - Ram - Netkort mb ind/ud
jeg har lige at par spms :).. håber de kan lade sig gører
hvordan kan man finde ud af hvor meget af ens cpu der bliver brugt og evt hvor hurtig den er...
noget med hvor meget ens netkort har sendt og modtaget (mb ind/ud) og om det kører 10, 100 eller 1.000 MBit :)
og hvor meget ram totalt og brugt...
det er da bare nogle cmds ikke ??? for hvis det bare er noget ala SysInfo.CPUSpeed og så får man total speed på ens cpu så er det nok... så skal jeg nok selv sette dem ind i en overordnet sammenhæng .. for jeg er vad at lave et lille sjovt prog der kan lave nogle grafer over hvor meget spu og ram der bliver brugt.. så kan man jo have det kørende i bg og så laver den lidt smukke grafer :)
jeg har me... men det ville være lidt fede hvis det sådan kunne være til mutible systemer...
og forresten en string der finder Os navn ville heller ikke skade :) .. hvis i vil have en smule flere points for det så kan jeg da smide en 10-20 oveni :)
function GetWinVersion: String; var VersionInfo : TOSVersionInfo; OSName : String; SerStr : String; begin VersionInfo.dwOSVersionInfoSize := SizeOf( TOSVersionInfo ); if Windows.GetVersionEx( VersionInfo ) then begin with VersionInfo do begin case dwPlatformId of VER_PLATFORM_WIN32s : OSName := \'Win32s\'; VER_PLATFORM_WIN32_WINDOWS : OSName := \'Windows 9x\'; VER_PLATFORM_WIN32_NT : OSName := \'Windows NT\'; end; if VersionInfo.dwPlatformId = VER_PLATFORM_WIN32_WINDOWS then if VersionInfo.dwMinorVersion = 0 then begin OSName := \'Windows 95\' ; end; if VersionInfo.dwMinorVersion = 10 then begin if versioninfo.szCSDVersion[1] = \'A\' then begin OSName := \'Windows 98 SE\'; end else OSName := \'Windows 98\'; end; end; if VersionInfo.dwMinorVersion = 90 then begin OSName := \'Windows Me\' ; end; End;
if VersionInfo.dwPlatformId = VER_PLATFORM_WIN32_NT then begin if VersionInfo.dwMajorVersion = 5 then begin if VersionInfo.dwMinorVersion = 0 then begin OSNAme := \'Windows 2000\'; end; if VersionInfo.dwMinorVersion = 1 then OSName := \'Windows XP\'; end; if VersionInfo.dwMajorVersion = 6 then begin OSName := \'Windows XP\'; end; end else begin OSName := \'Windows NT Version \' + IntToStr( VersionInfo.dwMajorVersion ) + \'.\' + IntToStr( VersionInfo.dwMinorVersion ); end; if VersionInfo.szCSDVersion <> \'\' then begin SerStr := \' (Build \' + IntToStr( VersionInfo.dwBuildNumber ) + \': \' + VersionInfo.szCSDVersion + \')\'; end else begin SerStr := \' (Build \' + IntToStr( VersionInfo.dwBuildNumber ) + \')\'; end; if OSName <> \'\' then begin Result := OSName + SerStr; end else begin Result := \'\'; end; end;
nåeh ja...jeg har da også en-eller-anden cpuspeed ting....
Function GetCpuSpeed : Real; Function IsCPUID_Available : Boolean;assembler;register; asm PUSHFD POP EAX MOV EDX,EAX XOR EAX,$200000 PUSH EAX POPFD PUSHFD POP EAX XOR EAX,EDX JZ @exit MOV AL,true @exit: end;
const Delay = 500;
var TimerHi, TimerLo: Integer; PriorityClass, Priority: Integer; Begin Result := 0; if not IsCPUID_Available then exit; PriorityClass := GetPriorityClass(GetCurrentProcess); Priority := GetThreadPriority(GetCurrentThread);
hmm damit hvordan fanden skal man da også regne sig ud til alle de ting :(
men den cpu tig finder den ud af total cpu speed.. eller det speed der bliver brugt lige nu ...
for programmet skal enlig komme til at ligne den der er i Win NT/2000 hvor man kan se hvor meget ram der bliver brugt og er totalt og hvor meget cpu bliver brugt og er i alt :)
function GetVersionEx; external kernel32 name \'GetVersionExA\';
{ TTimeZone }
type TRegTimeZoneInfo = packed record Bias: Longint; StandardBias: Longint; DaylightBias: Longint; StandardDate: TSystemTime; DaylightDate: TSystemTime; end;
function ReverseString(const AText: string): string; var I: Integer; P: PChar; begin SetLength(Result, Length(AText)); P := PChar(Result); for I := Length(AText) downto 1 do begin P^ := AText[I]; Inc(P); end; end;
function GetTZDaylightSavingInfoForYear(TZ: TTimeZoneInformation; year: word; var DaylightDate, StandardDate: TDateTime; var DaylightBias, StandardBias: longint): boolean; begin Result:=false; try if (TZ.DaylightDate.wMonth <> 0) and (TZ.StandardDate.wMonth <> 0) then begin DaylightDate:=DSTDate2Date(TZ.DaylightDate,year); StandardDate:=DSTDate2Date(TZ.StandardDate,year); DaylightBias:=TZ.Bias+TZ.DaylightBias; StandardBias:=TZ.Bias+TZ.StandardBias; Result:=true; end; except end; end;
function CompareSysTime(st1, st2: TSystemTime): integer; begin if st1.wYear<st2.wYear then Result:=-1 else if st1.wYear>st2.wYear then Result:=1 else if st1.wMonth<st2.wMonth then Result:=-1 else if st1.wMonth>st2.wMonth then Result:=1 else if st1.wDayOfWeek<st2.wDayOfWeek then Result:=-1 else if st1.wDayOfWeek>st2.wDayOfWeek then Result:=1 else if st1.wDay<st2.wDay then Result:=-1 else if st1.wDay>st2.wDay then Result:=1 else if st1.wHour<st2.wHour then Result:=-1 else if st1.wHour>st2.wHour then Result:=1 else if st1.wMinute<st2.wMinute then Result:=-1 else if st1.wMinute>st2.wMinute then Result:=1 else if st1.wSecond<st2.wSecond then Result:=-1 else if st1.wSecond>st2.wSecond then Result:=1 else if st1.wMilliseconds<st2.wMilliseconds then Result:=-1 else if st1.wMilliseconds>st2.wMilliseconds then Result:=1 else Result:=0; end;
function IsEqualTZ(tz1, tz2: TTimeZoneInformation): boolean; begin Result:=(tz1.Bias=tz2.Bias) and(tz1.StandardBias=tz2.StandardBias) and (tz1.DaylightBias=tz2.DaylightBias) and (CompareSysTime(tz1.StandardDate,tz2.StandardDate)=0) and (CompareSysTime(tz1.DaylightDate,tz2.DaylightDate)=0) and (WideCharToString(tz1.StandardName)=WideCharToString(tz2.StandardName)) and (WideCharToString(tz1.DaylightName)=WideCharToString(tz2.DaylightName)); end;
with TRegistry.create do begin rootkey:=HKEY_LOCAL_MACHINE;
if IsNT then TZKey:=rkNTTimeZones else TZKey:=rk9xTimeZones;
if OpenKey(TZKey,False) then begin GetKeyNames(sl); CloseKey;
for i:=0 to sl.Count-1 do if OpenKey(TZKey+\'\\\'+sl[i],False) then begin if GetDataSize(\'TZI\')=SizeOf(RTZ) then begin ReadBinaryData(\'TZI\',RTZ,SizeOf(RTZ));
StringToWideChar(ReadString(\'Std\'),@RegTZ.StandardName,SizeOf(RegTZ.StandardName) div SizeOf(WideChar)); StringToWideChar(ReadString(\'Dlt\'),@RegTZ.DaylightName,SizeOf(RegTZ.DaylightName) div SizeOf(WideChar));
procedure TTimeZone.Report(var sl: TStringList); begin with sl do begin Add(\'[Time Zone]\'); Add(Format(\'TimeZone=%s\',[DisplayName])); Add(Format(\'StdName=%s\',[DateTimeToStr(StandardStart)])); Add(Format(\'StdBias=%d\',[StandardBias])); Add(Format(\'DlghtName=%s\',[DateTimeToStr(DaylightStart)])); Add(Format(\'DlghtBias=%d\',[DaylightBias])); end; end;
with TRegistry.create do begin rootkey:=HKEY_LOCAL_MACHINE;
if IsNT then OK:=OpenKey(rkOSInfoNT,False) else OK:=OpenKey(rkOSInfo95,False);
if OK then begin if isnt then begin if ValueExists(rvVersionNameNT) then FVersion:=ReadString(rvVersionNameNT); end else if ValueExists(rvVersionName95) then FVersion:=ReadString(rvVersionName95);
if ValueExists(rvRegOrg) then FRegOrg:=ReadString(rvRegOrg); if ValueExists(rvRegOwn) then FRegUser:=ReadString(rvRegOwn); if ValueExists(rvProductID) then FProductID:=ReadString(rvProductID); if ValueExists(rvProductKey) then FProductKey:=ReadString(rvProductKey); if ValueExists(rvDVD) then FDVD:=ReadString(rvDVD);
FCSDEx:=\'\'; if IsNT then begin FCSDEx:=FCSD; if CSD=\'Service Pack 6\' then if OpenKey(rkSP6a,False) then begin if ValueExists(rvInstalled) then if ReadInteger(rvInstalled)=1 then FCSD:=\'Service Pack 6a\'; CloseKey; end; end else if IsOSR2 then FCSDEx:=\'OSR 2\' else if IsSE then FCSDEx:=\'Second Edition\'; end; Free; end;
procedure TOperatingSystem.Report(var sl: TStringList); begin with sl do begin Add(\'[Operating System]\'); Add(Format(\'Platform=%s\',[Platform])); Add(Format(\'VersionName=%s\',[Version])); Add(Format(\'Version=%d.%d\',[MajorVersion,MinorVersion])); Add(Format(\'BuildNumber=%d\',[BuildNumber])); Add(Format(\'CSD=%s\',[CSD])); Add(Format(\'ProductID=%s\',[ProductID])); Add(Format(\'ProductKey=%s\',[ProductKey])); Add(Format(\'RegUser=%s\',[RegisteredUser])); Add(Format(\'RegOrganization=%s\',[RegisteredOrg])); Add(Format(\'DVDRegion=%s\',[DVDRegion])); NTSpecific.Report(sl); Add(\'[Environment]\'); AddStrings(Environment); Add(\'[Folders]\'); AddStrings(Folders); TimeZone.Report(sl); Internet.Report(sl); end; end;
{ TNTSpecific }
procedure TNTSpecific.GetInfo; var VersionInfo: TOSVersionInfoEx; OS :TOSVersionInfo; s: string; const rkProductTypeNT = {HKEY_LOCAL_MACHINE\\}\'System\\CurrentControlSet\\Control\\ProductOptions\'; rvProductType = \'ProductType\'; begin ZeroMemory(@OS,SizeOf(OS)); OS.dwOSVersionInfoSize:=SizeOf(OS); Windows.GetVersionEx(OS);
if (OS.dwPlatformId=VER_PLATFORM_WIN32_NT) and (OS.dwMajorVersion=5) then begin ZeroMemory(@VersionInfo,SizeOf(VersionInfo)); VersionInfo.dwOSVersionInfoSize:=SizeOf(VersionInfo);
if GetVersionEx(@VersionInfo) then begin case VersionInfo.wProductType of VER_NT_WORKSTATION: FProduct:=ptWorkStation; VER_NT_DOMAIN_CONTROLLER: FProduct:=ptAdvancedServer; VER_NT_SERVER: FProduct:=ptServer; end;
FSuites:=[];
if VersionInfo.wSuiteMask and VER_SUITE_SMALLBUSINESS=VER_SUITE_SMALLBUSINESS then FSuites:=FSuites+[suSmallBusiness]; if VersionInfo.wSuiteMask and VER_SUITE_ENTERPRISE=VER_SUITE_ENTERPRISE then FSuites:=FSuites+[suEnterprise]; if VersionInfo.wSuiteMask and VER_SUITE_BACKOFFICE=VER_SUITE_BACKOFFICE then FSuites:=FSuites+[suBackOffice]; if VersionInfo.wSuiteMask and VER_SUITE_COMMUNICATIONS=VER_SUITE_COMMUNICATIONS then FSuites:=FSuites+[suCommunications]; if VersionInfo.wSuiteMask and VER_SUITE_TERMINAL=VER_SUITE_TERMINAL then FSuites:=FSuites+[suTerminal]; if VersionInfo.wSuiteMask and VER_SUITE_SMALLBUSINESS_RESTRICTED=VER_SUITE_SMALLBUSINESS_RESTRICTED then FSuites:=FSuites+[suSmallBusinessRestricted]; if VersionInfo.wSuiteMask and VER_SUITE_EMBEDDEDNT=VER_SUITE_EMBEDDEDNT then FSuites:=FSuites+[suEmbeddedNT]; if VersionInfo.wSuiteMask and VER_SUITE_DATACENTER=VER_SUITE_DATACENTER then FSuites:=FSuites+[suDataCenter];
FSPMajorVer:=VersionInfo.wServicePackMajor; FSPMinorVer:=VersionInfo.wServicePackMinor; end; end; if FProduct=ptUnknown then with TRegistry.Create do begin if OpenKey(rkProductTypeNT,False) then begin s:=ReadString(rvProductType); if s=\'WinNT\' then FProduct:=ptWorkStation else if s=\'ServerNT\' then FProduct:=ptServer else if s=\'LanmanNT\' then FProduct:=ptAdvancedServer; CloseKey; end; Free; end; end;
function TNTSpecific.GetProductTypeStr(PT: TNTProductType): string; begin Result:=\'Unknown\'; case PT of ptWorkstation: Result:=\'Workstation\'; ptServer: Result:=\'Server\'; ptAdvancedServer: Result:=\'Advanced Server\'; end; end;
procedure TNTSpecific.Report(var sl: TStringList); begin with sl do begin Add(\'[NT Specific]\');
case ProductType of ptUnknown : Add(\'ProductType=Unknown\'); ptWorkStation : Add(\'ProductType=Workstation\'); ptServer : Add(\'ProductType=Server\'); ptAdvancedServer : Add(\'ProductType=Advanced Server\'); end;
procedure TNTSpecific.Report_InstalledSuites(var sl: TStringList); begin with sl do begin Add(Format(\'Microsoft Small Business Server=%d\', [integer(suSmallBusiness in InstalledSuites)])); Add(Format(\'Windows 2000 Advanced Server=%d\', [integer(suEnterprise in InstalledSuites)])); Add(Format(\'Microsoft BackOffice Components=%d\', [integer(suBackOffice in InstalledSuites)])); Add(Format(\'Communications=%d\', [integer(suCommunications in InstalledSuites)])); Add(Format(\'Terminal Services=%d\', [integer(suSmallBusiness in InstalledSuites)])); Add(Format(\'Microsoft Small Business Server with the restrictive client license in force=%d\', [integer(suSmallBusinessRestricted in InstalledSuites)])); Add(Format(\'Terminal Services=%d\', [integer(suSmallBusiness in InstalledSuites)])); Add(Format(\'Embedded NT=%d\', [integer(suEmbeddedNT in InstalledSuites)])); Add(Format(\'Windows 2000 Datacenter Server=%d\', [integer(suDataCenter in InstalledSuites)])); end; end;
function TInternet.GetConnTypeStr(ACType: TConnectionType): string; begin case ACType of ctNone : Result:=\'None\'; ctDialup : Result:=\'Dialup\'; ctLAN : Result:=\'LAN\'; end; end;
procedure TInternet.GetInfo; begin try FBrowser:=GetDefaultBrowser; except FBrowser:= \'\'; end;
procedure TInternet.Report(var sl: TStringList); begin with sl do begin Add(\'[Internet]\'); Add(Format(\'DefaultBrowser=%s\',[DefaultBrowser])); Add(Format(\'DefaultmailClient=%s\',[DefaultMailClient])); Add(Format(\'Connection=%s\',[GetConnTypeStr(ConnectionType)])); Add(Format(\'ProxyServer=%s\',[ProxyServer])); end; end;
type TCPUIDResult = packed record EAX: Cardinal; EBX: Cardinal; ECX: Cardinal; EDX: Cardinal; end;
TIntelCache = record L2Cache: Cardinal; CacheDescriptors: array[0..15] of Byte; end;
TAMDCache = record DataTLB: array[0..1] of Byte; InstructionTLB: array[0..1] of Byte; L1DataCache: array[0..3] of Byte; L1ICache: array[0..3] of Byte; end;
TCyrixCache = record L1CacheInfo: array[0..3] of Byte; TLBInfo: array[0..3] of Byte; end;
function GetCPUVendorID(AVendor, AFamily, AModel, ABrand, ATyp, AL2Cache, AFreq: integer; var Codename: string; var TranCount: integer): string; begin case AVendor of VENDOR_INTEL: begin case AFamily of 4: case AModel of 0, 1: begin Result := \'i80486DX\'; CodeName := \'P4\'; TranCount := 1250000; end;
2: begin Result := \'i80486SX\'; CodeName := \'P23\'; TranCount := 900000; end;
3: begin Result := \'i80486DX2\'; CodeName := \'P24\'; TranCount := 1250000; end;
4: begin Result := \'i80486SL\'; CodeName := \'P23\'; TranCount := 900000; end;
5: begin Result := \'i80486SX2\'; CodeName := \'P23\'; TranCount := 900000; end;
7: begin Result := \'i80486DX2WB\'; CodeName := \'P24\'; TranCount := 1250000; end;
8: begin Result := \'i80486DX4\'; CodeName := \'P24C\'; TranCount := 1600000; end;
9: begin Result := \'i80486DX4WB\'; CodeName := \'P24C\'; TranCount := 1600000; end; end; 5: case AModel of 0: begin Result := \'Pentium\'; CodeName := \'P5 (0,80µm)\'; TranCount := 3100000; end;
1, 2: begin Result := \'Pentium\'; CodeName := \'P54C (0,50µm)\'; TranCount := 3100000; end;
3: begin Result := \'Pentium\'; CodeName := \'P24T\'; TranCount := 0; end;
4: begin Result := \'Pentium MMX\'; CodeName := \'P55C (0,28µm)\'; TranCount := 4500000; end;
5: begin Result := \'DX4\'; CodeName := \'\'; TranCount := 0; end;
6: begin Result := \'Pentium\'; CodeName := \'P5\'; TranCount := 0; end;
7: begin Result := \'Pentium\'; CodeName := \'P54C (0,35µm)\'; TranCount := 3100000; end;
8: begin Result := \'Pentium MMX (mobile)\'; CodeName := \'Tillamook (0,25µm)\'; TranCount := 4500000; end; else begin Result := \'Pentium\'; CodeName := \'\'; TranCount := 0; end; end; 6: case AModel of 0: begin Result := \'Pentium Pro\'; CodeName := \'P6 (0.50 µm)\'; TranCount := 5500000; end;
1: begin Result := \'Pentium Pro\'; CodeName := \'P6 (0.35 µm)\'; TranCount := 5500000; end;
3: begin Result := \'Pentium II\';
if AL2Cache = 333 then CodeName := \'P6T (0.25 µm)\' else CodeName := \'Klamath (0.35 µm)\';
TranCount := 7500000;
if ATyp = 1 then Result := Result + \' OverDrive\'; end;
4: begin Result := \'Pentium II\'; Codename := \'P55CT (P54 OverDrive)\'; TranCount := 3100000; end;
5: if (AL2Cache <= 512) then begin if (AL2Cache = 0) then begin Result := \'Celeron\'; Codename := \'Covington (0,25µm)\'; TranCount := 7500000; end else begin Result := \'Pentium II\'; Codename := \'Deschutes (0,25µm)\'; TranCount := 7500000; end; end else begin Result := \'Pentium II Xeon\'; Codename := \'Deschutes (0.25 µm)\'; TranCount := 7500000; end;
6: if AL2Cache < 256 then begin Result := \'Celeron A\'; Codename := \'Mendocino (0.25 µm)\'; TranCount := 19000000; end else begin Result := \'Pentium II PE (mobile)\'; Codename := \'Dixon (0.25 µm)\'; TranCount := 27400000; end;
7: if AL2Cache <= 512 then begin Result := \'Pentium III\'; Codename := \'Katmai (0.25 µm)\'; TranCount := 9500000; end else begin Result := \'Pentium III Xeon\'; Codename := \'Tanner (0.25 µm)\'; TranCount := 9500000; end;
8: begin Result := \'Pentium III E\'; Codename := \'Coppermine (0.18 µm)\'; TranCount := 28100000; end; else begin Result := \'Pentium II\'; Codename := \'\'; TranCount := 0; end; end; 7, 8: case ABrand of 1: begin Result := \'Celeron\'; Codename := \'\'; TranCount := 0; end; 3: begin Result := \'Pentium III Xeon\'; Codename := \'\'; TranCount := 0; end; 4: begin Result := \'Pentium IV\'; Codename := \'\'; TranCount := 0; end; else begin if (AL2Cache < 1024) then Result := \'Pentium III\' else Result := \'Pentium III Xeon\'; Codename := \'\'; TranCount := 0; end; end; $A: begin Result := \'Pentium III Xeon\'; Codename := \'\'; TranCount := 0; end; $F: begin Result := \'Pentium IV\'; Codename := \'\'; TranCount := 0; end;
end; end;
VENDOR_AMD: begin case AFamily of 4: case AModel of 0: begin Result := \'Am486DX\'; Codename := \'P4\'; TranCount := 1250000; end; 3, 7: begin Result := \'Am486DX2\'; Codename := \'P24\'; TranCount := 1250000; end; 8, 9: begin Result := \'Am486DX4\'; Codename := \'P24C\'; TranCount := 1250000; end; 14, 15: begin Result := \'Am5x86\'; Codename := \'X5\'; TranCount := 1600000; end; end; 5: case AModel of 0: begin Result := \'K5\'; Codename := \'SSA5 (0.50-0.35 µm)\'; TranCount := 4300000; end; 1, 2, 3: begin Result := \'K5-5k86 (PR120, PR133)\'; Codename := \'5k86 (0.35 µm)\'; TranCount := 4300000; end; 6: begin Result := \'K6\'; Codename := \'K6 (0.30 µm)\'; TranCount := 8800000; end; 7: begin Result := \'K6\'; Codename := \'Little Foot (0.25 µm)\'; TranCount := 8800000; end; 8: begin Result := \'K6-II\'; Codename := \'Chomper (0.25 µm)\'; TranCount := 9300000; end; 9: begin Result := \'K6-III\'; Codename := \'Slarptooth (0.25 µm)\'; TranCount := 21300000; end; $D: begin Result := \'K6-II+/K6-III+\'; Codename := \'\'; TranCount := 0; end; end; 6: begin Result := \'K7\'; Codename := \'Athlon (0.25-0.18 µm)\'; TranCount := 22000000; end; end; end;
VENDOR_CYRIX: begin case AFamily of 4: case AModel of 0: begin if AFreq in [20, 66] then begin Result := \'Cx486SLC/DLC\'; Codename := \'M0.5\'; TranCount := 600000; end; if AFreq in [33, 50] then begin Result := \'Cx486S\'; Codename := \'M0.6\'; TranCount := 600000; end; if AFreq > 66 then begin Result := \'Cx486DX/DX2/DX4\'; Codename := \'M0.7\'; TranCount := 1100000; end; end; 4: begin Result := \'Media GX\'; Codename := \'Gx86\'; TranCount := 24000000; end; 9: begin Result := \'5x86\'; Codename := \'M0.9 or M1sc (0.65 µm)\'; TranCount := 20000000; end; end; 5: case AModel of 2: begin Result := \'6x86 and 6x86L\'; Codename := \'M1 (0.65 µm) and M1L (0.35 µm)\'; TranCount := 30000000; end; 4: begin Result := \'MediaGXm\'; Codename := \'GXm\'; TranCount := 24000000; end; end; 6: case AModel of 0: if AFreq < 225 then begin Result := \'6x86MX (PR166-266)\'; Codename := \'M2 (0.35 µm)\'; TranCount := 65000000; end else begin Result := \'M-II (PR300-433)\'; Codename := \'M2 (0.35-0.25 µm)\'; TranCount := 65000000; end; 5: begin Result := \'VIA Cyrix III\'; Codename := \'\'; TranCount := 0; end; end; end; end;
VENDOR_IDT: begin case AFamily of 5: case AModel of 4: begin Result := \'WinChip\'; Codename := \'C6 (0.35 µm)\'; TranCount := 54000000; end; 8: begin Result := \'WinChip 2x\'; Codename := \'W2x (0.35-0.25 µm)\'; TranCount := 59000000; end; 9: begin Result := \'WinChip 3\'; Codename := \'W3 (0.25 µm)\'; TranCount := 90000000; end; end; end; end;
VENDOR_NEXGEN: begin case AFamily of 5: case AModel of 0: begin Result := \'Nx586\'; Codename := \'Nx5x86 (0.50-0.44 µm)\'; TranCount := 35000000; end; 6: begin Result := \'Nx686\'; Codename := \'HA (0,50µm)\'; TranCount := 60000000; end; end; end; end;
VENDOR_UMC: begin case AFamily of 4: begin Codename := \'U5D and U5S\'; TranCount := 12000000; case AModel of 1: Result := \'U5D\'; 2: Result := \'U5S\'; 3: Result := \'U486DX2\'; 4: Result := \'U486SX2\'; end; end; end; end;
VENDOR_RISE: begin case AFamily of 4: case AModel of 0, 2: begin Result := \'mP6\'; Codename := \'mP6 (0.25-0.18 µm)\'; TranCount := 36000000; end; end; end; end; end; end;
function GetCPUIDSupport: Boolean; asm PUSHFD POP EAX MOV EDX, EAX XOR EAX, CPUIDID_BIT PUSH EAX POPFD PUSHFD POP EAX XOR EAX, EDX JZ @exit MOV AL, TRUE @exit: end;
function ExecuteCPUID: TCPUIDResult; assembler; asm PUSH EBX PUSH EDI MOV EDI, EAX MOV EAX, CPUID_LEVEL DW $A20F STOSD MOV EAX, EBX STOSD MOV EAX, ECX STOSD MOV EAX, EDX STOSD POP EDI POP EBX end;
function ExecuteIntelCache: TIntelCache; var Cache: TIntelCache; i: DWORD; TimesToExecute, CurrentLoop: Byte; begin asm PUSH EAX PUSH EBP PUSH EBX PUSH ECX PUSH EDI PUSH EDX PUSH ESI
MOV CurrentLoop, 0 PUSH ECX
@@RepeatCacheQuery: POP ECX MOV EAX, CPUID_CACHETLB DB 0FH DB 0A2H INC CurrentLoop CMP CurrentLoop, 1 JNE @@DoneCacheQuery MOV TimesToExecute, AL CMP AL, 0 JE @@Done
@@Done: POP ESI POP EDX POP EDI POP ECX POP EBX POP EBP POP EAX end;
Cache.L2Cache := 0;
for i := 1 to 15 do case Cache.CacheDescriptors[i] of $40: Cache.L2Cache := 0; $41: Cache.L2Cache := 128; $42, $82: Cache.L2Cache := 256; $43, $83: Cache.L2Cache := 512; $44, $84: Cache.L2Cache := 1024; $45, $85: Cache.L2Cache := 2048; end; Result := Cache; end;
function ExecuteAMDCache: TAMDCache; var Cache: TAMDCache; begin asm PUSH EAX PUSH EBP PUSH EBX PUSH ECX PUSH EDI PUSH EDX PUSH ESI
MOV EAX, CPUID_LEVEL1CACHETLB DB 0Fh DB 0A2h MOV WORD PTR [Cache.InstructionTLB], BX SHR EBX, 16 MOV WORD PTR [Cache.DataTLB], BX MOV DWORD PTR [Cache.L1DataCache], ECX MOV DWORD PTR [Cache.L1ICache], EDX
POP ESI POP EDX POP EDI POP ECX POP EBX POP EBP POP EAX end; Result := Cache; end;
function ExecuteCyrixCache: TCyrixCache; var Cache: TCyrixCache; begin asm PUSH EAX PUSH EBP PUSH EBX PUSH ECX PUSH EDI PUSH EDX PUSH ESI
MOV EAX, CPUID_LEVEL1CACHETLB DB 0Fh DB 0A2h MOV DWORD PTR [Cache.TLBInfo], EBX MOV DWORD PTR [Cache.L1CacheInfo], ECX
POP ESI POP EDX POP EDI POP ECX POP EBX POP EBP POP EAX end; Result := Cache; end;
function GetCPUSerialNumber: string;
function SplitToNibble(ANumber: string): string; begin Result := Copy(ANumber, 0, 4) + \'-\' + Copy(ANumber, 5, 4); end;
var SerialNumber: TCPUIDResult; begin Result := \'\'; CPUID_Level := CPUID_CPUSIGNATURE; SerialNumber := ExecuteCPUID; Result := SplitToNibble(IntToHex(SerialNumber.EAX, 8)) + \'-\'; CPUID_Level := CPUID_CPUSIGNATURE; SerialNumber := ExecuteCPUID; Result := Result + SplitToNibble(IntToHex(SerialNumber.EDX, 8)) + \'-\'; Result := Result + SplitToNibble(IntToHex(SerialNumber.ECX, 8)); end;
function RoundFrequency(const Frequency: Integer): Integer; overload; const NF: array[0..8] of Integer = (0, 20, 33, 50, 60, 66, 80, 90, 100); var Freq, RF: Integer; i: Byte; Hi, Lo: Byte; begin RF := 0; Freq := Frequency mod 100;
for i := 0 to 8 do begin if Freq < NF[i] then begin Hi := i; Lo := i - 1;
if (NF[Hi] - Freq) > (Freq - NF[Lo]) then RF := NF[Lo] - Freq else RF := NF[Hi] - Freq;
Break; end; end; Result := Frequency + RF; end;
function REGCPUGetSpeed: DWORD; var _cpufreq: DWORD; len: integer; rh: HKEY; pr: dword; begin result := 0;
if regOpenKeyEx(HKEY_LOCAL_MACHINE, \'HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0\', 0, KEY_READ, rh) = ERROR_SUCCESS then begin if RegQueryValueEx(rh, \'~MHz\', nil, @pr, @_cpufreq, @len) = ERROR_SUCCESS then Result := _cpufreq; RegCloseKey(rh); end; end;
function ASMGetCpuSpeed: DWORD; const Delay = 500; var TimerHi, TimerLo: Integer; begin ZeroMemory(@Result, sizeof(Result));
if not GetCPUIDSupport then Exit;
SleepEx(10, FALSE);
asm dw 0F31h { $0F31 op-code for RDTSC pentiun instruction returns a 64 Bit Integer} mov TimerLo, eax mov TimerHi, edx end;
SleepEx(Delay, FALSE);
asm dw 0F31h { $0F31 op-code for RDTSC pentiun instruction returns a 64 Bit Integer} sub eax, TimerLo sbb edx, TimerHi mov TimerLo, eax mov TimerHi, edx end;
Result := Trunc(TimerLo / (1000 * Delay)); end;
function GetCpuSpeed : Dword; begin Result := REGCPUGetSpeed; if Result = 0 then Result := ASMGetCpuSpeed; end; function GetVendor: string; var CPUName: array[0..11] of Char; begin asm PUSH EAX PUSH EBP PUSH EBX PUSH ECX PUSH EDI PUSH EDX PUSH ESI
CPUID_Level := CPUID_CPUSIGNATURE; CPUID := ExecuteCPUID; FFamily := CPUID.EAX shr 8 and $F; FTyp := CPUID.EAX shr 12 and 3; FModel := CPUID.EAX shr 4 and $F; FStepping := CPUID.EAX and $F; FBrand := LoByte(LoWord(CPUID.EBX));
CPUID_Level := CPUID_MAXLEVEL;
try CPUID := ExecuteCPUID; except end;
FLevel := CPUID.EAX;
try FVendorCPUID := GetVendor; except end;
FCPUVendor := VENDOR_UNKNOWN; FVendor := \'\';
for i := VENDOR_INTEL to VENDOR_RISE do if CPUVendorIDs[i] = Vendor_CPUID then begin FCPUVendor := i; FVendor := CPUVendors[i]; FVendorEx := CPUVendorsEx[i]; Break; end;
Features.GetInfo;
if Features.SERIAL then FSerial := GetCPUSerialNumber;
procedure TCPU.Report(var sl: TStringList); begin with sl do begin Add(\'[CPU]\'); Add(Format(\'Count=%d\', [Self.Count])); Add(Format(\'Frequency=%d\', [Frequency])); Add(Format(\'VendorID=%s\', [VendorID])); Add(Format(\'Vendor=%s\', [Vendor])); Add(Format(\'Family=%d\', [Family])); Add(Format(\'Model=%d\', [Model])); Add(Format(\'Stepping=%d\', [Stepping])); Add(Format(\'CodeName=%s\', [CodeName])); Add(Format(\'Transistors=%d\', [Transistors])); Add(Format(\'SerialNumber=%s\', [SerialNumber])); Add(Format(\'FDIVBug=%d\', [Integer(FDIVBug)]));
Features.Report(sl);
Cache.Report(sl); end; end;
{ TCPUCache }
procedure TCPUCache.GetInfo; var i: integer; begin FLevel1Data := 0; FLevel1Code := 0; FLevel1 := 0; FLevel2 := 0;
case AVendor of VENDOR_INTEL: begin IntelCache := ExecuteIntelCache; FLevel2 := IntelCache.L2Cache;
FLevel1Data := 0; for i := 0 to 15 do if (IntelCache.CacheDescriptors[i] in [$0A, $0C]) then begin if (IntelCache.CacheDescriptors[i] = $0A) then FLevel1Data := 8 else FLevel1Data := 16; end;
FLevel1Code := 0; for i := 0 to 15 do if (IntelCache.CacheDescriptors[i] in [$6, $8]) then begin if (IntelCache.CacheDescriptors[i] = $06) then FLevel1Code := 8 else FLevel1Code := 16; end;
FLevel1 := 0; for i := 0 to 15 do if (IntelCache.CacheDescriptors[i] = $80) then FLevel1 := 16; end;
VENDOR_CYRIX: begin CyrixCache := ExecuteCyrixCache; if $80 in [CyrixCache.L1CacheInfo[0], CyrixCache.L1CacheInfo[1], CyrixCache.L1CacheInfo[2], CyrixCache.L1CacheInfo[3]] then FLevel1 := 16; end;
function Init9xCPUData: Boolean; begin Reg:=TRegistry.Create; with Reg do try Rootkey:=HKEY_DYN_DATA; if OpenKey(StartStat,False) then begin GetDataType(ObjCounter); ReadBinaryData(ObjCounter,CPU9xUsage,GetDataSize(ObjCounter)); CloseKey; if not OpenKey(StatData,False) then raise Exception.Create(\'Unable to read performance data\'); end else raise Exception.Create(\'Unable to start performance monitoring\'); finally Result:=CurrentPath=StatData; end; end;
function Get9xCPUUsage: integer; begin with Reg do begin ReadBinaryData(ObjCounter,CPU9xUsage,4); end; Result:=Cpu9xUsage; end;
procedure Release9xCPUData; begin with Reg do begin CloseKey; if OpenKey(StopStat,False) then begin GetDataType(ObjCounter); GetDataType(ObjCounter); ReadBinaryData(ObjCounter,CPU9xUsage,GetDataSize(ObjCounter)); CloseKey; end; Free; end; end;
function InitNTCPUData: Boolean; var R: NTSTATUS; n: DWORD; begin n:=0; CPUNTUsage:=AllocMem(SizeOf(SYSTEM_PROCESSOR_TIMES)); R:=ZwQuerySystemInformation(SystemProcessorTimes,CPUNTUsage,SizeOf(SYSTEM_PROCESSOR_TIMES),nil); while R=STATUS_INFO_LENGTH_MISMATCH do begin Inc(n); ReallocMem(CPUNTUsage,n*SizeOf(CPUNTUsage^)); R:=ZwQuerySystemInformation(SystemProcessorTimes,CPUNTUsage,n*SizeOf(SYSTEM_PROCESSOR_TIMES),nil); end; CPUSize:=n*SizeOf(CPUNTUsage^); Result:=R=STATUS_SUCCESS; end;
function GetNTCPUUsage; begin ZwQuerySystemInformation(SystemProcessorTimes,CPUNTUsage,CPUSize,nil); Result:=CPUNTUsage^.IdleTime; end;
procedure ReleaseNTCPUData; begin Freemem(CPUNTUsage); end;
{ TMCPUUsage }
constructor TMCPUUsage.Create(AOwner: TComponent); begin inherited; Timer:=TTimer.Create(Self); Timer.Interval:=1000; Timer.Enabled:=False; if IsNT then FReady:=InitNTCPUData else FReady:=Init9xCPUData; if FReady then Timer.OnTimer:=OnTimer; end;
destructor TMCPUUsage.Destroy; begin Timer.Free; if FReady then begin if IsNT then ReleaseNTCPUData else Release9xCPUData; end; inherited; end;
function TMCPUUsage.GetActive: Boolean; begin Result:=Timer.Enabled; end;
function TMCPUUsage.GetInterval: DWORD; begin Result:=Timer.Interval; end;
procedure TMCPUUsage.OnTimer(Sender: TObject); var v: DWORD; begin if IsNT then begin FLastValue:=FValue; FValue:=GetNTCPUUsage; v:=Round((Timer100n-(FValue-FLastValue)/(Timer.Interval/Timer1s))/Timer100n*100); end else v:=Get9xCPUUsage; if Assigned(FOnInterval) then FOnInterval(Self,v); end;
procedure TMCPUUsage.SetActive(const Value: Boolean); begin Timer.Enabled:=Value and FReady; end;
procedure TMCPUUsage.SetInterval(const Value: DWORD); begin Timer.Interval:=Value; end;
initialization if IsNT then begin if NTDLL_DLL=0 then NTDLL_DLL:=GetModuleHandle(NTDLL_DLL_name); if NTDLL_DLL<>0 then @ZwQuerySystemInformation:=GetProcAddress(NTDLL_DLL,\'ZwQuerySystemInformation\'); end; end.
orv ja forresten der er et lille problem med TMemory hvis den bliver kaldet på WIN32s (32 Bits subsystem på en Windows 3.11). Så vil den benytte sig af Generic Thunk. For det skal lykkes skal flaget ONLYWIN9X sættes i DEF.inc
Det er altså ikke lige sådan noget man gør ... Hvis dit program fx er på over 100.000 linjer ... Og som regl betyder det at det skal skrives om fra bunden ...
Appropos gammel lort så er din CPU da vist ikke helt frisk ?
øhh hvis det ikke er for meget forlangt vil i så ikke sende mig en projekt med dem i ??
det vil enlig være lidt næmmere min mail er JRe@Kontor-Teknik.dk ellers lik et link til filerne
btw. jens din hp ser helt skæv ud hos mig din menu ligger helt uppe i hjørnet og man kan kun se 3 punkter på en gang :) og dit txt felt midt på siden er så smalt at man ikke kan se hvad der står i.. jeg briger IE 5 eller også er det 6
prøv at remme de forskellige klaser ud en efter en .... Ellers ved vi jo ikke hvor den falder ned ... Og uden den viden kan jeg UMULIGT hjælpe dig ....
hmmm så skal jeg jo til at lede vildt meget efter den :(... hmm well i kan få lidt point for det i har hjålpet mig med nu... så skal jeg vende tilbage når jeg har fundet min delphi cd...
btw. jeg sagde også til mine andre venner at de skulle prøve programmet og de får samme fejl :).. så det er ikke min comp der er noget galt med heheheheheh det er da altid noget :)
weee .. jeg har fundet min cd nu :) .. jeg får denne her fejl når jeg kører projektet inde i delphi : [Fatal Error] Project2.dpr(5): File not found: \'Devices.dcu\'
og denne her linie bliver higlightet
program Project2;
uses Forms, -------------------------------------- Unit1 in \'Unit1.pas\' {Form1}|her er min kurser|; -------------------------------------- {$R *.res}
begin Application.Initialize; Application.CreateForm(TForm1, Form1); Application.Run; end.
Hey jeg har side og set på de fine eksempler her og det ser ud til det er lige hvad jeg mangler men.. når jeg vil bruge det brokker delphi sig over at den ikke kan finde filen Routines.dcu har søgt mine diske i gennem men nej den er der ikke
/MB
Synes godt om
Ny brugerNybegynder
Din løsning...
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.