Jump to content

doing the same in vb.net -dllimport wingettext


giorget
 Share

Recommended Posts

As in precedent post i'm tryng do the same of this old post, importing wingettext

http://www.autoitscript.com/forum/lofivers...php?t10267.html

As this guy i always return a zero from the function.

this is the API declaration of c++

AU3_API void WINAPI AU3_WinGetText(const char *szTitle, /*[in,defaultvalue("")]*/const char *szText, char *szRetText, int nBufSize);

this how i import:

<DllImport("Autoitx3.dll")> _

Public Shared Sub AU3_WinGetText(ByVal strTitle As String, ByVal strText As String, ByRef returntxt As String, ByVal bufsize As Integer)

End Sub

and this is the way i call:

Dim test As String

AU3_WinGetText("Sapgui 640", "", test, 100)

maybe something wrong in nbufsize parameter? in the pasted post they speak about using a byte array as third parameter but i always receive a zero.

for test i've tried to use a normal call with referenced object (no dllimport) and works correctly

Any ideas?

thanks!

Link to comment
Share on other sites

Try using an array of byte for the buffer.

Declare Sub AU3_WinGetText Lib "AutoItX3.dll" (ByVal Title As String, ByVal Txt As String, ByVal Buffer() As Byte, ByVal BufSize As Integer)

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click

Dim buff(100) As Byte

Dim st As String = ""

Dim i As Integer = 0

AU3_WinGetText("Untitled", "", buff, 100)

Do While (buff(i) <> 0)

st = st + Chr(buff(i))

i = i + 1

Loop

MsgBox(st)

End Sub

Link to comment
Share on other sites

Try using an array of byte for the buffer.

Declare Sub AU3_WinGetText Lib "AutoItX3.dll" (ByVal Title As String, ByVal Txt As String, ByVal Buffer() As Byte, ByVal BufSize As Integer)

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click

Dim buff(100) As Byte

Dim st As String = ""

Dim i As Integer = 0

AU3_WinGetText("Untitled", "", buff, 100)

Do While (buff(i) <> 0)

st = st + Chr(buff(i))

i = i + 1

Loop

MsgBox(st)

End Sub

It works!!! thanks a lot....REally!!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...