konya Posted August 28, 2023 Posted August 28, 2023 I have found the solution is to mix C# but I want to use pure Autoit . Use Autoit -> DotNet_LoadCScode call dll result correct,but I'm use Autoit dllcall result crash,please give me some advice. I have test as below : Autoit -> Transfer function PTR to C# -> DotNet_LoadCScode (CS code ) -> result correct. Autoit -> Transfer Struct PTR to C# -> DotNet_LoadCScode (CS code ) -> result correct. But Autoit self execute will crash. Autoit Code: (Crash) (1) DllCallAddress("bool" , $FunctionPTR.pfnSetParam ,"bool", true ,"word",3,"word",0,"word",0,"str","c:\" ) (2) $tag = DllStructCreate("struct;bool a;word b;word c;word d;char e[260];endstruct") $tag.a = True $tag.b = 3 $tag.c = 0 $tag.d = 0 $tag.e = "c:\" DllCallAddress("bool" , $FunctionPTR.pfnSetParam ,"ptr",DllStructGetPtr($tag) ) CS Code : (Result correct return) Autoit call CS $CTRL.SetParam() public delegate Boolean pfnSetParam(Test_PARAM Param); public pfnSetParam m_pfnSetParam = null; m_pfnSetParam = (pfnSetParam)GetAddress(m_test, Function.SETPARAM, typeof(pfnSetParam)); [StructLayout(LayoutKind.Sequential, Pack = 1)] public struct Test_PARAM { public Boolean btest; public UInt16 wtesta; public UInt16 wtestb; public UInt16 wtestc; [MarshalAs(UnmanagedType.ByValArray, SizeConst = 260)] public char[] szSaveFolder; } public Boolean SetParam() { Test_PARAM Param; Param.wtesta = 3; Param.wtestb = 0; Param.wtestc = 0; Param.btest = true; Param.szSaveFolder = "c:\"; m_pfnSetParam(Param); } Read Public or Pravite key information data tool (Read PEM) GDI+ Image deskew and crop
LarsJ Posted August 28, 2023 Posted August 28, 2023 To use the DllCall or DllCallAddress functions, the header in the dll-file must be in one of the formats Portable Executable (PE) or Common Object File Format (COFF). These files are usually coded in C/C++. But that's not the case for a C# dll-file. And that's the cause of the error. Controls, File Explorer, ROT objects, UI Automation, Windows Message MonitorCompiled code: Accessing AutoIt variables, DotNet.au3 UDF, Using C# and VB codeShell menus: The Context menu, The Favorites menu. Shell related: Control Panel, System Image ListsGraphics related: Rubik's Cube, OpenGL without external libraries, Navigating in an image, Non-rectangular selectionsListView controls: Colors and fonts, Multi-line header, Multi-line items, Checkboxes and icons, Incremental searchListView controls: Virtual ListViews, Editing cells, Data display functions
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