Jump to content

[Solved] How to use different calling convention in DllCallbackRegister ?


Go to solution Solved by kcvinu,

Recommended Posts

Posted (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 by kcvinu
  Reveal hidden contents

 

  • kcvinu changed the title to How to use different calling convention in DllCallbackRegister ?
  • Solution
Posted

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.

 

  Reveal hidden contents

 

  • kcvinu changed the title to [Solved] How to use different calling convention in DllCallbackRegister ?

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
  • Recently Browsing   0 members

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