Discussion:
File Redirection on 64bit OS
(too old to reply)
Jerry West
2008-06-18 01:49:15 UTC
Permalink
My 32bit VB app needs to check for the existence of a file located in the
system32\drivers folder on a 64bit system. Because of file redirection my
app cannot see the file. I am aware of the API
Wow64DisableWow64FsRedirection. I make a call to it before checking for the
file. The call indicates success yet the file still is hidden due to
redirection. Here is a snippet of my code:

Declare Function Wow64DisableWow64FsRedirection Lib "Kernel32.dll" (ByRef
OldValue As Long) As Long

lRet& = Wow64DisableWow64FsRedirection(lOldValue&)

If gFSO.FileExists(udtCurOS.sWinSysDirUNC & "\drivers\" & sFile$) Then
DoSomething

lRet always is a non-zero value indicating success and I get a value in
lOldValue&. Yet, like I said, the call still fails when checking for the
file's existence.

Does anyone know if I'm doing this correctly? It sure appears so but I'm
baffled at this point. Any help appreciated!

JW
MikeD
2008-06-18 02:08:11 UTC
Permalink
Post by Jerry West
My 32bit VB app needs to check for the existence of a file located in the
system32\drivers folder on a 64bit system. Because of file redirection my
app cannot see the file. I am aware of the API
Wow64DisableWow64FsRedirection. I make a call to it before checking for
the file. The call indicates success yet the file still is hidden due to
Declare Function Wow64DisableWow64FsRedirection Lib "Kernel32.dll" (ByRef
OldValue As Long) As Long
lRet& = Wow64DisableWow64FsRedirection(lOldValue&)
If gFSO.FileExists(udtCurOS.sWinSysDirUNC & "\drivers\" & sFile$) Then
DoSomething
lRet always is a non-zero value indicating success and I get a value in
lOldValue&. Yet, like I said, the call still fails when checking for the
file's existence.
Does anyone know if I'm doing this correctly? It sure appears so but I'm
baffled at this point. Any help appreciated!
Just a guess, but try it without the FSO. You shouldn't be using that thing
anyway in VB6.
--
Mike
Microsoft MVP Visual Basic
Bill McCarthy
2008-06-18 03:15:58 UTC
Permalink
Hi Jerry,


I tested it here and the API definitely works on Vista X64 with VB6 using
Dir.

Private Declare Function Wow64DisableWow64FsRedirection Lib "Kernel32"
(ByRef oldvalue As Long) As Boolean
Private Declare Function Wow64RevertWow64FsRedirection Lib "Kernel32" (ByVal
oldvalue As Long) As Boolean


Private Sub Command1_Click()
Dim ret As Boolean
Dim oldvalue As Long
oldvalue = 0

Debug.Print "with redirection file name is : " &
Dir("C:\Windows\System32\alg.exe")

ret = Wow64DisableWow64FsRedirection(oldvalue)

Debug.Print "without redirection file name is " &
Dir("C:\Windows\System32\alg.exe")

Wow64RevertWow64FsRedirection oldvalue

End Sub


This outputs:
with redirection file name is :
without redirection file name is alg.exe
Post by Jerry West
My 32bit VB app needs to check for the existence of a file located in the
system32\drivers folder on a 64bit system. Because of file redirection my
app cannot see the file. I am aware of the API
Wow64DisableWow64FsRedirection. I make a call to it before checking for
the file. The call indicates success yet the file still is hidden due to
Declare Function Wow64DisableWow64FsRedirection Lib "Kernel32.dll" (ByRef
OldValue As Long) As Long
lRet& = Wow64DisableWow64FsRedirection(lOldValue&)
If gFSO.FileExists(udtCurOS.sWinSysDirUNC & "\drivers\" & sFile$) Then
DoSomething
lRet always is a non-zero value indicating success and I get a value in
lOldValue&. Yet, like I said, the call still fails when checking for the
file's existence.
Does anyone know if I'm doing this correctly? It sure appears so but I'm
baffled at this point. Any help appreciated!
JW
Jerry West
2008-06-18 03:52:47 UTC
Permalink
Thanks, yes, you are quite right. It does work.

Thanks!

JW
Post by Bill McCarthy
Hi Jerry,
I tested it here and the API definitely works on Vista X64 with VB6 using
Dir.
Private Declare Function Wow64DisableWow64FsRedirection Lib "Kernel32"
(ByRef oldvalue As Long) As Boolean
Private Declare Function Wow64RevertWow64FsRedirection Lib "Kernel32"
(ByVal oldvalue As Long) As Boolean
Private Sub Command1_Click()
Dim ret As Boolean
Dim oldvalue As Long
oldvalue = 0
Debug.Print "with redirection file name is : " &
Dir("C:\Windows\System32\alg.exe")
ret = Wow64DisableWow64FsRedirection(oldvalue)
Debug.Print "without redirection file name is " &
Dir("C:\Windows\System32\alg.exe")
Wow64RevertWow64FsRedirection oldvalue
End Sub
without redirection file name is alg.exe
Post by Jerry West
My 32bit VB app needs to check for the existence of a file located in the
system32\drivers folder on a 64bit system. Because of file redirection my
app cannot see the file. I am aware of the API
Wow64DisableWow64FsRedirection. I make a call to it before checking for
the file. The call indicates success yet the file still is hidden due to
Declare Function Wow64DisableWow64FsRedirection Lib "Kernel32.dll" (ByRef
OldValue As Long) As Long
lRet& = Wow64DisableWow64FsRedirection(lOldValue&)
If gFSO.FileExists(udtCurOS.sWinSysDirUNC & "\drivers\" & sFile$) Then
DoSomething
lRet always is a non-zero value indicating success and I get a value in
lOldValue&. Yet, like I said, the call still fails when checking for the
file's existence.
Does anyone know if I'm doing this correctly? It sure appears so but I'm
baffled at this point. Any help appreciated!
JW
Loading...