Jump to content
Sign in to follow this  
Insolence

Trying to create a DLL

Recommended Posts

Insolence

[Kind of OT]

Do any of you C++ worn old folk have a link to on specifically on the creation of DLL's and anything else that would be important to that.

[/OT]

Here's the source:

#include <windows.h>
__declspec(dllexport) int Hello();

int Hello(){
    MessageBox( NULL, "Hello world!", NULL, MB_OK ); 
    return 1;            
}

Here's the AutoIT file:

$test = DllCall( @ScriptDir & "\Project1.dll", "int", "Hello" )

MsgBox("","", $Test)

It should throw the "Hello world!" message box, and then throw the successfully returned value "1". Obviously, it's not.

As with my last DLL post I feel ashamed, please don't bash me... or if you have to, be gentle :idiot:


"I thoroughly disapprove of duels. If a man should challenge me, I would take him kindly and forgivingly by the hand and lead him to a quiet place and kill him." - Mark TwainPatient: "It hurts when I do $var_"Doctor: "Don't do $var_" - Lar.

Share this post


Link to post
Share on other sites
Insolence

Thanks.

I didn't really understand most of that, I got rid of as much of the DLL as I could, it's just one file... that's all the code.

I thought I should post it there, but I think people need to see it here also.

I'm playing SC right now, but I'll do the $Test[0] thing, thanks.


"I thoroughly disapprove of duels. If a man should challenge me, I would take him kindly and forgivingly by the hand and lead him to a quiet place and kill him." - Mark TwainPatient: "It hurts when I do $var_"Doctor: "Don't do $var_" - Lar.

Share this post


Link to post
Share on other sites
Insolence

I get

C:\Documents and Settings\Eric\Desktop\programming\cpp\memory reader\test.au3 (3) : ==> Subscript used with non-Array variable.:

now, so I assume it's just not returning a single thing.

eh :idiot:


"I thoroughly disapprove of duels. If a man should challenge me, I would take him kindly and forgivingly by the hand and lead him to a quiet place and kill him." - Mark TwainPatient: "It hurts when I do $var_"Doctor: "Don't do $var_" - Lar.

Share this post


Link to post
Share on other sites
Valik

The name for that is mangled via the C++ compiler. It needs to be extern "C" in order to have the correct name.

This should work.

#include <windows.h>

extern "C" __declspec(dllexport) int Hello(){
    MessageBox( NULL, "Hello world!", NULL, MB_OK );
    return 1;           
}

Or, as Larry mentioned, you need a module definition file and then you can do without the 'extern "C" __declspec(dllexport)' stuff.

Share this post


Link to post
Share on other sites
Insolence

I'm at school now but I'll test that when I get home, thanks

EDIT-

Excellent! It works, time to get to work.

Edited by Insolence

"I thoroughly disapprove of duels. If a man should challenge me, I would take him kindly and forgivingly by the hand and lead him to a quiet place and kill him." - Mark TwainPatient: "It hurts when I do $var_"Doctor: "Don't do $var_" - Lar.

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  

×