Jump to content

Trying to create a DLL


Insolence
 Share

Recommended Posts

[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.
Link to comment
Share on other sites

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.
Link to comment
Share on other sites

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.
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.
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...