我是想知道cpu的使用情况,如现在cpu使用百分之几(象nt中的任务管理器一样)

解决方案 »

  1.   

    放弃吧,delphi本来就不是专门针对低层的
    这样岂不是高射炮打蚊子?
      

  2.   

    看了一下taskmgr.exe,里面好像有几个函数:
    NtQuerySystemInformation().....找了好久,居然没有这个API?
      

  3.   

    我这里有老帖子一篇,不知道还能用否?
    不过就算这帖子是错的,也不是象
    guest(俺们来做客的,喜欢吃"炒猪肝")说的: 
    放弃吧,delphi本来就不是专门针对低层的
    这样岂不是高射炮打蚊子?在一般要求下,在delphi里面内嵌汇编都可以,写vxd也可以,还有什么不能做的吗?帖子如下:
    function LoadLibrary16(LibraryName: PChar): THandle; stdcall; external kernel32 index 35; 
    procedure FreeLibrary16(HInstance: THandle); stdcall; external kernel32 index 36; 
    function GetProcAddress16(Hinstance: THandle; ProcName: PChar): Pointer; stdcall; external kernel32 index 37; 
    procedure QT_Thunk; cdecl; external kernel32 name 'QT_Thunk'; function GetFreeSysRes(SysRes: Word): Word; 
    var 
    Thunks: Array[0..$20] of Word; 
    begin 
    Thunks[0] := hInst16; 
    hInst16 := LoadLibrary16('user.exe'); 
    if hInst16 < 32 then 
    raise Exception.Create('Can''t load USER.EXE!'); 
    FreeLibrary16(hInst16); 
    SR := GetProcAddress16(hInst16, 'GetFreeSystemResources'); 
    if SR = nil then 
    raise Exception.Create('Can''t get address of GetFreeSystemResources!'); 
    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; 
    end; function TResMeter.GetSystemRes: Byte; 
    begin 
    Result := GetFreeSysRes(cSystemRes); 
    end; function TResMeter.GetGDIRes: Byte; 
    begin 
    Result := GetFreeSysRes(cGDIRes); 
    end; function TResMeter.GetUSERRes: Byte; 
    begin 
    Result := GetFreeSysRes(cUSERRes); 
    end;