Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Scripting.FileSystemObject
Message
De
20/08/2001 08:36:31
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Contrôles ActiveX en VFP
Divers
Thread ID:
00545135
Message ID:
00546134
Vues:
13
>Anyone using the Scripting.FileSystemObject in SCRRUN.DLL to get information on drives, folders, volume names etc?
>
>oFS = CREATEOBJECT("Scripting.FileSystemObject")
>cDrive = ..drive letter ...
>IF oFS.DriveExists(cDrive)
> oDrv = oFS.Drives.Item(cDrive)
> ? oDrv.SerialNumber
> ? oDrv.FreeSpace
> ? oDrv.TotalSpace
> ... etc ...
>ENDIF
>
>It works very well (as long as you have SCRRUN.DLL installed), but I cannot get volume serial numbers from some partitions. On a W2K machine, its FAT partition gives a good serial number, but its 2 NTFS partitions each return "0000-0000".
>
>The KnowledgeBase article Q139547 shows how to use the GetVolumeInformation API call with VFP - but this does no better.
>
>VOL at the command prompt returns a good serial for each partition.
>
>Any clues about how to get around this? Any past threads deal with it?
>John Burton

John,
As an addition to George, for local NTFS partitions actually it's not returning 0. It's returning a value > 0x7FFFFFFF and I think that's the problem. As a workaround I touch the value. Works with w98 and NTFS partitions (if you want is the one that you get with dir or vol at command prompt). ie:
Function GetVolInfo
Lparameters lcRoot, taInfo && Root of drive ie: "c:\", InfoArray passed by ref
    Declare SHORT GetVolumeInformation IN Win32API;
        STRING @lpRootPathName, STRING @lpVolumeNameBuffer,;
        INTEGER nVolumeNameSize, integer @lpVolumeSerialNumber,;
        INTEGER @lpMaximumComponentLength, INTEGER @lpFileSystemFlags,;
        STRING @lpFileSystemNameBuffer, INTEGER nFileSystemNameSize
    Store 0 TO lncomplen, lnsysflags, lnserialno
    Store SPACE(260) TO lcvolname, lcsysname
    Store LEN(lcvolname) TO lnvolsize, lnnamesize
    If (GetVolumeInformation(@lcRoot, @lcvolname,;
            lnvolsize, @lnserialno, @lncomplen, @lnsysflags,;
            @lcsysname, lnnamesize) # 0)
        Dimension taInfo[3]
        taInfo[1] = substr(lcvolname, 1, at(chr(0),lcvolname)-1) && Volume name
        taInfo[2] = substr(lcsysname, 1, at(chr(0),lcsysname)-1) && Par.type
  taInfo[3] = trans(right(trans(iif(lnSerialNo < 0, ;
         0x7FFFFFFF-abs(lnSerialNo)+0x7FFFFFFF, lnSerialNo),'@0'),8),;
         '@R XXXX-XXXX') && Serial in hex format
    Else
        taInfo = ""
    Endif
    Return
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform