Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


[Delphi] Help about GetVolumeInformation

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
h4c0r-BG
Master Cheater
Reputation: 0

Joined: 29 Nov 2006
Posts: 449
Location: The yogurt country

PostPosted: Mon Nov 05, 2007 10:37 am    Post subject: [Delphi] Help about GetVolumeInformation Reply with quote

procedure TForm1.Button1Click(Sender: TObject);

Quote:
var
SerialNum : pdword;
Buffer : array [0..255] of char;
MaxCompLength, FileSystemFlags : dword;
result: string;

begin
GetVolumeInformation('D:\', Buffer, SizeOf(Buffer),
SerialNum, MaxCompLength,
FileSystemFlags, nil, 0);
Label1.Caption:=inttostr(serialnum^);

end;


The problem is that i can't get the HD serial number.
I sent the program to my friends and all of us get:

label1.caption ----> 2346224467

How to fix this? It is not possible the serial to be the same on different computers. =/

_________________

Back to top
View user's profile Send private message
Renkokuken
GO Moderator
Reputation: 4

Joined: 22 Oct 2006
Posts: 3249

PostPosted: Mon Nov 05, 2007 11:08 am    Post subject: Reply with quote

Check this example usage, better of not declaring as a PDWORD.

Code:
var
fileSysFlags: DWORD;
maxCompLen  : DWORD;
serNum      : DWORD;
begin
GetVolumeInformation(PChar(<INSERTDISK>+':\'), nil, 0, @serNum,
maxCompLen, fileSysFlags, nil, 0)



Taken from : Here.
Back to top
View user's profile Send private message
appalsap
Moderator
Reputation: 0

Joined: 27 Apr 2006
Posts: 6753
Location: Pakistan

PostPosted: Mon Nov 05, 2007 11:22 am    Post subject: Reply with quote

Code:

program HSerial;

{$APPTYPE CONSOLE}

uses
  SysUtils, Windows;

var
  CurrentDrive: pchar;
  SerialNumber, Blah: Cardinal;
begin
  try
    CurrentDrive := PChar(ExtractFileDrive(GetCurrentDir)+'\');
    if GetVolumeInformation(CurrentDrive, nil, 0, @SerialNumber, Blah, Blah, nil, 0) then
      WriteLn('Serial Number: ' + IntToStr(SerialNumber))
    else
      WriteLn('Unable to retrieve serial number! This may help: ' + IntToStr(GetLastError));   
    ReadLn;
  except
    on E:Exception do
      Writeln(E.Classname, ': ', E.Message);
  end;
end.


Your problem was you declared a pointer to some memory that doesn't exist, so you will get whatever crap was on the stack at the time.

_________________
Back to top
View user's profile Send private message
h4c0r-BG
Master Cheater
Reputation: 0

Joined: 29 Nov 2006
Posts: 449
Location: The yogurt country

PostPosted: Mon Nov 05, 2007 12:06 pm    Post subject: Reply with quote

Thank you appalsap. It was a nice copy/pasteable code. ^^
_________________

Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites