Page 1 of 1

FileExist fail in System32 folder (ahk_32 on x64 OS)

Posted: 29 Jun 2018, 11:07
by stealzy
On windows 7x64 autohotkey32 can not see this file:

Code: Select all

f := FileOpen("C:\Windows\System32\dwm.exe","r","CP0")
	if !IsObject(f)
		MsgBox 0
MsgBox % FileExist("C:\Windows\System32\dwm.exe")
autohotkey64 works fine.
Are there any reasons for this behavior?

Re: FileExist fail (ahk_32 on x64 OS)

Posted: 29 Jun 2018, 12:04
by TheDewd
lexikos wrote:If you're running 32-bit AutoHotkey (or any 32-bit program) on a 64-bit OS, C:\Windows\System32 is redirected to C:\Windows\SysWow64. In that case, [file] most likely really doesn't exist at that path, as accessed from a 32-bit program.

For AutoHotkey 32-bit, use SysNative instead of System32.
Source: https://autohotkey.com/boards/viewtopic ... 679#p20679

Code: Select all

f := FileOpen("C:\Windows\SysNative\dwm.exe","r","CP0")
	if !IsObject(f)
		MsgBox 0
MsgBox % FileExist("C:\Windows\SysNative\dwm.exe")

Code: Select all

MsgBox % FileExist("C:\Windows\" (A_PtrSize = 8 ? "System32" : "SysNative") "\dwm.exe")

Re: FileExist fail (ahk_32 on x64 OS)  Topic is solved

Posted: 29 Jun 2018, 12:28
by Flipeador