What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » My Own C++ dll

My Own C++ dll
Author: Message:
TheSte
Junior Member
**

Who's he? xD

Posts: 18
30 / Male / Flag
Joined: Nov 2008
O.P. My Own C++ dll
Hi all...I know there are a lot of similar threads but I haven't understood this yet...

This is the code in dllmain.cpp

code:
#include "stdafx.h"
extern "C"__declspec(dllexport) int somma(int a, int b);
BOOL APIENTRY DllMain( HMODULE hModule,
                       DWORD  ul_reason_for_call,
                       LPVOID lpReserved
                     )
{
    switch (ul_reason_for_call)
    {
    case DLL_PROCESS_ATTACH:
    case DLL_THREAD_ATTACH:
    case DLL_THREAD_DETACH:
    case DLL_PROCESS_DETACH:
        break;
    }
    return TRUE;
}

int somma(int a, int b){

    return a + b;

}

the building is ok...but when I load it with plus it says:

"Bad calling convention detected for "somma" in "C:\Program Files\Messenger Plus! Live\Scripts\nomi\dll.dll". The function must be declared with __stdcall and called with the appropriate number of parameter."

How I can declare it with __stdcall ?




sorry this is the js code

code:
function OnEvent_Initialize(MessengerStart)
{
var s=0;

s= Interop.Call(MsgPlus.ScriptFilesPath + "\\dll.dll", "somma", "2","3");
MsgPlus.DisplayToast("sss", s);
Interop.FreeDll(MsgPlus.ScriptFilesPath + "\\dll.dll");
}
05-04-2009 05:49 PM
Profile E-Mail PM Find Quote Report
mezzanine
Full Member
***

Avatar

Posts: 106
Reputation: 23
– / – / Flag
Joined: May 2005
Status: Away
RE: My Own C++ dll
code:
extern "C" __declspec(dllexport) int __stdcall somma(int a, int b) {
    return a + b;
}

05-04-2009 06:04 PM
Profile PM Web Find Quote Report
TheSte
Junior Member
**

Who's he? xD

Posts: 18
30 / Male / Flag
Joined: Nov 2008
O.P. RE: My Own C++ dll
Thank u :)

But now t says that it fails the collocation of the function "somma"...O.o


edit: mmm..it seems to not find the somma function....the name is correct..so why?


SOLVED

With the help of http://www.dependencywalker.com/ I've found the real name of funvtion that was _somma@8

This post was edited on 05-05-2009 at 08:46 PM by TheSte.
05-04-2009 06:31 PM
Profile E-Mail PM Find Quote Report
TheSteve
Full Member
***

Avatar
The Man from Japan

Posts: 179
Reputation: 23
39 / Male / Flag
Joined: Aug 2005
RE: My Own C++ dll
If you remove the __declspec(dllexport) then use a .def file, the name will remain in a readable format.
05-07-2009 01:11 AM
Profile PM Web Find Quote Report
TheSte
Junior Member
**

Who's he? xD

Posts: 18
30 / Male / Flag
Joined: Nov 2008
O.P. RE: My Own C++ dll
how can I create a .def?
05-10-2009 02:07 PM
Profile E-Mail PM Find Quote Report
segosa
Community's Choice
*****


Posts: 1407
Reputation: 92
Joined: Feb 2003
RE: My Own C++ dll
...

Project -> Add New -> .def
The previous sentence is false. The following sentence is true.
05-10-2009 08:05 PM
Profile PM Find Quote Report
TheSteve
Full Member
***

Avatar
The Man from Japan

Posts: 179
Reputation: 23
39 / Male / Flag
Joined: Aug 2005
RE: My Own C++ dll
Right. For VC6, you just create a new text file and save it as <projectname>.def

The contents of the file can look something like this:
code:
LIBRARY "My Library"
EXPORTS
    ; Explicit Exports go here
    MyFunction

This post was edited on 05-11-2009 at 05:18 AM by TheSteve.
05-11-2009 05:16 AM
Profile PM Web Find Quote Report
TheSte
Junior Member
**

Who's he? xD

Posts: 18
30 / Male / Flag
Joined: Nov 2008
O.P. RE: My Own C++ dll
ok thanks a lot ; )
05-11-2009 12:19 PM
Profile E-Mail PM Find Quote Report
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On