Jump to content

What's wrong in DLL Call?


E1M1
 Share

Recommended Posts

I am new to dll stuff ;) Why I see 0 in msgbox? I should see 4 there.

MsgBox(0,0,DllCall("formulas.dll","dword","sub","int",2,"int",2))

Dll

#include "stdafx.h"

#define DLL extern "C" __declspec(dllexport)

DLL WORD sum(int a,int b)
{
    return a+b;
}
Edited by E1M1

edited

Link to comment
Share on other sites

Is my autoit code bad or DLL?

$var = DllCall("formulas.dll","int","sub","int",2,"int",2) 
MsgBox(0,0,$var[0])

C:\Users\rain\Documents\Visual Studio 2008\Projects\formulas\Debug\dllcall.au3 (2) : ==> Subscript used with non-Array variable.:
MsgBox(0,0,$lol[0])
MsgBox(0,0,$lol^ ERROR

edited

Link to comment
Share on other sites

You didn't specify a default calling convention in your dll project right? So it's assumed to be __cdecl, try:

$var = DllCall("formulas.dll","int:cdecl","sub","int",2,"int",2)
MsgBox(0,0,$var[0])

..or specify the calling convention in the dll project:

#include "stdafx.h"

#define DLL extern "C" __declspec(dllexport)

DLL WORD WINAPI sum(int a,int <img src='http://www.autoitscript.com/forum/public/style_emoticons/<#EMO_DIR#>/cool.png' class='bbc_emoticon' alt='B)' />
{
    return a+b;
}

Edit: It's sum not sub.

$var = DllCall("formulas.dll","int:cdecl","sum","int",2,"int",2)
MsgBox(0,0,$var[0])

..and the return value is ushort not int. ;)

Edited by Authenticity
Link to comment
Share on other sites

eh what's wrong? I cant find it.

$var = DllCall("formulas.dll","int:cdecl","sub","int",2,"int",2)

DLLcall return 0 but

msgbox cause error

C:\Users\rain\Documents\Visual Studio 2008\Projects\formulas\Debug\dllcall.au3 (4) : ==> Subscript used with non-Array variable.:
MsgBox(0,0,$var[0])
MsgBox(0,0,$var^ ERROR

edited

Link to comment
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
 Share

  • Recently Browsing   0 members

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