Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
GetDiskFreeSpaceEx() in WIN32API
Message
De
11/01/2000 00:52:08
 
 
À
11/01/2000 00:38:22
Information générale
Forum:
Visual FoxPro
Catégorie:
Fonctions Windows API
Divers
Thread ID:
00315812
Message ID:
00315992
Vues:
43
>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.
>

I believe that integers at ~2^32 stop being returned as integers and start being doubles. I haven't checked he crossover point in detail

>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.
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform