LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with launching OSK (on-screen keyboard) using LaunchExecutableEx in Windows 10

Solved!
Go to solution

Hallo, 

I developed an application which calls the on-screen keyboard when the String control gets the focus. I use the function LaunchExecutableEx to run the OSK.EXE, which is the part of Windows. In WindowsXP it works normally, in Windows 10 the OSK is not launched and the error message appears saying that Function on-screen keyboard cannot be launched, eventhough the return value of the function LaunchExecutableEx is 0. I tried also the example "launchexe" in utility CVI samples with the same result. When I run "osk" command in "cmd" window, the OSK appears normally. Can you tell what could be the problem?

I use the LabWindows/CVI 2019 now. The first version of my application was developed in LW/CVI 2015, the same problem exists when I run this application under Win10.

Thank you for the answer, with best regards

 

Roman Vitek.

 

0 Kudos
Message 1 of 5
(6,997 Views)
Solution
Accepted by topic author Roman_Vitek

Solved. The application must be built for 64-bit target operating system. Sorry for disturbing,

Roman. 

0 Kudos
Message 2 of 5
(6,970 Views)
Solution
Accepted by topic author Roman_Vitek

Hi,

 

You can run osk.exe from 32 bit exe too. You just have to disable WOW64 file system redirection first and then revert to original when launched.

See Code below

 

void LaunchOSK(void)
{
 // If process is running as 32 bit on 64 bit OS then windows on windows is enabled
 if(IsWow64())
 {
  // Wow64DisableWow64FsRedirection is useful for 32-bit applications that want to gain access
  // to the native system32 directory. By default, WOW64 file system redirection is enabled.
  PVOID pOldValue = NULL;
  LPFN_WOW64DISABLEWOW64FSREDIRECTION fnWow64DisableWow64FsRedirection;
  LPFN_WOW64REVERTWOW64FSREDIRECTION fnWow64RevertWow64FsRedirection;

  fnWow64DisableWow64FsRedirection = (LPFN_WOW64DISABLEWOW64FSREDIRECTION) GetProcAddress(GetModuleHandle(TEXT("kernel32")), "Wow64DisableWow64FsRedirection");
  fnWow64RevertWow64FsRedirection = (LPFN_WOW64REVERTWOW64FSREDIRECTION) GetProcAddress(GetModuleHandle(TEXT("kernel32")), "Wow64RevertWow64FsRedirection");

  if(fnWow64DisableWow64FsRedirection != NULL && fnWow64RevertWow64FsRedirection != NULL)
  {
   if(fnWow64DisableWow64FsRedirection(&pOldValue))
   {
    // Run native 64 bit on screen keyboard for 32 bit application
    LaunchExecutable("osk.exe");
    fnWow64RevertWow64FsRedirection(pOldValue);
   }
  }
 }
 else
  LaunchExecutable("osk.exe");
}

 

Jan

 

Message 3 of 5
(6,877 Views)

Hi,

because I didnt find the defnitions of the function IsWow64() and type LPFN_WOW64REVERTWOW64FSREDIRECTION, I tried a simplyfied version of the code you have posted

 

PVOID pOldValue;

if(Wow64DisableWow64FsRedirection(&pOldValue))
{
   LaunchExecutableEx("osk.exe",LE_SHOWNORMAL,&hOSK);
   Wow64RevertWow64FsRedirection(pOldValue);
}

 

On Windows 10 64-bit it works fine. Thank you for the advice, with best regards

 

Roman.

Message 4 of 5
(6,859 Views)

You can find IsWow64 ()  on Microsoft Docs as example to IsWow64Process:

https://docs.microsoft.com/en-us/windows/win32/api/wow64apiset/nf-wow64apiset-iswow64process#example...

 

#include <windows.h>

 

typedef BOOL (WINAPI *LPFN_ISWOW64PROCESS) (HANDLE, PBOOL);

LPFN_ISWOW64PROCESS fnIsWow64Process;

 

BOOL IsWow64()

{

  BOOL bIsWow64 = FALSE;

  //IsWow64Process is not available on all supported versions of Windows.

  //Use GetModuleHandle to get a handle to the DLL that contains the function

  //and GetProcAddress to get a pointer to the function if available.

  fnIsWow64Process = (LPFN_ISWOW64PROCESS) GetProcAddress( GetModuleHandle(TEXT("kernel32")),"IsWow64Process");

  if(NULL != fnIsWow64Process)

  {

    if (!fnIsWow64Process(GetCurrentProcess(),&bIsWow64))

    {

      //handle error

    }

  }

  return bIsWow64;

}

0 Kudos
Message 5 of 5
(6,001 Views)