0

In researching how to do make the osk visible, I found the code below, created a new solution, added 2 buttons, pasted in the code and it worked perfectly. When I added it to the solution I've been working on, nothing happened:

Public Class Form1
    Declare Function Wow64DisableWow64FsRedirection Lib "kernel32" (ByRef oldvalue As Long) As Boolean
    Declare Function Wow64EnableWow64FsRedirection Lib "kernel32" (ByRef oldvalue As Long) As Boolean
    Private osk As String = "C:\Windows\System32\osk.exe"
    Private pOSK As Process = Nothing

Private Sub Keyboard_Show()
        'An instance is running 
        For Each pkiller As Process In Process.GetProcesses
            If String.Compare(pkiller.ProcessName, "osk", True) = 0 Then pOSK = pkiller
        Next

        'If no instance of OSK is running than create one depending on 32/64 bit
        For Each pkiller As Process In Process.GetProcesses
            If Not (String.Compare(pkiller.ProcessName, "osk", True) = 0) And (pOSK Is Nothing) Then

                Dim old As Long
                If Environment.Is64BitOperatingSystem Then ' returns true
                    '64 Bit
                    If Wow64DisableWow64FsRedirection(old) Then ' returns false
                        pOSK = Process.Start(osk)
                        Wow64EnableWow64FsRedirection(old)
                    End If


                Else
                    '32 Bit
                    pOSK = Process.Start(osk)
                End If
                Exit For
            End If
        Next
    End Sub

 Public Sub Keyboard_Show()
        'An instance is running 
        For Each pkiller As Process In Process.GetProcesses
            If String.Compare(pkiller.ProcessName, "osk", True) = 0 Then pOSK = pkiller
        Next

        'If no instance of OSK is running than create one depending on 32/64 bit
        For Each pkiller As Process In Process.GetProcesses
            If Not (String.Compare(pkiller.ProcessName, "osk", True) = 0) And (pOSK Is Nothing) Then

                Dim old As Long
                If Environment.Is64BitOperatingSystem Then
                    '64 Bit
                    If Wow64DisableWow64FsRedirection(old) Then
                        pOSK = Process.Start(osk)
                        Wow64EnableWow64FsRedirection(old)
                    End If
                Else
                    '32 Bit
                    pOSK = Process.Start(osk)
                End If
                Exit For
            End If
        Next
    End Sub

When running on my actual project, If Environment.Is64BitOperatingSystem Then returns True, but
If Wow64DisableWow64FsRedirection(old) Then returns False

For troubleshooting purposes, I tried avoiding the whole subroutine and just used
Process.Start("c:\windows\system32\osk.exe") which threw an exception:
System.ComponentModel.Win32Exception: 'The requested operation requires elevation.'

Thoughts? Any help would be greatly appreciated!

Ryan G
  • 1
  • 1

1 Answers1

-1

Bonjour, après beaucoup de recherche, j'arrive a ca : (/!\ x86)

            Dim old As Long
        If Environment.Is64BitOperatingSystem Then
            If Wow64DisableWow64FsRedirection(old) Then
                Dim RepPrgClavierVirtuel As String = Path.Combine(Directory.GetDirectories(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Windows), "winsxs"), "amd64_microsoft-windows-osk_*")(0), "osk.exe")

              Dim psi As ProcessStartInfo = New ProcessStartInfo(RepPrgClavierVirtuel)
                psi.UseShellExecute = True
                psi.Verb = "runas"
                Process.Start(psi)

                Wow64EnableWow64FsRedirection(old)
            End If
        Else
            Process.Start(MyParametres.Systeme.PrgClavierVirtuel)
        End If