Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Finding a Volume Label
Message
De
01/03/2002 11:13:16
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00626993
Message ID:
00627003
Vues:
22
>I have a program that uses low-level file functions to catalog files found on a CD-ROM drive. I have two questions.
>
>#1 - how do I find the volume label of a drive? I found this on the KB but am not able to turn it around to tell me what the current volume is.
>
> DECLARE INTEGER SetVolumeLabel IN Win32API STRING lcRootPath,;
> STRING lcVolumeLabel
>
> liRetVal = 0
> * Message box with OK/Cancel buttons
> liRetVal = MESSAGEBOX("Insert scratch floppy disk in drive A:",;
> 1)
>
> * Handle non-OK selection from message box
> IF liRetVal # 1
> RETURN
> ENDIF
>
> lcVolumeLabel = "Test"
> = SetVolumeLabel ("A:\", lcVolumeLabel)
>
>#2 - How can I FOPEN(cfilename,10) &Read_Only Un_buffered a file on a CD-ROM to read the files. I had to work around this problem by copying the file to the HD before fopen()'ing it.
>
>TIA

1)
Declare SHORT GetVolumeInformation IN Win32API;
  STRING @lpRootPathName, STRING @lpVolumeNameBuffer,;
  INTEGER nVolumeNameSize, integer @lpVolumeSerialNumber,;
  INTEGER @lpMaximumComponentLength, INTEGER @lpFileSystemFlags,;
  STRING @lpFileSystemNameBuffer, INTEGER nFileSystemNameSize

lcRoot="c:\"

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)
  ? substr(lcvolname, 1, at(chr(0),lcvolname)-1)
Endif
2) fopen() without 2nd parameter. ie: fopen('c:\myfile.txt')
Instead of fopen() you could use FileToStr() with VFP6 and later.
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
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform