Sign in to follow this  
Followers 0
blahblahblah5038

A Beginner needs help

5 posts in this topic

I wanted to learn how to use C++ dll files in auto it for a larger program I am working on, so I made a simple program in auto it, and a simple c++ dll just to try and learn. I think of it as my version of the hello world program. The idea is that the math that the dll does should match the math that auto it does. Problem is that they don't, the dll always returns 0. I need help.

Here is the code for the auto it program and the c++ dll as well as the compiled dll

CODE

; auto it

for $count1 = 1 to 10

for $count2= 1 to 10

$close = DllOpen("dll test.dll")

$A = DllCall ("dll test.dll", "int", "addTEST", "int", $count1, "int", $count2)

$B = DllCall ("dll test.dll", "int", "multTEST", "int", $count1, "int", $count2)

$C = $count1 +$count2

$D = $count1 *$count2

MsgBox (0, "Addition Test", "Internal math " & $count1 & "+" &$count2 & "=" &$C)

MsgBox (0, "Addition Test", "Dll math " & $count1 & "+" &$count2 & "=" &$A)

MsgBox (0, "Multiplication Test", "Internal math " & $count1 & "*" &$count2 & "=" &$D)

MsgBox (0, "Multiplication Test", "Dll math " & $count1 & "*" &$count2 & "=" &$:)

DllClose ($close)

Next

Next

CODE
// dll test.cpp : Defines the entry point for the DLL application.

//

//c++ dll

#ifdef _MANAGED

#pragma managed(push, off)

#endif

int addTEST (int A, int Bb);

int multTEST (int A, int Bb);

BOOL APIENTRY DllMain( HMODULE hModule,

DWORD ul_reason_for_call,

LPVOID lpReserved

)

{

return TRUE;

}

#ifdef _MANAGED

#pragma managed(pop)

#endif

int addTEST (int A, int Bb)

{

int nReturn;

nReturn = A + Bb ;

return nReturn;

}

int multTEST (int A, int Bb)

{

int nReturn;

nReturn = A*Bb;

return nReturn;

}

dll_test.dll


Noteworthy works:Fast Pixel SearchSigned: WG

Share this post


Link to post
Share on other sites



Any help would be most appreciated.


Noteworthy works:Fast Pixel SearchSigned: WG

Share this post


Link to post
Share on other sites

First of all, DllCall returns an array, not just the return value.

Also, I checked your dll itself, you don't have any functions exported. I'm afraid I don't know how to do that because every time I tried to do so, it didn't work.

Share this post


Link to post
Share on other sites

Thankyou, I think I'll look into those


Noteworthy works:Fast Pixel SearchSigned: WG

Share this post


Link to post
Share on other sites

I solved the problems, got the dll to work, and then implemented the changes on the larger program I was working on for an ultra fast pixel search. Thanks again.


Noteworthy works:Fast Pixel SearchSigned: WG

Share this post


Link to post
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
Sign in to follow this  
Followers 0