Results 1 to 8 of 8

Thread: shellexecute versus opening from explorer

Threaded View

  1. #2
    Fanatic Member
    Join Date
    Jul 2007
    Location
    Essex, UK.
    Posts
    579

    Re: shellexecute versus opening from explorer

    When using 64bit Windows, I have had to do the following

    Code:
    Private Declare Function IsWow64Process Lib "kernel32.dll" (ByVal hProcess As Long, ByRef Wow64Process As Long) As Long
    Private Declare Function Wow64EnableWow64FsRedirection Lib "kernel32.dll" (ByVal Wow64FsEnableRedirection As Byte) As Byte
    Private Declare Function GetProcAddress Lib "kernel32" (ByVal hModule As Long, ByVal lpProcName As String) As Long
    Private Declare Function GetModuleHandle Lib "kernel32" Alias "GetModuleHandleA" (ByVal lpModuleName As String) As Long
    
    Private Function Is64bit() As Boolean
        Dim Ret As Long
        If GetProcAddress(GetModuleHandle("kernel32"), "IsWow64Process") > 0 Then
            IsWow64Process GetCurrentProcess(), Ret
        End If
        Is64bit = (Ret <> 0)
    End Function
    
    Public Function RunProg(Hwnd As Long, Path As String) As Long
        If Is64bit Then
            Wow64EnableWow64FsRedirection False
            RunProg = ShellExecute(Hwnd, "open", Path, vbNullString, GetPath(Path), vbNormalFocus)
            Wow64EnableWow64FsRedirection True
        Else
            RunProg = ShellExecute(Hwnd, "open", Path, vbNullString, GetPath(Path), vbNormalFocus)
        End If
    End Function
    Last edited by Steve Grant; Dec 31st, 2020 at 07:58 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width