Jump to content
E1M1

Need help with calling my DLL

Recommended Posts

E1M1

Hello. I am trying to call 64 bit dll from 64 bit autoit, but I get @error = 3.

My autoit code:

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_UseUpx=n
#AutoIt3Wrapper_UseX64=y
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
DllCall("test.dll", "int", "MyMessageBoxW", _
        "hwnd", 0, _ ; Handle to the parent window
        "wstr", "Some text", _ ; The text of the message box
        "wstr", "Some title", _ ; The title of the message box
        "int", 0) ; Flags for the message box.

MsgBox(0,0,@error)

 

And my C++ code:

#undef UNICODE
#include <windows.h>
#include <cstdio>

INT APIENTRY DllMain(HMODULE hDLL, DWORD Reason, LPVOID Reserved)
{
    switch(Reason)
    {
    case DLL_PROCESS_ATTACH:
        MessageBox(0,"","Loaded",0);
        break;
    case DLL_PROCESS_DETACH:
    case DLL_THREAD_ATTACH:
    case DLL_THREAD_DETACH:
        break;
    }
    return TRUE;
}

int  WINAPI MyMessageBoxW(HWND hWnd, LPCWSTR lpText, LPCWSTR lpCaption, UINT uiType)
{
    int retValue = MessageBoxW(hWnd, lpText, lpCaption, uiType); 
    return retValue; 
}

The message box that says "Loaded" pops up so the problem cant be in loading dll.


edited

Share this post


Link to post
Share on other sites
MilesAhead

What happens if you comment out the "loaded" messagebox?

Share this post


Link to post
Share on other sites
E1M1

Would it change anything? If I remeber correctly, nothing happens.


edited

Share this post


Link to post
Share on other sites
jchd

This is C++ code, not C. C++ function names are mangled, which make them unrecognizable (mostly). Enclose the source in:

#ifdef __cplusplus
extern "C" {
#endif

// here your source code

#ifdef __cplusplus
}
#endif

 


This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

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

×