onestcoder Posted January 13, 2008 Posted January 13, 2008 I'm trying to figure out a way to convert this C# or VB.net dll call to autoit. I want to understand how it is done, not just to get someone to write it for me because I have more conversions I need to make, but if some one would show me I'm sure I can learn from the example. Here are two codes: C# [DllImport("FFACE.dll", EntryPoint = "GetTargetName")] public static extern void sName(byte[] buffer, ref int size); public static string Name() { int s = 20; byte[] b = new byte[21]; sName(b, ref s); return System.Text.Encoding.ASCII.GetString(b, 0, s - 1); } VB.net Private Declare Ansi Sub sName Lib "FFACE.dll" Alias "GetTargetName" (ByVal buffer() As Byte, ByRef size As Integer) Public Shared Function Name() As String Dim s As Integer = 20 Dim b(20) As Byte sName(b, s) Return System.Text.Encoding.ASCII.GetString(b, 0, s - 1) End Function Need a website: http://www.iconixmarketing.com
onestcoder Posted January 13, 2008 Author Posted January 13, 2008 Hmmm Maybe if someone could just point me to an example so I may figure it out all on my own. Or is it even possible to do this in autoit? Need a website: http://www.iconixmarketing.com
weaponx Posted January 13, 2008 Posted January 13, 2008 I searched the forum for FFACE.dll and it seems as though you already have 2 topics about converting this from C into AutoIT. Why don't you refer back to those.
onestcoder Posted January 14, 2008 Author Posted January 14, 2008 I searched the forum for FFACE.dll and it seems as though you already have 2 topics about converting this from C into AutoIT. Why don't you refer back to those. And they got me to this point. The simple dllcall using FFACE.dll work great. But what I'm working on now requires more conversion of the results. I have tested with all the standard autoit functions and it crashes autoit. It is this part of the code I need help with understanding. (byte[] buffer, ref int size); public static string Name() { int s = 20; byte[] b = new byte[21]; sName(b, ref s); return System.Text.Encoding.ASCII.GetString(b, 0, s - 1); } Need a website: http://www.iconixmarketing.com
onestcoder Posted January 14, 2008 Author Posted January 14, 2008 (edited) All of my attemps have no worked. when i call the GetTargetName function using all of the standard return type autoit crashs. All I can think of this im not doing the call back right. my last try was using: $dll = DllOpen("FFACE.dll") $running = DllCall($dll, "int", "InitFFACE") ;Initialize the DLL. Will return false if FFXI isnt running. if @error = 0 Then ; Check for errors if $running[0] Then ;Check to see if FFXI is running. $result = DllCall($dll, "int", "GetTargetName") ;If it is, lets call our function. if @error= 0 Then MsgBox(0, "", $result[0]) ;Display our Target Name EndIf Else MsgBox(0, "Couldnt Find FFXI", "FFXI Is NOT Running") ; FFXI wasnt running EndIf Else MsgBox(0, "Some Error Occured", "@error = " + @error) ; An error occured, lets display the error number. EndIf DllClose($dll) Edited January 14, 2008 by onestcoder Need a website: http://www.iconixmarketing.com
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now