Page 1 of 1
Read size of file
Posted: Wed Aug 01, 2012 8:44 am
by jdeleon7010
Is there support to read the size of a file?
Re: Read size of file
Posted: Wed Aug 01, 2012 9:13 am
by jdeleon7010
I am actually trying to call GetFileSize from kernel32.dll. The return value is EXTERNELEXCEPTION, what is wrong with my parameters?
Code: Select all
~InstallAware Clipboard Data~
~MessageBox~
~{66E06A30-BF40-45A5-97A9-EBBD5C91110A}~
~TEST~
~$FILE_SIZE$~
~0~
~1~
~~
~Call DLL Function~
~{20E7AA1B-23BA-4372-AABA-429C2285A8B6}~
~kernel32.dll,GetFileSize,byte,FILE_SIZE,"pointer to string",$SD$\_TMP\test.bat,$~
~mIDEFunc.dll\mEXEFunc.dll~
~Set Variable~
~{115FF94E-88EC-49F3-B6F2-0B615D0CE92A}~
~FILE_SIZE$MYAH$MYAH$FALSE~
~~
Re: Read size of file
Posted: Wed Aug 01, 2012 9:14 am
by jdeleon7010
Disregard, I had to add dword false parameter.
Re: Read size of file
Posted: Thu Aug 02, 2012 3:32 am
by FrancescoT
Happy that you solved!

Re: Read size of file
Posted: Mon Aug 06, 2012 4:00 pm
by saleen98r
Hi, I'm actually trying to do this to confirm a size of corporate standard wallpaper in a IDE script to create, then set the wallpaper on all machines. We are then using GPO later to enforce it. The previous poster stated he added "double word" and false. I may be using the parameter incorrectly because the result is always "255". No matter what the BMP size is. Can you be more specific please?
~Call DLL Function~
~{637DE3A5-C922-445E-A928-4AA086F52B79}~
~kernel32.dll,GetFileSize,byte,FILESIZE,"pointer to string",$WIN$Wallpaper.bmp,"double word",FALSE,$~
~mIDEFunc.dll\mEXEFunc.dll~
Re: Read size of file
Posted: Tue Aug 07, 2012 8:05 am
by FrancescoT
Dear User,
the above code is not correct.
Please use the following code as example:
Code: Select all
~InstallAware Clipboard Data~
~End~
~{BD9DC602-43A6-49B9-8ED7-3C2BB6F2845E}~
~End~
~{F550168D-EB0B-4C74-B680-312B684D777C}~
~Call DLL Function~
~{D3C689B6-EA56-4243-B345-DDE8E25B1FDC}~
~Kernel32.dll,CloseHandle,bool,RESULT,"double word",$FILE_HANDLE$,$~
~~mIDEFunc.dll\mEXEFunc.dll~~
~Set Variable~
~{A6A2A769-8FBF-437B-8351-1E6ED556B129}~
~RESULT$MYAH$MYAH$FALSE~
~FALSE~
~Comment~
~{803610FC-F813-47EC-AA82-5C1AF4AC58BF}~
~~
~MessageBox~
~{DE1DCA8F-0DED-446A-8130-0B380680A414}~
~DEBUG~
~File size = $FILE_SIZE$~
~0~
~1~
~~
~Call DLL Function~
~{F1DD8BDF-F788-40B1-BFF1-319FBDC9EC6B}~
~Kernel32.dll,GetFileSize,"double word",FILE_SIZE,"double word",$FILE_HANDLE$,"double word",0,$~
~~mIDEFunc.dll\mEXEFunc.dll~~
~If~
~{BFDEFE3F-8E45-4A2A-A6D6-E8215079BE1E}~
~FILE_HANDLE~
~4~
~4294967295~
~TRUE~
~If~
~{8A8542B7-F393-456F-A5B6-C43E71707039}~
~FILE_HANDLE~
~2~
~0~
~FALSE~
~Call DLL Function~
~{F319E9BC-C572-4D74-A615-F8220D901E02}~
~Kernel32.dll,CreateFileA,"double word",FILE_HANDLE,"pointer to string",C:\myfile.pdf,"double word",2147483648,"double word",0,long,0,"double word",3,"double word",128,"double word",0,$~
~~mIDEFunc.dll\mEXEFunc.dll~~
~Comment~
~{9501523B-B740-427B-B34C-ADBC53E04771}~
~~
~Set Variable~
~{FBF5A181-86AF-4E88-BCD3-97D85FE7F7B1}~
~FILE_SIZE$MYAH$MYAH$FALSE~
~~
~Set Variable~
~{05684256-A473-45A6-98A2-0C56FE6B682C}~
~FILE_HANDLE$MYAH$MYAH$FALSE~
~~
Hope this helps you.
Regards
Re: Read size of file
Posted: Tue Aug 07, 2012 3:04 pm
by saleen98r
Hi. I've tried the new code. For some reason, the $FILE_HANDLE$ shows 0 even though it was declared. Once it ran, the $RESULT$ showed as FALSE. Is the code correct? I thought function is suppose to be GetFileSize to get the size of a file, not CloseHandle.
I've included screen capture of Call DLL function and all codes pertaining to this task. Thanks for helping in advance.
Here's my current code:
Set Variable FILE_HANDLE to $WINDIR$\System32\msiexec.exe
Call DLL Function Kernel32.dll->CloseHandle (get result into variable RESULT)
MessageBox: DEBUG, HANDLE = $FILE_HANDLE$$NEWLINE$RESULT = $RESULT$
Here's the contents of the CALL DLL FUNCTION:
~InstallAware Clipboard Data~
~Call DLL Function~
~{099FCEC6-3AF8-40DE-9526-64F4F9093FE1}~
~Kernel32.dll,CloseHandle,bool,RESULT,"double word",$FILE_HANDLE$,$~
~mIDEFunc.dll\mEXEFunc.dll~
Re: Read size of file
Posted: Tue Aug 07, 2012 3:07 pm
by saleen98r
BTW, i "SET variable FILE_HANDLE = $WINDIR$\System32\msiexec.exe" just as a test because I know the file exists for sure and the exe contains fields/data that a BMP file does not contain.
Re: Read size of file
Posted: Wed Aug 08, 2012 5:26 am
by FrancescoT
Dear User,
please review my code once again ... what you are doing is not correct at all.
FILE_HANDLE points to a file handle pointer (with WIN API is declared as HANDLE) not to the file name.
With my code the file name is passed as first parameter in CreateFileA WIN API function.
So just replace the file name I used with my sample and leave all the rest as it is.
The call to CloseHandle is required because it is necessary to FREE the pointer returned (FILE_HANDLE ) ... otherwise could cause problems.
To use my code just copy and then paste it in your script.
The sample will show a dialog that reports the size of the given file.
I have personally tested it!
Regards