IsFileExist [Windows]
Posted: Mon Mar 10, 2014 1:22 pm
Find if file exist for windows x86 - x64
Code: Select all
;=======================================
; Snippet: IsFileExist;
; Author: RASHAD
; Date: Mar 10, 2014
; Target OS: Windows
;=======================================
Procedure IsFileExist(File$)
OpenLibrary(0, "Kernel32.dll")
GetFunction(0, "IsWow64Process")
CallFunction(0,"IsWow64Process",GetCurrentProcess_(), @IsWow64ProcessFlag)
If IsWow64ProcessFlag <> 0
CompilerIf #PB_Compiler_Processor = #PB_Processor_x86
wfd.WIN32_FIND_DATA
GetFunction(0, "Wow64DisableWow64FsRedirection")
CallFunction(0,"Wow64DisableWow64FsRedirection",Flag)
hFile = FindFirstFile_(@File$,wfd)
FindClose_(hFile)
GetFunction(0, "Wow64RevertWow64FsRedirection")
CallFunction(0,"Wow64RevertWow64FsRedirection",Flag)
CloseLibrary(0)
CompilerEndIf
Else
hFile = FileSize(File$)
EndIf
If hFile > 0
Debug "File exist"
Else
Debug "No"
EndIf
EndProcedure
IsFileExist("C:\Windows\System32\mblctr.exe")