Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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

  • *Gurus*
Posted

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

Posted (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 by divil
Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...