Прочитать свойства системы

Материал из DRKB

Прочитать свойства системы[править | править код]

{
  The SYSTEM_INFO structure contains information about the current computer
  system. This includes the architecture and type of the processor, the number of
  processors in the system, the page size, and other such information.
}
procedure TForm1.Button1Click(Sender: TObject);
var
  SysInfo: TSystemInfo;
begin
  GetSystemInfo(SysInfo);
  with ListBox1.Items, SysInfo do
  begin
    Add('ProcessorArchitecture:' + IntToStr(wProcessorArchitecture));
    Add(FloatToStr(dwPageSize) + ' Kb page size');
    Add(Format('Lowest memory address accessible to applications and DLL - %p',
      [lpMinimumApplicationAddress]));
    Add(Format('Highest memory address accessible to applications and DLL - %p',
      [lpMaximumApplicationAddress]));
    Add('OEMID:' + IntToStr(dwOemId));
    Add('ActiveProcessorMask:' + IntToStr(dwActiveProcessorMask));
    Add(IntToStr(dwNumberOfProcessors) + ' - number of processors');
    Add('ProcessorType:' + IntToStr(dwProcessorType));
    case wProcessorLevel of
      3: Add('Intel 80386 processor level');
      4: Add('Intel 80486 processor level');
      5: Add('Intel Pentium processor level');
    end;
    Add(FloatToStr(dwAllocationGranularity / 1024) +
      ' Kb - granularity with which virtual memory is allocated');
    Add('ProcessorRevision:' + IntToStr(wProcessorRevision));
  end;
end;


Source: Взято с сайта: http://www.swissdelphicenter.ch
ID: 01629



Часто при создании систем привязки программ к компьютеру или окон типа System Info или About Box необходимо определить данные о пользователе и о системе. Это можно сделать следующим образом (из примеров по Delphi - программа COA):


var
  Buffer: Array[0..30] of Char;    // Буфер под ASCIIZ строку
begin
  // Открыли библиотеку User
  hInstUser := LoadLibrary('USER');
  LoadString(hInstUser, 514, Buffer, 30);
  // Имя пользователя
  LabelUserName.Caption := StrPas(Buffer);
  LoadString(hInstUser, 515, Buffer, 30);
  FreeLibrary(hInstUser);
  // Компания
  LabelCompName.Caption := StrPas(Buffer);
  WinVer := GetVersion;
  // Версия Windows
  LabelWinVer.Caption := Format('Windows %u.%.2u',
         [LoByte(LoWord(WinVer)), HiByte(LoWord(WinVer))]);
  // Версия DOS
  LabelDosVer.Caption := Format('DOS %u.%.2u',
         [HiByte(HiWord(WinVer)), LoByte(HiWord(WinVer))]);
  WinFlags := GetWinFlags;
  // Режим
  if WinFlags AND WF_ENHANCED > 0 then
    LabelWinMode.Caption := '386 Enhanced Mode'
  else if WinFlags AND WF_PMODE > 0 then
    LabelWinMode.Caption := 'Standard Mode'
  else
    LabelWinMode.Caption := 'Real Mode';
  // Сопроцессор
  if WinFlags AND WF_80x87 > 0 then
    ValueMathCo.Caption := 'Present'
  else
    ValueMathCo.Caption := 'Absent';

  // Свободно ресурсов
  Fmt := GetFreeSystemResources(GFSR_SYSTEMRESOURCES);
  ValueFSRs.Caption := Format('%d%% Free', [Fmt1]);
  // Свободно памяти
  ValueMemory.Caption := FormatFloat(',#######', MemAvail DIV 1024) + ' KB Free';
end;


Source: http://delphiworld.narod.ru
ID: 01630