Q&A

  • Win98에서 되던 소스가 Win2000에서 안되요
Win98에서 되던 소스가 Win2000에서 안되요..
16비트와 32비트의 차이 같은데..고수님들 도와 주세요 ^^

function LoadLibrary32(LibraryName: PChar): THandle; stdcall; external
         kernel32 index 35;
procedure FreeLibrary32(HInstance: THandle); stdcall; external
         kernel32 index 36;
function GetProcAddress32(Hinstance: THandle; ProcName: PChar):
        Pointer; stdcall; external kernel32 index 37;
procedure QT_Thunk; cdecl; external kernel32 name 'QT_Thunk';


function GetResourcesDisp(var GMemPer, UMemPer: String): String;
var
  RetRes1, RetRes2: DWord;
begin
  RetRes1 := GetFreeSystemResources(Gfsr_GdiResources);
  RetRes2 := GetFreeSystemResources(Gfsr_UserResources);

  GMemPer := FormatFloat('##0%', RetRes1);
  UMemPer := FormatFloat('##0%', RetRes2);

  Result := '자원(G:' + FormatFloat('#00%', RetRes1) + '/' +
                 'U:' + FormatFloat('#00%', RetRes2) + ')';

end;

function GetFreeSystemResources(SysResource: Word): DWord;
var
  ThunkTrash: array[0..$20] of DWord;
begin
  ThunkTrash[0] := hInst16;
  hInst16 := LoadLibrary32('user.exe');
  if hInst16 < 32 then
     raise Exception.Create('Cannot load USER.EXE');
  FreeLibrary32(hInst16);

  GFSR := GetProcAddress32(hInst16, 'GetFreeSystemResources');
  if GFSR = nil then
     raise Exception.Create('Cannot get address of GetFreeSystemResources');

  asm
    push SysResource  {push arguments}
    mov edx, GFSR     {load 16-bit procedure pointer}
    call QT_Thunk     {call thunk}
    mov Result, EAX    {save the result}
  end;
end;
0  COMMENTS