Shoutbox

Trouble creating a DLL that works in Plus - 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: Trouble creating a DLL that works in Plus (/showthread.php?tid=86617)

Trouble creating a DLL that works in Plus by a0369 on 10-12-2008 at 08:18 PM

I've spent quite some time trying to get a DLL file to work by using the Interop.Call function, but it just won't accept it.

Here's what I have so far.

c code:
#include "stdafx.h"

#ifdef __cplusplus    // If used by C++ code,
extern "C" {          // we need to export the C interface
#endif

__declspec(dllexport) int __stdcall GetScreenSize(int avar)
{
    //some code here
    return 1;
}

#ifdef __cplusplus
}
#endif

I just want to get the dll to work so I can use it, but messenger plus will not call the function.
RE: Trouble creating a DLL that works in Plus by felipEx on 10-12-2008 at 11:13 PM

quote:
Originally posted by a0369
c code:
__declspec(dllexport) int __stdcall GetScreenSize(int avar)

I had to use:
c code:
__declspec(dllexport) int GetScreenSize(int avar)

jscript code:
    Debug.Trace(Interop.Call(MsgPlus.ScriptFilesPath + "\\test.dll", "GetScreenSize", 16 /* or any value*/ ))
    Interop.FreeDll(MsgPlus.ScriptFilesPath + "\\test.dll")


btw, what are you trying to do? :p
RE: Trouble creating a DLL that works in Plus by a0369 on 10-12-2008 at 11:22 PM

find the screen resolution, if I can just get the function to be able to be called, I should be good to go from there. I tried taking out the __stdcall, but it still can't be called


RE: Trouble creating a DLL that works in Plus by felipEx on 10-12-2008 at 11:40 PM

Well, you don't need a special DLL to achieve this. :D

jscript code:
var rc = Interop.Allocate(16);
Interop.Call("user32", "GetWindowRect", Interop.Call("user32", "GetDesktopWindow"), rc);
Debug.Trace("screen resolution: " + rc.ReadDWORD(8) + 'x' + rc.ReadDWORD(12))

rc.Size = 0;
I know theres another way, i'll post it later...

just open up the Script Debugging window and you'll see something like this:
quote:
Script is starting
Script is now loaded and ready
Function called: OnEvent_Initialize
screen resolution: 1280x1024

if you still want to create that DLL, just have a read at this article at msdn ;)
RE: Trouble creating a DLL that works in Plus by a0369 on 10-13-2008 at 01:22 AM

thanks for the screen resolution code, if I ever need to create a DLL, I'll try following what that tutorial says.


RE: RE: Trouble creating a DLL that works in Plus by davidpolitis on 10-13-2008 at 10:18 AM

quote:
Originally posted by felipEx
I know theres another way, i'll post it later...
jscript code:
Interop.Call("User32", "SystemParametersInfoW", SPI_GETWORKAREA, 0, rc, 0);

RE: Trouble creating a DLL that works in Plus by Mnjul on 10-13-2008 at 11:24 AM

quote:
Originally posted by felipEx
quote:
Originally posted by a0369
c code:
__declspec(dllexport) int __stdcall GetScreenSize(int avar)

I had to use:
c code:
__declspec(dllexport) int GetScreenSize(int avar)

:-/ the documentation says you must use __stdcall calling convention.

quote:
FunctionName
[string] Name of the function as specified in the export table of the library. The function must use the __stdcall calling convention. See Remarks.


RE: Trouble creating a DLL that works in Plus by a0369 on 10-13-2008 at 04:52 PM

i know the documentation says you need to use the __stdcall, but it still doesn't accept, is there something that needs to be changed? I'm using Visual Studio 2005 btw