Shoutbox

[Request] Loading DLL - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Messenger Plus! for Live Messenger (/forumdisplay.php?fid=4)
+---- Forum: Scripting (/forumdisplay.php?fid=39)
+----- Thread: [Request] Loading DLL (/showthread.php?tid=74408)

[Request] Loading DLL by S4KurA_^ on 05-15-2007 at 08:00 PM

Hi erveryone,

I'm a new member of this great forum and hope to find nice people :)
Hmm... I can say more about me first, if you would like.
My name is Jérôme, is 20 years old, born and live in Strasbourg (North-East France) and got used to create C/C++ statements for plugin for Messenger Plus! older versions.


I would like to extend the limited functions provided by JScript in adding an external library (.dll) to provide new powerful features.
But when calling Interop.Call(), the debugging window tell me that an unknown error has occured. :(

Here is a part of the C/C++ code in the DLL file :

test.h header file

code:
#ifndef _TEST_H_
#define _TEST_H_

#ifndef _UNICODE
#define _UNICODE
#endif

#define DLLEXPORT __declspec(dllexport)

extern "C++" {

// API test
int __stdcall DLLEXPORT CreateTest(TCHAR* szMessage);


} // end extern C++

#endif



Now, the C++ source file

code:
#include <windows.h>
#include "test.h"


extern "C++" {


// API test
int __stdcall DLLEXPORT CreateTest(TCHAR* szMessage) {


    MessageBox(NULL, ":)", ":)", 0);
    MessageBox(NULL, szMessage, TEXT(";)"), MB_ICONHAND | MB_OK);
    return 1;
}


} // end extern C++



And a part of my script file :

code:
Interop.Call("xmsn32.dll", "CreateTest", Message);
Debug.Trace("Test created - " + Message);
FreeDll("xmsn32.dll");



I've a copy/paste the dll file into Windows system directory and know that the script has found and load it.
But an unkown error occured when calling Interop.Call()...

Has someone an idea ?
I thank you all in advance for your help

Cheers,
S4KurA_^

PS : Sorry for by english, but I try to do my best :P
RE: [Request] Loading DLL by S4KurA_^ on 05-15-2007 at 08:25 PM

Hmmm have found the solution : the function is exported by Dev-C++ with an other name that specified... then Interop.Call() can't find the function within the DLL.

:)


RE: [Request] Loading DLL by Patchou on 05-15-2007 at 10:55 PM

that's because of the "extern C++" directive. Replace that by "extern C" when declaring the function and its name should not be decorated.


RE: [Request] Loading DLL by S4KurA_^ on 05-16-2007 at 07:41 AM


Hi Patchou,

I already know that yesterday :)
Problem solved.

Thanks for your answer


Cheers,
S4KurA_^