08-31-2019 12:31 PM
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.
Solved! Go to Solution.
08-31-2019 02:39 PM
Solved. The application must be built for 64-bit target operating system. Sorry for disturbing,
Roman.
09-03-2019 06:04 AM
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
09-05-2019 03:42 AM
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.
08-05-2020 07:10 AM
You can find IsWow64 () on Microsoft Docs as example to IsWow64Process:
#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;
}