Sabtu, 19 Maret 2011

Menampilkan informasi sistem komputer

function TForm1.PCinfo:string;
const typstr:array[DRIVE_REMOVABLE..DRIVE_RAMDISK] of string[9]=
    ('Removable','Fixed','Network','CD-ROM','RAM');
var str:string;
    ov:_osversioninfoa;
    buf:array[0..255]of char;
    tmp,tmp2,tmp3:int64;
    tmp4:cardinal;
    st:_systemtime;
    ms:tmemorystatus;
    c:char;
    typ:integer;
begin
  str:=' Server Info '+#10#10'Server path:'#10'  '+paramstr(0)+#13#10'OS type:'#10'   Windows ';
  ov.dwOSVersionInfoSize:=sizeof(_osversioninfoa);
  getversionex(ov);
  case ov.dwPlatformId of
    VER_PLATFORM_WIN32s: str:=str+'3.1 + Win32s ';
    VER_PLATFORM_WIN32_WINDOWS: if ov.dwMinorVersion=10 then str:=str+'98 ' else if ov.dwMinorVersion=0 then str:=str+'95 ' else str:=str+'9X or better ';
    VER_PLATFORM_WIN32_NT: str:=str+'NT';
  end;
  str:=str+inttostr(ov.dwMajorVersion)+'.'+inttostr(ov.dwMinorVersion)+'.'+inttostr(loword(ov.dwBuildNumber))+' ('+ov.szCSDVersion+')'#10#10+'Windows directory:  ';
  getwindowsdirectory(buf,255);
  str:=str+buf+#10+'System directory:  ';
  getsystemdirectory(buf,255);
  str:=str+buf+#10+'Temporary directory:  ';
  gettemppath(255,buf);
  str:=str+buf;
  str:=str+#10#10'Mouse: ';
  tmp4:=getsystemmetrics(SM_CMOUSEBUTTONS);
  if tmp4=0 then str:=str+'Not installed' else str:=str+' Present ('+inttostr(tmp4)+' buttons)';
  str:=str+#10'Screen resolution:  '+inttostr(getsystemmetrics(SM_CXSCREEN))+'x'+inttostr(getsystemmetrics(SM_CYSCREEN));
  getlocaltime(st);
  str:=str+#10'Current time:  '+inttostr(st.wHour)+':'+inttostr(st.wMinute);
  ms.dwLength:=sizeof(ms);
  globalmemorystatus(ms);
  str:=str+#10'RAM:  '+inttostr(ms.dwTotalPhys div 1000)+' Kb';
  tmp4:=255; getusername(@buf,tmp4);
  str:=str+#10'User Name:  '+buf;
  tmp4:=255; getcomputername(@buf,tmp4);
  str:=str+#10'Computer Name: '+buf;
  str:=str+#10'Computer is on for '+inttostr(gettickcount div 60000)+' min ( >'+inttostr(gettickcount div (60000*60))+' h)'#10;
  str:=str+#10'Drives:'#10;
  for c:='A' to 'Z' do begin
    typ:=getdrivetype(pchar(c+':\'));
    if typ>1 then begin
      if ((ov.dwPlatformId=VER_PLATFORM_WIN32_WINDOWS)and((ov.dwMinorVersion>=10)or(ov.dwBuildNumber>1000)))or(ov.dwPlatformId=VER_PLATFORM_WIN32_NT) then begin
        if ((typ=DRIVE_FIXED)or(typ=DRIVE_REMOTE)or(typ=DRIVE_RAMDISK)) then begin
          getdiskfreespaceex(pchar(c+':\'),tmp,tmp2,@tmp3);
          str:=str+'   '+c+': '+typstr[typ]+'  (Size: '+inttostr(tmp2 div 1000000)+' Mb; Free: '+inttostr(tmp3 div 1000000)+' Mb)'#10;
        end else begin
          str:=str+'   '+c+': '+typstr[typ]+#10;
        end;
      end else begin
        str:=str+'   '+c+': '+typstr[typ]+#10;
      end;
    end;
  end;
  result:=str+#13;

end;

procedure TForm1.Button1Click(Sender: TObject);
begin
Showmessage(pcinfo);
end;

Tidak ada komentar:

Posting Komentar