热情软件屋

 

如何在VFP中调用GetVolumeInformation获得磁盘序列号


编号:QA002730
建立日期: 2000年3月17日 最后修改日期:2000年3月17日
所属类别:

lcz:
    我看了QA000894 "如何调用GetVolumeInformation获得磁盘序列号",在vfp5中如何实现,能在百忙之中举例说明吗?

回答:

    下面是一个例子:
     **---------------------------------------------------------------**
     ** Program: Getvol.prg **
     ** Purpose: Demonstrates how to declare and use the Win32 **
     ** GetVolumeInformation API. **
     **---------------------------------------------------------------**
     PUBLIC lpRootPathName, ;
     lpVolumeNameBuffer, ;
     nVolumeNameSize, ;
     lpVolumeSerialNumber, ;
     lpMaximumComponentLength, ;
     lpFileSystemFlags, ;
     lpFileSystemNameBuffer, ;
     nFileSystemNameSize
    
     lpRootPathName = "E:\" && 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)
    
     **---------------------------------------------------------------**
     ** 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). **
     **---------------------------------------------------------------**
    
     DEFINE WINDOW ShowInfo FROM 0,0 TO 10,70 ;
     FLOAT CLOSE ;
     TITLE "Drive Information for " + ;
     ALLTRIM(lpRootPathName) ;
     FONT "Courier",10
    
     ACTIVATE WINDOW ShowInfo
     MOVE WINDOW ShowInfo CENTER
    
     **--------------------------------------------------------------**
     ** Because several of the return values are padded with a null **
     ** terminator, you will need to strip off the null terminator **
     ** in order to get the correct value, which is what is done **
     ** using the LEFT, ALLTRIM, and LEN functions. **
     **--------------------------------------------------------------**
     @ 0,1 SAY "Drive & path name : " + ;
     ALLTRIM(lpRootPathName)
    
     @ 1,1 SAY "Volume name : " + ;
     LEFT(ALLTRIM(lpVolumeNameBuffer),LEN(ALLTRIM(lpVolumeNameBuffer))-1)
    
     @ 2,1 SAY "Max #/chars in vol name : " + ;
     ALLTRIM(STR(nVolumeNameSize))
    
     @ 3,1 SAY "Volume Serial # : " + ;
     ALLTRIM(STR(lpVolumeSerialNumber))
    
     @ 4,1 SAY "Max #/chars in dir/file names: " + ;
     ALLTRIM(STR(lpMaximumComponentLength))
    
     @ 5,1 SAY "File System Flags : " + ;
     ALLTRIM(STR(lpFileSystemFlags))
    
     @ 6,1 SAY "File System type : " + ;
     LEFT(ALLTRIM(lpFileSystemNameBuffer), ;
     LEN(ALLTRIM(lpFileSystemNameBuffer))-1)
    
     @ 7,1 SAY "File Sys Name Size : " + ;
     ALLTRIM(STR(nFileSystemNameSize))

此问题由李海回答。

 
把这个问题推荐给朋友
   
   
您的意见类别
您的名字
您的电子邮件
您的建议(请尽可能详细)
 
 

版权所有 1997-2008 热情软件屋
如果您有任何建议和意见, 请给我发个电子邮件 askpro@china-askpro.com
Web Designed by ZebraStudio