Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Hard Disk serial number
Message
From
04/01/2006 02:23:34
 
 
To
04/01/2006 02:11:54
Somesh Sahu
Cybage Software Pvt Ltd,
Pune, India
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Environment versions
Visual FoxPro:
VFP 7
Miscellaneous
Thread ID:
01083011
Message ID:
01083013
Views:
32
>Hi
>I am developing a software in VFP for which i need the serial number of the hard disk. I don't want the Volume Number of the drive (ie c: , d: etc) as according to my information, this volume number changes whenever that volume is formatted. Can anybody help in getting the Hard Disk serial number which is manufacturer defined and which will not change.
> Can anyone please tell me the VFP or API function to obtain disk serial number.
>
> thanks in advance
LOCAL lpRootPathName, ;
        lpVolumeNameBuffer, ;
        nVolumeNameSize, ;
        lpVolumeSerialNumber, ;
        lpMaximumComponentLength, ;
        lpFileSystemFlags, ;
        lpFileSystemNameBuffer, ;
        nFileSystemNameSize
 
lpRootPathName           = [C:]
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
 
* RJV: Don't assign the return value to a variable unless you make it local or private!
=GetVolInfo(@lpRootPathName, @lpVolumeNameBuffer, ;
                  nVolumeNameSize, @lpVolumeSerialNumber, ;
                  @lpMaximumComponentLength, @lpFileSystemFlags, ;
                  @lpFileSystemNameBuffer, nFileSystemNameSize)
                  
this.VolumeName=LEFT(ALLTRIM(lpVolumeNameBuffer),LEN(ALLTRIM(lpVolumeNameBuffer))-1)
this.SerialNumber=lpVolumeSerialNumber
this.Maxfilenamesize=lpMaximumComponentLength
this.FSFlags=lpFileSystemFlags
this.FSType=LEFT(ALLTRIM(lpFileSystemNameBuffer),LEN(ALLTRIM(lpFileSystemNameBuffer))-1)


**---------------------------------------------------------------**
** Return code values for file system flags. Return codes are    **
** shown in parentheses.                                         **
**---------------------------------------------------------------**
** FS_CASE_SENSITIVE     If this flag is set, the file system    **
**                       supports case-sensitive file names      **
**                       (0001h).                                **
**                                                               **
** FS_CASE_IS_PRESERVED  If this flag is set, the file system    **
**                       preserves the case of file names when   **
**                       it places a name on disk (0002h).       **
**                                                               **
** FS_UNICODE_ON_DISK    If this flag is set, the file system    **
**                       supports Unicode in file names as they  **
**                       appear on disk (0004h).                 **
**                                                               **
** FS_PERSISTENT_ACLS    If this flag is set, the file system    **
**                       preserves and enforces ACLs. For        **
**                       example, NTFS preserves and enforces    **
**                       ACLs, but HPFS and FAT do not (0008h)   **
**                                                               **
** FS_FILE_COMPRESSION   The file system supports file-based     **
**                       compression (0010h)                     **
**                                                               **
** FS_VOL_IS_COMPRESSED  The specified volume is a compressed    **
**                       volume; for example, a DoubleSpace      **
**                       volume (8000h)                          **
**---------------------------------------------------------------**
** The following information is pertinent to several of the      **
** listed flags:                                                 **
**---------------------------------------------------------------**
** The FS_VOL_IS_COMPRESSED flag is the only indicator of volume-**
** based compression. The file system name is not altered to     **
** indicate compression. This flag comes back set on a Double-   **
** Space volume, for example. With volume-based compression, an  **
** entire volume is either compressed or not compressed.         **
**                                                               **
** The FS_FILE_COMPRESSION flag indicates whether a file system  **
** supports file-based compression. With file-based compression, **
** individual files can be compressed or not compressed.         **
**                                                               **
** The FS_FILE_COMPRESSION and FS_VOL_IS_COMPRESSED flags are    **
** mutually exclusive; both bits cannot come back set.           **
**---------------------------------------------------------------**
** Note that the return value can be a combination of the        **
** individual return values. For example, a return value of 6    **
** indicates that case is preserved (FS_CASE_IS_PRESERVED) and   **
** the file system supports UNICODE in file names                **
** (FS_UNICODE_ON_DISK).                                         **
**---------------------------------------------------------------**
*!*    The File System Flags value of 31 is a combination of the following file
*!*    system attributes:
*!*     
*!*    Flag                      Hex Value   Decimal Value
*!*    ---------------------------------------------------
*!*    FS_CASE_SENSITIVE             1             1
*!*    FS_CASE_IS_PRESERVED          2             2
*!*    FS_UNICODE_ON_DISK            4             4
*!*    FS_PERSISTENT_ACLS            8             8
*!*    FS_FILE_COMPRESSION          10            16

*!*    ---------------------------------------------------
*!*    Total return value:                        31
* Human is a question asked by birth and answered by death. Machine is another kind of question with another kind of answer
Previous
Reply
Map
View

Click here to load this message in the networking platform