Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
GetDiskFreeSpaceEx() in WIN32API
Message
De
11/01/2000 00:38:22
 
 
À
10/01/2000 21:53:10
Information générale
Forum:
Visual FoxPro
Catégorie:
Fonctions Windows API
Divers
Thread ID:
00315812
Message ID:
00315991
Vues:
32
You can use 3 VFP strings initialized with repl(chr(0), 8) for the 3 ULARGE_INTEGER parameters. Be aware that
GetDiskFreeSpaceEx() does not return an error (everything works just like there's nothing wrong if called on
Win95 previous OSR2).

I don't understand where is VFP using floating point numbers for this function call.

Vlad

>
SET PROCEDURE TO MEMMGR ADDITIVE
>oHeap = CREATEOBJ('Heap')
>LOCAL n3PU_LARGE_Values, cBuffer
>n3PULARGE_Values = oHeap.AllocInitAs(24,CHR(0))
>DECLARE INTEGER GetDiskFreeSpaceEx IN Win32API ;
>  STRING @ lpDirectoryName, ;
>  INTEGER lpFreeBytesAvailable, ;
>  INTEGER lpTotalNumberOfBytes, ;
>  INTEGER lpTotalNumberOfFreeBytes
>IF GetDiskFreeSpaceEx('C:\', ;
>                      n3PULARGE_Values,;
>                      n3PULARGE_Values+8, ;
>                      n3PULARGE_Values+16) # 0
>   cBuffer = oHeap.CopyFrom(n3PULARGE_Values)
>   ? 'Free bytes', ConvertULARGE(SUBST(cBuffer,1,8))
>   ? 'Tot. bytes', ConvertULARGE(SUBST(cBuffer,9,8))
>   ? 'Free bytes', ConvertULARGE(SUBST(cBuffer,17,8))
>ENDIF
>oHeap.DeAlloc(n3PULARGE_Values)
>oHeap = ''
>
>FUNCTION ConvertULARGE
>LPARAMETER tcULARGE
>LOCAL nCtr, nValue
>nValue = 0
>FOR nCtr = 8 TO 1 STEP -1
>   nValue = (nValue * 256) + ASC(SUBST(tcULARGE,nCtr,1))
>ENDFOR
>RETURN nValue
>
>Note - I allocate a block of memory large enough to hold the 3 values, and pass pointers to the sections of the memory block rather than passing strings. Each ULARGE is 8 bytes in length. The conversion is rather brute force, but it works; numbers are stored with the Least Significant Byte first. Be aware that rouding errors may occur, since VFP is forced to work with this as a floating point number.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform