Guest hasnain_razwi Posted April 22, 2004 Posted April 22, 2004 hi. im using an API to calculate the free space on my hard disk. this is the line that i use to call the API: - lngReturn = GetDiskFreeSpace(strDrive, lngSectorPerCluster, lngBytesPerSector, lngFreeClusters, lngTotalClusters) where the value of strDrive is "C:/ ". the trouble is no matter what value i put in strDrive, i keep getting the same result for the rest of the parameters i.e 0,0,0,0. (ofcourse thats not right :mad: ) and since there isnt any error, i cant tell where the mistake is. one more thing, is there an API viewer like application like the one available in VB 6 where we could copy the declaration code from the viewer window and paste it into the code? Quote
Administrators PlausiblyDamp Posted April 22, 2004 Administrators Posted April 22, 2004 How have you declared the API? does it work with "C:\"? Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Guest hasnain_razwi Posted April 22, 2004 Posted April 22, 2004 How have you declared the API? does it work with "C:\"? nope stil doesnt it doesnt even give me an error when i put in an empty string. just doesnt work. the declaration is as follows :- Public Declare Function GetDiskFreeSpace Lib "kernel32" Alias "GetDiskFreeSpaceA" (ByVal lpRootPathName As String, ByVal lpSectorsPerCluster As Long, ByVal lpBytesPerSector As Long, ByVal lpNumberOfFreeClusters As Long, ByVal lpTotalNumberOfClusters As Long) As Long Quote
Arch4ngel Posted April 22, 2004 Posted April 22, 2004 Have you tryied DllImport ? Quote "If someone say : "Die mortal !"... don't stay to see if he isn't." - Unknown "Learning to program is like going out with a new girl friend. There's always something that wasn't mentioned in the documentation..." - Me "A drunk girl is like an animal... it scream at everything like a cat and roll in the grass like a dog." - Me after seeing my girlfriend drunk and some of her drunk friend. C# TO VB TRANSLATOR
*Experts* mutant Posted April 22, 2004 *Experts* Posted April 22, 2004 Try chnaging the As Long to As Integer. VB6's Longs are now the same size as .NET's Integers. Quote
Guest hasnain_razwi Posted April 23, 2004 Posted April 23, 2004 thanks..it did work that way :D Quote
Recommended Posts