Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8789517
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T22:25:44+00:00 2026-06-13T22:25:44+00:00

I am trying to make delphi program Server And Client so To Secure my

  • 0

I am trying to make delphi program Server And Client so To Secure my App and To Make Sure all user are under control i should give them a unique Key that can’t be change to not lose them Handle, So i think it should be HDD Serial Number + Bios SN , but i remember that Bios Can Be Change When remove motherboard Battery so it will not be work .
so my choose now is HDD Real serial number i am try this code below to get it but it didn’r work

    unit Unit2;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls,WbemScripting_TLB,ActiveX;

type
  TForm4 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form4: TForm4;

implementation

{$R *.dfm}

function GetWMIstring (wmiHost, wmiClass, wmiProperty : string):string;
var  // These are all needed for the WMI querying process
  Locator:  ISWbemLocator;
  Services: ISWbemServices;
  SObject:  ISWbemObject;
  ObjSet:   ISWbemObjectSet;
  SProp:    ISWbemProperty;
  Enum:     IEnumVariant;
  Value:    Cardinal;
  TempObj:  OleVariant;
  SN: string;
begin
  try
  Locator := CoSWbemLocator.Create;  // Create the Location object
  // Connect to the WMI service, with the root\cimv2 namespace
   Services :=  Locator.ConnectServer(wmiHost, 'root\cimv2', '', '', '','', 0, nil);
  ObjSet := Services.ExecQuery('SELECT * FROM '+wmiClass, 'WQL',
    wbemFlagReturnImmediately and wbemFlagForwardOnly , nil);
  Enum :=  (ObjSet._NewEnum) as IEnumVariant;
  while (Enum.Next(1, TempObj, Value) = S_OK) do
  begin
    SObject := IUnknown(tempObj) as ISWBemObject;
    SProp := SObject.Properties_.Item(wmiProperty, 0);
    if VarIsNull(SProp.Get_Value) then
      result := ''
    else
    begin
      SN := SProp.Get_Value;
      result :=  SN;
    end;
  end;
  except // Trap any exceptions (Not having WMI installed will cause one!)
   on exception do
    result := '';
   end;
end;

procedure TForm4.Button1Click(Sender: TObject);
var
x:string;
Y:string;

begin


    X:=GetWMIstring('','Win32_BIOS','SerialNumber');
    Y:=GetWMIstring('','Win32_DiskDrive"','SerialNumber')     ;

    ShowMessage(x+';'+y);
end;

end.

*so please can any one correct my Code or Give me another idea
Best regard’s
*

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T22:25:46+00:00Added an answer on June 13, 2026 at 10:25 pm

    Your code is not working because you are passing a double-quote in the WMI class name.

    change this code

    GetWMIstring('','Win32_DiskDrive"','SerialNumber');
    

    To this

    GetWMIstring('','Win32_DiskDrive','SerialNumber');
    

    Btw, you can improve a lot your WMI function (GetWMIstring) if you follow the recommendations of the answer to this question How can I improve the WMI performance using delphi?.

    Try this sample (this code use late binding and don’t need the WbemScripting_TLB unit)

      uses
          ActiveX,
          ComObj;
    
        var
          FSWbemLocator : OLEVariant;
          FWMIService   : OLEVariant;
    
        function  GetWMIstring(const WMIClass, WMIProperty:string): string;
        const
          wbemFlagForwardOnly = $00000020;
        var
          FWbemObjectSet: OLEVariant;
          FWbemObject   : OLEVariant;
          oEnum         : IEnumvariant;
          iValue        : LongWord;
        begin;
          Result:='';
          FWbemObjectSet:= FWMIService.ExecQuery(Format('Select %s from %s',[WMIProperty, WMIClass]),'WQL',wbemFlagForwardOnly);
          oEnum         := IUnknown(FWbemObjectSet._NewEnum) as IEnumVariant;
          if oEnum.Next(1, FWbemObject, iValue) = 0 then
    
      if not VarIsNull(FWbemObject.Properties_.Item(WMIProperty).Value) then
    
         Result:=FWbemObject.Properties_.Item(WMIProperty).Value;
    
        FWbemObject:=Unassigned;
        end;
    
        procedure TForm4.Button1Click(Sender: TObject);
        var
          x:string;
          Y:string;
        begin
          FSWbemLocator := CreateOleObject('WbemScripting.SWbemLocator');
          FWMIService   := FSWbemLocator.ConnectServer('localhost', 'root\CIMV2', '', '');
    
          X:=GetWMIstring('Win32_BIOS','SerialNumber');
          Y:=GetWMIstring('Win32_PhysicalMedia','SerialNumber');
    
          ShowMessage(x+';'+y);
        end;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to make a Delphi client (Delphi 2006) to communicate with a
Hoi! I trying to make a webservice in Windows. The client is Delphi 6,
Delphi 2010, dbExpress, and SQL Server 2005 DB I am trying to make a
i m trying to make rename program with delphi and need to know if
I'm a hobby programmer trying to build a client/server application suite, using Delphi XE.
I am using Delphi 2007 and I am trying to make record type file.
I'm trying make a login window where a user is prompted to enter their
I am fairly new to iOS development and trying make a simple app which
i was created a nonvisual vcl component in delphi and I'm trying to make
I am trying to make HTTP Requests from Delphi using the WinInet functions. So

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.