Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Volume serial number
Message
De
04/05/2000 04:41:09
Liam O'Hagan
O'Hagan Programming Ltd
Irlande
 
 
À
03/05/2000 12:33:21
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00365631
Message ID:
00365984
Vues:
19
>How can I get the volume serial number for my hard drive through VFP like I do when I type 'LABEL' in DOS? Thanks for any help

Hi Michael,

I got most of this source from somewhere - can't remember from where - probably UT.

The following source is the GetVolInfo method in my class VolInfo
There are 4 properties cDrive, cVolName, cVolSerNo & lResult.
load cDrive with the drive letter you want to query and call the GetVolInfo method. cVolName and cVolSerNo will return the Volume Name and Serial Number. As I recall, I had a problem getting volume details from a network drive but it worked fine for local drives. lResult (default value .F.) will result the succes or otherwise of the API call.

Hope this helps.

Liam





Local lpRootPathName, ;
lpVolumeNameBuffer, ;
nVolumeNameSize, ;
lpVolumeSerialNumber, ;
lpMaximumComponentLength, ;
lpFileSystemFlags, ;
lpFileSystemNameBuffer, ;
nFileSystemNameSize

If Empty(This.cDrive) Then
This.cDrive = "C:\"
Else
This.cDrive = Upper(This.cDrive)
If !Between(Substr(This.cDrive,1,1), "A", "Z") Then
This.cDrive = "C:\"
Endif

If Substr(This.cDrive, 2) != ":\" Then
This.cDrive = Substr(This.cDrive, 1, 1) + ":\"
Endif
Endif


lpRootPathName = This.cDrive && Drive and directory path
lpVolumeNameBuffer = SPACE(256) && lpVolumeName return buffer
nVolumeNameSize = 256 && Size of/lpVolumeNameBuffer
lpVolumeSerialNumber = 0 && lpVolumeSerialNumber buffer

lpMaximumComponentLength = 256
lpFileSystemFlags = 0
lpFileSystemNameBuffer = SPACE(256)
nFileSystemNameSize = 256


DECLARE INTEGER GetVolumeInformation IN Win32API AS GetVolInfo ;
STRING @lpRootPathName, ;
STRING @lpVolumeNameBuffer, ;
INTEGER nVolumeNameSize, ;
INTEGER @lpVolumeSerialNumber, ;
INTEGER @lpMaximumComponentLength, ;
INTEGER @lpFileSystemFlags, ;
STRING @lpFileSystemNameBuffer, ;
INTEGER nFileSystemNameSize


RetVal=GetVolInfo(@lpRootPathName, @lpVolumeNameBuffer, ;
nVolumeNameSize, @lpVolumeSerialNumber, ;
@lpMaximumComponentLength, @lpFileSystemFlags, ;
@lpFileSystemNameBuffer, nFileSystemNameSize)


If RetVal !=1 Then
Return
Endif

This.cVolName = LEFT(ALLTRIM(lpVolumeNameBuffer),LEN(ALLTRIM(lpVolumeNameBuffer))-1)
This.cVolSerNo = ALLTRIM(STR(lpVolumeSerialNumber))
This.lResult = .T.
Liam O'Hagan
MCP VFP Desktop Apps
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform