Because it is looking for files in a different folder.
An x86 application uses the SysWOW64 folder when accessing the System32 folder because System32 contains x64 resources
Try this, it should be perfect
Code: Select all
EnableExplicit
; https://www.purebasic.fr/english/viewtopic.php?t=82308
; Debug FileDirListCmd(Files(), "C:\Windows\System32", "*", 0, 0, 0) ; CMD + Dir
; ; ForEach Files()
; ; Debug Files()
; ; Next
;
; ; 4853
; If ExamineDirectory(0, "C:\Windows\System32", "*")
; While NextDirectoryEntry(0)
; i + 1
; Wend
; EndIf
; Debug i
; 4855
; https://www.purebasic.fr/english/viewtopic.php?p=581152#p581152
CompilerIf #PB_Compiler_Processor = #PB_Processor_x86
Procedure.i Is64BitOS()
Protected HDLL, IsWow64Process_, Is64BitOS
If SizeOf(Integer) = 8
Is64BitOS = 1 ; this is a 64 bit exe
Else
HDll = OpenLibrary(#PB_Any, "kernel32.dll")
If HDll
IsWow64Process_ = GetFunction(HDll, "IsWow64Process")
If IsWow64Process_
CallFunctionFast(IsWow64Process_, GetCurrentProcess_(), @Is64BitOS)
EndIf
CloseLibrary(HDll)
EndIf
EndIf
ProcedureReturn Is64BitOS
EndProcedure
CompilerEndIf
Global x86_64, Wow64
CompilerIf #PB_Compiler_Processor = #PB_Processor_x86
Wow64 = 1
CompilerElse
Wow64 = 0
CompilerEndIf
CompilerIf #PB_Compiler_Processor = #PB_Processor_x86
If Is64BitOS()
x86_64 = 64
Else
x86_64 = 32
EndIf
CompilerElse
; since the x64 program will run only on OS_x64, we unambiguously set the variables
x86_64 = 64
CompilerEndIf
; Debug x86_64
; to disable redirection to the SysWOW64 folder when using an x86 program
Global IsWow64ProcessFlag, hKrnDLL, *Func
; Redirection conditions: file 32 bit, system 64 bit and higher than WinXP,
; otherwise we simply disable redirection with the Wow64=0 flag (forced)
CompilerIf #PB_Compiler_Processor = #PB_Processor_x86
If x86_64 = 64 And OSVersion() >= #PB_OS_Windows_Vista
hKrnDLL = OpenLibrary(#PB_Any, "Kernel32.dll")
If hKrnDLL
*Func = GetFunction(hKrnDLL, "IsWow64Process")
If *Func
CallFunctionFast(*Func, GetCurrentProcess_(), @IsWow64ProcessFlag)
*Func = 0
If IsWow64ProcessFlag And SizeOf(Integer) = 4
*Func = GetFunction(hKrnDLL, "Wow64DisableWow64FsRedirection")
EndIf
EndIf
EndIf
Else
; for x64 redirection is not needed, so disable it
Wow64 = 0
EndIf
CompilerEndIf
; WindowsXP
If OSVersion() < #PB_OS_Windows_Vista Or Not *Func
Wow64 = 0
EndIf
If Wow64
CallFunctionFast(*Func, 0)
EndIf
Define i
If ExamineDirectory(0, "C:\Windows\System32", "*")
While NextDirectoryEntry(0)
i + 1
Wend
EndIf
Debug i
; 4855
If Wow64
CallFunctionFast(*Func, 1)
EndIf
CompilerIf #PB_Compiler_Processor = #PB_Processor_x86
If IsLibrary(hKrnDLL)
CloseLibrary(hKrnDLL)
EndIf
CompilerEndIf