![]() ![]() ProcessStartInfo psi = new ProcessStartInfo() ![]() Disable 圆4 directory virtualization if we're on 圆4, WM_SYSCOMMAND, new IntPtr(SC_RESTORE), new IntPtr(0)) īool sucessfullyDisabledWow64Redirect = false meanwhile -> proper exception handling should be added there might be a race condition if the process terminated ![]() Thread.SetApartmentState(ApartmentState.MTA) ThreadStart start = new ThreadStart(StartOsk) Path.GetFileNameWithoutExtension(OnScreenKeyboardExe)) Private const string OnScreenKeyboardExe = "osk.exe" Private const UInt32 SC_RESTORE = 0xf120 Private const UInt32 WM_SYSCOMMAND = 0x112 Static extern IntPtr SendMessage(IntPtr hWnd, ![]() Public static extern bool Wow64RevertWow64FsRedirection(IntPtr ptr) Private static extern bool Wow64DisableWow64FsRedirection(ref IntPtr ptr) The code below checks the apartment state and then makes sure to start the On-Screen Keyboard from an MTA thread: using System when UseShellExecute is set to false and also when being called from an STA thread as it seems. However, under certain conditions, Process.Start will create the new process from a separate thread, e.g. The reason seems to be that a call to Wow64DisableWow64FsRedirection only affects the current thread. Var path32 = path = (Environment.Is64BitOperatingSystem) ? path64 : path32 Ĭertain things are going on under the hood that require you to start osk.exe from an MTA thread. This is my code var path64 = Path.Combine(Directory.GetDirectories(Path.Combine(Environment.GetFolderPath(), "winsxs"), "amd64_microsoft-windows-osk_*"), "osk.exe") Var path64 = path32 = path = (Environment.Is64BitOperatingSystem) ? path64 : path32 Solution 2Ī 32 bit application running on a 64 bit operating system should start the 64 bit version of osk.exe.īelow you see a code snipped written in C# to start the correct on screen keyboard. A very small helper EXE that you compile with Platform Target = Any CPU can solve your problem. There are lots of DLLs that get demand-loaded. You don't need it here.Ĭlearly, disabling redirection is a risky approach with side-effects you cannot really predict. You'll get the wrong one when you disable redirection.Ī workaround for that is to set ProcessStartInfo.UseShellExecute to false. This function lives in shell32.dll, a DLL that might have to be loaded if that wasn't previously done. By default, Process.Start() P/Invokes the ShellExecuteEx() API function to start the process. But disabling redirection is going to mess up the. I don't have a very solid explanation for the exact error message you are getting. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |