Unable to launch onscreen keyboard (osk.exe) from a 32-bit process on Win7 x64

前端 未结 6 1291
抹茶落季
抹茶落季 2020-12-03 14:08

90% of the time I am unable to launch osk.exe from a 32bit process on Win7 x64. Originally the code was just using:

Process.Launch(         


        
6条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-03 14:45

    I don't have a very solid explanation for the exact error message you are getting. But disabling redirection is going to mess up the .NET framework. By default, Process.Start() P/Invokes the ShellExecuteEx() API function to start the process. This function lives in shell32.dll, a DLL that might have to be loaded if that wasn't previously done. You'll get the wrong one when you disable redirection.

    A workaround for that is to set ProcessStartInfo.UseShellExecute to false. You don't need it here.

    Clearly, disabling redirection is a risky approach with side-effects you cannot really predict. There are lots of DLLs that get demand-loaded. A very small helper EXE that you compile with Platform Target = Any CPU can solve your problem.

提交回复
热议问题