How to know Hard drive Serial Number?

M

Mota

Hi;
To make a security system to prevent copying,i want to use some information
from the current
system (that my program will be installed on) hardwares.
Can anyone please help me to get for example Serial Number of the hard drive
or the BIOS serial no?
Any help is appreciated.Thank you.
 
D

david epsom dot com dot au

Private Declare Function GetVolumeInformation _
Lib "kernel32.dll" Alias "GetVolumeInformationA" _
(ByVal lpRootPathName As String, _
ByVal lpVolumeNameBuffer As String, _
ByVal nVolumeNameSize As Integer, _
lpVolumeSerialNumber As Long, _
lpMaximumComponentLength As Long, _
lpFileSystemFlags As Long, _
ByVal lpFileSystemNameBuffer As String, _
ByVal nFileSystemNameSize As Long) _
As Long

Dim SerialNum As Long

Res = GetVolumeInformation("c:\", Temp1, Len(Temp1), SerialNum, 0, 0, Temp2,
Len(Temp2))


(david)
 
M

Mota

Thnak you for your attention
Have you tested this API?
I put API in a Standard Module and replaced the word "Private" with
"Public",and put the following code in a Click Event of a command button of
a form:
Dim SerialNum as long
Res = GetVolumeInformation("c:\", Temp1, Len(Temp1), SerialNum, 0, 0, Temp2,
Len(Temp2))
MsgBox SerialNum
but i got zero in MsgBox.What is wrong here?Can you help me please?
In addition,I need a constant serial Number,e.g. a hard drive.Is the Volume
Serial No countable enough to be used in a Locking system of a program?Does
not it change after formating or partitioning a Hard Drive?
Thank you again for this useful API.
Waiting for its correction.
 
M

Mota

Waiting for your reply.

david epsom dot com dot au said:
Private Declare Function GetVolumeInformation _
Lib "kernel32.dll" Alias "GetVolumeInformationA" _
(ByVal lpRootPathName As String, _
ByVal lpVolumeNameBuffer As String, _
ByVal nVolumeNameSize As Integer, _
lpVolumeSerialNumber As Long, _
lpMaximumComponentLength As Long, _
lpFileSystemFlags As Long, _
ByVal lpFileSystemNameBuffer As String, _
ByVal nFileSystemNameSize As Long) _
As Long

Dim SerialNum As Long

Res = GetVolumeInformation("c:\", Temp1, Len(Temp1), SerialNum, 0, 0,
Temp2, Len(Temp2))


(david)
 
M

Mota

Dear David;
Im still waiting.This API wont work and returns zero for the SerialNum.Help
me please.
 
D

david epsom dot com dot au

Mota said:
Thnak you for your attention
Have you tested this API?
Yes.

I put API in a Standard Module and replaced the word "Private" with
"Public",and put the following code in a Click Event of a command button
of a form:
Dim SerialNum as long

dim Temp1 as string
dim Temp2 as string

Temp1 = space(250)
Temp2 = space(250)
Res = GetVolumeInformation("c:\", Temp1, Len(Temp1), SerialNum, 0, 0,
Temp2, Len(Temp2))

if res = 0 then
MsgBox SerialNum
else
msgbox "Response:" & vbtab & res
endif
but i got zero in MsgBox.What is wrong here?Can you help me please?
In addition,I need a constant serial Number,e.g. a hard drive.Is the
Volume Serial No countable enough to be used in a Locking system of a
program?Does not it change after formating or partitioning a Hard Drive?

Yes, but all copy protection systems are faulty in one way or another.

Microsoft.public.access.formscoding is a good place to ask about
coding Access forms. I used this API as part of an Audit Record,
and, 7 years ago, as part of a home-grown text based replication
system, and I've passed it on to you for your consideration, but
I leave the question "how to write a good copy protection system"

(david)
 
M

Mota

Its not a good or global copy protection system.I want it just for a few
untrained users that i know tham all.But in some reasons need a small
protecting system.
By the way,it doesnt work again.Just says "Response=1"
in fact,i have doubt this API work in Win XP platforms.I think need WMI to
get a full hardware infoes from win xp thru its query method,that im not so
familiar with it.
Anyway,thank you for your help.
 
D

david epsom dot com dot au

It works on my copy of Windows XP.

If all the requested information is retrieved, the return value is nonzero.

If not all the requested information is retrieved, the return value is 0
(zero). To get extended error information, call GetLastError.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fileio/fs/getvolumeinformation.asp



I see that WMI returns the manufacturers serial number: that wasn't so
easily available when I was using the volume serical number. You can get
WMI information from a WMI object or probably from an OLEDB provider through
ADO



(david)
 
M

Mota

This is a Drive serial no,that changes when formatting.I need HDD
manufacurer serial no,that is accessible thru WMI.
any way,Thank you for ur attention.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top