kcvinu Posted May 22, 2023 Share Posted May 22, 2023 (edited) Hi all, I am doing an experiment with DllCall function. I wrote the dll in D programming language. Unfortunately, I am compelled to use two different calling conventions for my dll. Most of the functions from that dll uses cdecl. But one function uses stdcall. Anyways, I can successfully call those functions from Autoit. But there is a problem. I use this code to set a function pointer. func onMouseDown($sender, $eventArgs) Local $control = DllCall($hDll, "ptr:cdecl", "getControl", "ptr", $sender)[0] Local $hwnd = DllCall($hDll, "hwnd:cdecl", "getHandle", "ptr", $control)[0] MsgBox(0, "Dflex message", "Hi, this message is from Autoit", 0, $hwnd) EndFunc Local $pCallback = DllCallbackRegister("onMouseDown", "none", "ptr;ptr") Local $pfuncPtr = DllCallbackGetPtr($pCallback) But the WndProc function which I use to call this function pointer uses "stdcall" convention. So inside my "onMouseDown" function, I got the parameters in reverse order. That means, $sender is an EventArgs class and $eventArgs is actually a Control class. How to fix this ? Is there any way to tell the calling convention in DllCallBackRegister ? EDIT NOTE: I have changed all my functions to stdcall and re run my program. But the results are same. Still parameters are in reverse order. But when using stdcall, compiled exe file is not working. Both 32 bit and 64 bit. Script will run in scite editor. Edited May 22, 2023 by kcvinu Spoiler My Contributions Glance GUI Library - A gui library based on Windows api functions. Written in Nim programming language. UDF Link Viewer --- A tool to visit the links of some most important UDFs Includer_2 ----- A tool to type the #include statement automatically Digits To Date ----- date from 3 integer values PrintList ----- prints arrays into console for testing. Alert ------ An alternative for MsgBox MousePosition ------- A simple tooltip display of mouse position GRM Helper -------- A littile tool to help writing code with GUIRegisterMsg function Access_UDF -------- An UDF for working with access database files. (.*accdb only) Link to comment Share on other sites More sharing options...
Solution kcvinu Posted May 22, 2023 Author Solution Share Posted May 22, 2023 Ah, Never mind. I solved it by myself. It has nothing to do with Autoit. The problem was in D side. Just tell the calling convention of the callback function and it's done. Spoiler My Contributions Glance GUI Library - A gui library based on Windows api functions. Written in Nim programming language. UDF Link Viewer --- A tool to visit the links of some most important UDFs Includer_2 ----- A tool to type the #include statement automatically Digits To Date ----- date from 3 integer values PrintList ----- prints arrays into console for testing. Alert ------ An alternative for MsgBox MousePosition ------- A simple tooltip display of mouse position GRM Helper -------- A littile tool to help writing code with GUIRegisterMsg function Access_UDF -------- An UDF for working with access database files. (.*accdb only) Link to comment Share on other sites More sharing options...
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