Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

serial number from USB flash drive 2

Status
Not open for further replies.

med1112

Instructor
Jul 9, 2003
4
0
0
MA
hi,
Using either Delphi7, is there a way to obtain a serial number off a USB flash drive?
thanx
 
You could try using this function. I don't know if the value returned is correct but it is different to the serial numbers from the other drives on my computer.
Code:
function GetDiskVolSerialID( cDriveName : char ): cardinal;
var
  VolumeSerialNumber: DWORD;
  MaximumComponentLength: DWORD;
  FileSystemFlags: DWORD;
  diskdrive: string;
begin
  diskdrive := cDriveName + ':\';
  GetVolumeInformation(pchar(diskdrive),
                       nil,
                       0,
                       @VolumeSerialNumber,
                       MaximumComponentLength,
                       FileSystemFlags,
                       nil,
                       0);
  result := VolumeSerialNumber;
end;


Andrew
Hampshire, UK
 
One thing you find out about Delphi is that it is very niche, and consequently many things are not written for it in examples. You will also find that since Microsoft has the look-in on the OS interfaces, that most things can be plugged and played on their languages (C++ and Visual Basic).

Consequently, you will find examples mostly in those two things and will be lucky if you find many things in Delphi. Also consequently, you will find that most successful Delphi programmers require C++ or Visual Basic knowledge when dealing with the API beyond the elements already translated by Borland for the Delphi VCL (which begs the question why not program in one of those things, but that's beside the point here).

Short story of it: You'll basically have to take the example that was given in that link and port it to Delphi, unless you have found someone that has already done the task and posted it on another web page. The lucky thing is that it is in Visual Basic (generally easier to follow the logic for) and since the writer of the link described the API functions and where they are located, it shouldn't take too much research to be able to get the job done.

Sorry if that sounds harsh, but that's Delphi for you when it comes to an OS task...

----------
Those who work hard are rewarded with more work and remembered come time to downsize. Those who hardly work are given a paycheck and ignored completely.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top