d4rk Posted June 11, 2008 Share Posted June 11, 2008 hello every1, i have this simple code to check a file's size, but i can't make it works, can some1 tell me why ? thanks for reply MsgBox(64,"",DllCall("kernel32.dll","dword","GetFileSizeEx","str","D:\Music\Ranh Gioi Thien Ac - Lil Knight.mp3","int",0)) [quote]Don't expect for a perfect life ... Expect a least troubles ones[/quote]Contact me : ass@kiss.toWhat I Have Done :Favorites Manager Mangage your favorite's folder, that's coolPC Waker For those who want to save stickersWebScipts Supporter For those who've just started with Web and WebScriptsTemporary Looker Simple but powerful to manage your Temporary folder, you know what you downloaded[UDF] _NumberFormat() Better performance on number display[UDF] _DirGet() What a folder contain [how many (hidden,normal,...) files], with one line of code[UDF] _IsPressEs() Just like _IsPress() but for a group of keys Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted June 11, 2008 Moderators Share Posted June 11, 2008 hello every1, i have this simple code to check a file's size, but i can't make it works, can some1 tell me why ? thanks for reply MsgBox(64,"",DllCall("kernel32.dll","dword","GetFileSizeEx","str","D:\Music\Ranh Gioi Thien Ac - Lil Knight.mp3","int",0)) 2. Not only do you have to get the parameters right (which you don't have), you also need to create any types/unions/structs that are necessary. You can't just magically call something and hope it works. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
smashly Posted June 11, 2008 Share Posted June 11, 2008 Couple of reasons your call fails.1st the call requires the handle to a file, not a file path.2nd A pointer to a LARGE_INTEGER structure that receives the file size, in bytes is meant to be used for the last value ptr not an int. So I gather you would need to get the file size from the LARGE_INTEGER struct if the return of the dll call is anything different to 0Myself I don't understand the LARGE_INTEGER struct and how it's set up.I tried the dll call using the standard "GetFileSize" and it returns the size of the file, but the "GetFileSizeEx" I don't quite understand.To get a handle to the file I used _WinAPI_CreateFile() function which can open a file and return a handle.#Include <WinAPI.au3> Local $FilePath, $hFile, $aRet $FilePath = @HomeDrive & "\NTDETECT.COM" $hFile = _WinAPI_CreateFile($FilePath, 2, 2) If $hFile <> 0 Then $aRet = DllCall("kernel32.dll","int","GetFileSize","int",$hFile,"int",0) If IsArray($aRet) Then MsgBox(64, $FilePath, $aRet[0] & " bytes") EndIf Link to comment Share on other sites More sharing options...
d4rk Posted June 11, 2008 Author Share Posted June 11, 2008 Thanks for reply, i'm just starting with DLL and i'm just trying to show some efforts i'll read your posts carefully and will back with a specific question thanks [quote]Don't expect for a perfect life ... Expect a least troubles ones[/quote]Contact me : ass@kiss.toWhat I Have Done :Favorites Manager Mangage your favorite's folder, that's coolPC Waker For those who want to save stickersWebScipts Supporter For those who've just started with Web and WebScriptsTemporary Looker Simple but powerful to manage your Temporary folder, you know what you downloaded[UDF] _NumberFormat() Better performance on number display[UDF] _DirGet() What a folder contain [how many (hidden,normal,...) files], with one line of code[UDF] _IsPressEs() Just like _IsPress() but for a group of keys Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now