Recent

Author Topic: HWID in Lazarus  (Read 5205 times)

shonay

  • Full Member
  • ***
  • Posts: 169
HWID in Lazarus
« on: January 30, 2015, 01:43:35 pm »
Sorry to bother you fellows again,
many thanks on the first help i got on here, now i am onto a more difficult topic.
I been trying to get the GUID / HWID of a computer too. very difficult.

(just trying my hands out on some win32 here ), Please Do help..

Did this already, doesnt seem to print out the HWID as i want it to, the cmd just vanishes

Code: [Select]
program hwid;

{$mode delphi}{$H+}

uses
  {$IFDEF UNIX}{$IFDEF UseCThreads}
  cthreads,
  {$ENDIF}{$ENDIF}
  Classes ,SysUtils, Windows
  { you can add units after this };
var
  SerialNum,A,B: DWord;
  C: array [0..255] of Char;
  Buffer: array [0..255] of Char;
  Result : string;
  HWID : string;
begin
  GetVolumeInformation(pChar('C:\'), Buffer, 256, @SerialNum, A, B, C, 256);
  Result := inttostr(SerialNum * Cardinal(-1));
end.

« Last Edit: January 30, 2015, 02:12:13 pm by shonay »
When the power of love overcomes the love of power, the world would know Peace

- Jimi Hendrix.

ChrisF

  • Hero Member
  • *****
  • Posts: 542
Re: HWID in Lazarus
« Reply #1 on: January 30, 2015, 02:36:45 pm »
WriteLn ?

balazsszekely

  • Guest
Re: HWID in Lazarus
« Reply #2 on: January 30, 2015, 02:38:50 pm »
Code: [Select]

writeln(inttostr(SerialNum * Cardinal(-1)));
readln();

howardpc

  • Hero Member
  • *****
  • Posts: 4144
Re: HWID in Lazarus
« Reply #3 on: January 30, 2015, 02:41:16 pm »
What is the purpose (and need for)
Code: [Select]
* Cardinal(-1)Won't that just lead to an overflow?

balazsszekely

  • Guest
Re: HWID in Lazarus
« Reply #4 on: January 30, 2015, 03:24:22 pm »
Yes, it's kinda pointless!

shonay

  • Full Member
  • ***
  • Posts: 169
Re: HWID in Lazarus
« Reply #5 on: January 30, 2015, 04:39:04 pm »
Ok i even tried that, it returned something i  did not expect,just numbers
here is what i tried again after looking up some code on C/C++ seems this is what i wanted

Code: [Select]
program hwid2;

{$mode delphi}{$H+}

uses
  {$IFDEF UNIX}{$IFDEF UseCThreads}
  cthreads,
  {$ENDIF}{$ENDIF}
  Classes , Windows , SysUtils
  { you can add units after this };

var
  hwProfileInfo : string;
  hwid : string;

begin
  hwid := GetCurrentHwProfile(hwProfileInfo.szHwProfileGuid);
  Writeln('HWID :',hwid);
end.

When the power of love overcomes the love of power, the world would know Peace

- Jimi Hendrix.

howardpc

  • Hero Member
  • *****
  • Posts: 4144
Re: HWID in Lazarus
« Reply #6 on: January 30, 2015, 05:07:59 pm »
On Windows you would need
Code: [Select]
program hwProfile;

{$mode objfpc}{$H+}

uses
  JwaWinBase;

var
  hwProfileInfo: HW_PROFILE_INFO;

begin
  if GetCurrentHwProfile(hwProfileInfo) then
    begin
      Writeln('hwProfileName is ',hwProfileInfo.szHwProfileName);
      writeln('hwprofileGUID is ',hwProfileInfo.szHwProfileGuid);
    end
  else WriteLn('Windows API call failed');
  ReadLn;
end.

shonay

  • Full Member
  • ***
  • Posts: 169
Re: HWID in Lazarus
« Reply #7 on: January 30, 2015, 05:15:29 pm »
@HowardPc, You the best. Thanks a whole lot, May God bless you.
When the power of love overcomes the love of power, the world would know Peace

- Jimi Hendrix.

 

TinyPortal © 2005-2018