Guest MyNuS Posted December 6, 2002 Posted December 6, 2002 I've been having problems with a module that I am working on. I can get my program to send a wm_gettext message to an other aplication, but it won't send the string to the buffer. The function returns the appropriate lenght of string copied, and every other message that i try to send with sendmessage works. Thanks for your help. '--------------------------CODE------------------------ Imports System.Runtime.InteropServices Public Const WM_GETTEXT = &HD <DllImport("user32.dll")> _ Public Function SendMessage(ByVal hWnd As Integer, ByVal uMsg As Integer, ByVal wParam As Integer, ByVal lParam As String) As Integer End Function Function getWinText() As String Dim n As Integer, s As String, q As Integer s$ = Space$(255) n = SendMessage(3080978, WM_GETTEXTLENGTH, 0, 0) q = SendMessage(3080978, WM_GETTEXT, 254, s$) getImSn = s$ End Function Quote
*Gurus* Derek Stone Posted December 6, 2002 *Gurus* Posted December 6, 2002 Let me offer you this example: Public Declare Ansi Function GetWindowText Lib "User32.dll" Alias "GetWindowTextA" ( _ ByVal hwnd As Integer, _ ByVal lpString As StringBuilder, _ ByVal nMaxCount As Integer) As Integer Dim s As New StringBuilder(256) Win32API.GetWindowText(hwnd, s, s.Capacity) MessageBox.Show(s.ToString(), Application.ProductName) Also, for a brief overview of using buffers, take a look at this article: http://www.elitevb.com/content/01,0075,01/05.aspx Quote Posting Guidelines
Guest MyNuS Posted December 6, 2002 Posted December 6, 2002 (edited) Thanks for the help! I got it now. Just in case anyone else reads this for reference in vb.net you need to use: Imports System.Text to use the stringbuilder. Thanks again. Edited December 6, 2002 by divil Quote
Recommended Posts