Have an amazing solution built in RAD Studio? Let us know. Looking for discounts? Visit our Special Offers page!
DelphiRAD Studio

Delphiを使用してWindowsからシステムBIOS情報を簡単に取得するには?

easily fetch system management bios info

登録キーを使用してアプリケーションを保護しようとしたことがありますか? 

もしそれを行いたい場合、さまざまな方法で実現することができます。(例えば、デバイスのシリアル番号などに基づいて登録キーを生成など)

あるいは、分析のためにデバイスに関するすべての情報を取得しようとしたことがありますか?

もしそれを行いたい場合、「TSMBIOS」というDelphi向けのオープンソースライブラリを利用することで、Object Pascal言語を使用してデバイスに関連するすべてのデータを取得することができます。

このライブラリがカバーしているSMBIOS(System Management BIOS)はDMTFによって策定された規格で、SMBIOSに保存される情報には、デバイスの製造元、モデル名、シリアル番号、BIOSバージョン、アセットタグ、プロセッサ、ポート、およびインストールされているデバイスメモリが含まれます。

TSMBIOSライブラリ

TSMBIOSライブラリは、以下のような特徴を持っています。

  • Delphi 2005以降で利用可能なヘルプインサイト機能と完全互換性をもつドキュメント
  • SMBIOSのバージョン(2.1 〜  2.8)をサポート
  • Windows、Linuxに対応
  • SMBIOSデータをファイルへの保存、読み込みが可能
  • SMBIOSデータは、リモートマシン(WMI経由)から取得可能

このライブラリの簡単な使い方は、以下の通りです。

{$APPTYPE CONSOLE}
 
{$R *.res}
 
uses
  Classes,
  SysUtils,
  uSMBIOS in '....CommonuSMBIOS.pas';
 
procedure GetMemoryDeviceInfo;
Var
  SMBios : TSMBios;
  LMemoryDevice  : TMemoryDeviceInformation;
begin
  SMBios:=TSMBios.Create;
  try
      WriteLn('Memory Device Information');
      WriteLn('-------------------------');
 
      if SMBios.HasPhysicalMemoryArrayInfo then
      for LMemoryDevice in SMBios.MemoryDeviceInformation do
      begin
        WriteLn(Format('Total Width    %d bits',[LMemoryDevice.RAWMemoryDeviceInfo.TotalWidth]));
        WriteLn(Format('Data Width     %d bits',[LMemoryDevice.RAWMemoryDeviceInfo.DataWidth]));
        WriteLn(Format('Size           %d Mbytes',[LMemoryDevice.GetSize]));
        WriteLn(Format('Form Factor    %s',[LMemoryDevice.GetFormFactor]));
        WriteLn(Format('Device Locator %s',[LMemoryDevice.GetDeviceLocatorStr]));
        WriteLn(Format('Bank Locator   %s',[LMemoryDevice.GetBankLocatorStr]));
        WriteLn(Format('Memory Type    %s',[LMemoryDevice.GetMemoryTypeStr]));
        WriteLn(Format('Speed          %d MHz',[LMemoryDevice.RAWMemoryDeviceInfo.Speed]));
        WriteLn(Format('Manufacturer   %s',[LMemoryDevice.ManufacturerStr]));
        WriteLn(Format('Serial Number  %s',[LMemoryDevice.SerialNumberStr]));
        WriteLn(Format('Asset Tag      %s',[LMemoryDevice.AssetTagStr]));
        WriteLn(Format('Part Number    %s',[LMemoryDevice.PartNumberStr]));
 
        WriteLn;
 
        if LMemoryDevice.RAWMemoryDeviceInfo.PhysicalMemoryArrayHandle>0 then
        begin
          WriteLn('  Physical Memory Array');
          WriteLn('  ---------------------');
          WriteLn('  Location         '+LMemoryDevice.PhysicalMemoryArray.GetLocationStr);
          WriteLn('  Use              '+LMemoryDevice.PhysicalMemoryArray.GetUseStr);
          WriteLn('  Error Correction '+LMemoryDevice.PhysicalMemoryArray.GetErrorCorrectionStr);
          if LMemoryDevice.PhysicalMemoryArray.RAWPhysicalMemoryArrayInformation.MaximumCapacity$80000000 then
            WriteLn(Format('  Maximum Capacity %d Kb',[LMemoryDevice.PhysicalMemoryArray.RAWPhysicalMemoryArrayInformation.MaximumCapacity]))
          else
            WriteLn(Format('  Maximum Capacity %d bytes',[LMemoryDevice.PhysicalMemoryArray.RAWPhysicalMemoryArrayInformation.ExtendedMaximumCapacity]));
 
          WriteLn(Format('  Memory devices   %d',[LMemoryDevice.PhysicalMemoryArray.RAWPhysicalMemoryArrayInformation.NumberofMemoryDevices]));
        end;
        WriteLn;
      end
      else
      Writeln('No Memory Device Info was found');
  finally
   SMBios.Free;
  end;
end;
 
 
begin
 try
    GetMemoryDeviceInfo;
 except
    on E:Exception do
        Writeln(E.Classname, ':', E.Message);
 end;
 Writeln('Press Enter to exit');
 Readln;
end.

TSMBIOSライブラリはオープンプロジェクトで、こちらから入手できます。なお、エンバカデロではこのライブラリに関するテクニカルサポートサービスは提供しておりません。

RAD Studio 13.1 Florence Now Available See What's New in RAD Studio 13.1 Delphi is 31 - Webinar Replay

Reduce development time and get to market faster with RAD Studio, Delphi, or C++Builder.
Design. Code. Compile. Deploy.

Start Free Trial   Upgrade Today

   Free Delphi Community Edition   Free C++Builder Community Edition

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

IN THE ARTICLES