WinAPI MoveWindow function not working for some windows

后端 未结 1 701
日久生厌
日久生厌 2021-01-14 20:58

I want to resize and/or move some external windows from my application, mainly the On-Screen keyboardwindow. Here is the code:

     [DllImport(\"user32.dll\"         


        
相关标签:
1条回答
  • 2021-01-14 21:29

    The on screen keyboard runs at a high integrity level. This means that you need your process also to run at that integrity level. The first thing to do is to execute your program as admin. That will run your process at a high integrity level.

    Of course, you are unlikely to find the prospect of running your app elevated, and so presenting its users with UAC dialogs, very appealing. But that's just a consequence of the system design.

    Do note that your error handling is incorrect. Only check the error code if the API functions fails. Which means checking the return value of the function. And your p/invoke for SetWindowPos is flawed. It fails to set SetLastError. These details really do matter and you must take great care. The compiler cannot check interop code for correctness.

    0 讨论(0)
提交回复
热议问题