Sign in to follow this  
Followers 0
Guest Lan-Kern

C#

3 posts in this topic

Ok I am trying to get this to work from within C#. Here is the code I have:

[DllImport ("AutoItX3.Dll", EntryPoint="AU3_WinGetText")]

public static extern void WinGetText(string title, string text, ref string returnTxt, int buff);

and when i call it like this and pass in ref temp as the 3rd parameter it always comes back unchanged.

Any Ideas?

Share this post


Link to post
Share on other sites



Ok I am trying to get this to work from within C#.  Here is the code I have:

[DllImport ("AutoItX3.Dll", EntryPoint="AU3_WinGetText")]

public static extern void WinGetText(string title, string text, ref string returnTxt, int buff);

and when i call it like this and pass in ref temp as the 3rd parameter it always comes back unchanged.

Any Ideas?

<{POST_SNAPBACK}>

It seems like C# is having trouble converting from char* to string. . if you use byte[] as the param it works fine.

[DllImport ("AutoItX3.Dll", EntryPoint="AU3_WinGetText")]

public static extern void WinGetText(string title, string text, byte[] returnTxt, int buff);

Share this post


Link to post
Share on other sites

It seems like C# is having trouble converting from char* to string. . if you use byte[] as the param it works fine.

[DllImport ("AutoItX3.Dll", EntryPoint="AU3_WinGetText")]

public static extern void WinGetText(string title, string text, byte[] returnTxt, int buff);

You can also use an InPtr type. This is right out of MSDN:

Note Win32 API functions that allocate a string enable you to free the string by using a method such as LocalFree. Platform invoke handles such parameters differently. For platform invoke calls, make the parameter an IntPtr type instead of a String type. Use methods provided by the System.Runtime.InteropServices.Marshal class to convert the type to a string manually and free it manually.

Share this post


Link to post
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
Sign in to follow this  
Followers 0