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 Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Volume Serial number

Status
Not open for further replies.

JPG77

Programmer
Mar 22, 2002
27
FR
Hi,
I need to get the volume serial number.
I found sometime good with the "GetVolumeInformation" in WIN32API (for VisualFox). But I had to get this information in 3 application written in FoxPro 2.6a.
I try with RegFn() - Foxtools with always error message.

The syntax for VFP is :

Declare Integer GetVolumeInformation in WIN32API ;
String @lpRootPathName, ;
String @lpVolumeNameBuffer, ;
Integer nVolumeNameSize, ;
Integer @lpVolumeSerialNumber, ;
Integer @lpMaximumComponentLength, ;
Integer @lpFileSystemFlags, ;
String @lpFileSystemNameBuffer, ;
Integer nFileSystemNameSize

*** Variable declaration
cString = ""
cRoot = "C:\"
cVolumeName = Space(256)
nVolumeNameSize = 256
nVolumeSerial = 0
nMaxCompLength = 256
nFileSysFlag = 0
cFileSysNameBuf = Space(256)
nFileSysNameSize= 256
*** And Call <GetVolumeInformation>

nReturn = GetVolumeInformation(@cRoot, @cVolumeName,nVolumeNameSize, @nVolumeSerial,@nMaxCompLength,@nFileSysFlag,@cFileSysNameBuf,nFileSysNameSize)

Can somebody help me ???
I really appreciate and sorry for my bad english.
 
Because this is explicitly a 32-bit API call, you can't use RegFn() in FPW directly (just 16-bit &quot;compatible&quot; API calls). Go to and download Rick's &quot;Call32 - Call Win32 functions from FoxPro 2.x&quot;. I believe one of the samples is this specific API call.

Rick
 
Use this answer from vinukonat (Programmer) Jun 28, 2001
Hello,

You can use the following code for finding the volume serial number of floppy disk and hard disk

hd=allt(sys(5))
fpno = '!vol '+hd + ' > '+hd+'\'+'fp.txt'
&fpno
mfile1 = hd + '\fp.txt'
mfile2 = hd + '\temp.dbf'
sele 1
create table &mfile2 (desc c(80))
appe from &mfile1 sdf
dele all for recno() # 3
pack
volserialno = allt(substR(desc,25,65))
use
dele file &mfile2
dele file &mfile1

:)
 
Rick,
Thanks for your answer.
I try call32.dll but still have problems.

I thank you too <cdimas> for his answer but I'had tried before and had problems cause my application is on a server and the letter drive change. So I had to create one .bat and one .pif and overwrite the instructions in the .bat.
Then, the DOS windows is allways visible and cant'be hidden.
So I decided to write a small programm in VFP6, and just call <GetVolumeInformation> and put the SerialNumber somewhere - In Fox 2.6, I run this small programm, with hidden windows and then return under 2.6 and get the serialnumber.
Not really the best solution, but as I can see, It's works without problem.

Thanks all.
JpG
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top