Note that there are some explanatory texts on larger screens.

plurals
  1. POFunction "SendMessage" of User32.dll does not work in Windows 8
    primarykey
    data
    text
    <p>I am developing a piece of software to extract some information from a external desktop application, the thing is that i am working in Windows 7 using C# and I have got a workable application that uses the stuff of here:</p> <p><a href="https://stackoverflow.com/questions/18880330/how-can-i-retrieve-the-values-from-window-of-class-thunderrt6listbox-using-use/">How can I retrieve the values from window of class &quot;ThunderRT6ListBox&quot; using user32.dll in c#</a></p> <p>But the problem comes when I test the same software against the same external application in Windows 8, it doesn't work in the same way.</p> <p>I can copy the handler id of the controls but when I use the SendMessage function, for example, to put a new text to a edit control (textbox), nothing is happened.</p> <pre><code> public static void SetText(IntPtr HWnd, string strTextToSet) { var text = new StringBuilder(strTextToSet); SendMessage(HWnd, WM_SETTEXT, IntPtr.Zero, text); } </code></pre> <p>Is there any consideration in Windows 8 when it used this stuff?</p> <p>UPDATE:</p> <p>Still it does not work. GetText works, but SetText doesn't.</p> <p>My code:</p> <pre><code> [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)] static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam); const uint WM_SETTEXT = 0x000C; public static string GetText(IntPtr hwnd) { var text = new StringBuilder(1024); if (SendMessageTimeoutText(hwnd, 0xd, 1024, text, 0x2, 1000, 0) != 0) { return text.ToString(); } return ""; } public static void SetText(IntPtr HWnd, string strTextToSet) { //var text = new StringBuilder(strTextToSet); IntPtr text = System.Runtime.InteropServices.Marshal.StringToCoTaskMemUni(strTextToSet); SendMessage(HWnd, WM_SETTEXT, IntPtr.Zero, text); } </code></pre> <p>UPDATE 2:</p> <p>Error code:</p> <pre><code> ModApi.SetText(hwEdit, "foo_namE"); //The textbox does not change int error_code = Marshal.GetLastWin32Error(); //error_code is 5 </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload