Shoutbox

[question] Calling an external 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: [question] Calling an external DLL (/showthread.php?tid=61350)

[question] Calling an external DLL by deAd on 06-25-2006 at 04:37 PM

How do you call an external dll? I'm really confused. I'm using VB.NET to make the dll, and I'm registering it in the DotNetFiles section of the ScriptInfo.xml. However, each time I've tried to call a function from it, I get "Error: unknown."

I tried giving the DLL Name parameter of Interop.Call a nonexistant filename, and I get the same error with the same parameters as I did, with the same error code. This leads me to believe that Plus! cannot find my dll, however, everything I've tried gives me this same error.

So how can I make this work?


RE: [question] Calling an external DLL by segosa on 06-25-2006 at 04:54 PM

Interop.Call is for win32 dlls, not .NET ones.

I'm not sure what you need to use for .NET DLLs. Probably ActiveXObject().


RE: [question] Calling an external DLL by deAd on 06-25-2006 at 05:27 PM

Ah, I see. I'll try that soon. :)

EDIT: I can't seem to get this to work. :S


RE: [question] Calling an external DLL by BlackSun1102 on 06-25-2006 at 06:21 PM

Hi,

I need to call an .Net Library, too, so I have the same problem...
Does anybody know a solution?

Edit: We can use the Included Com-Interop Services in .Net, but then itīs mindless from the developers of Plus! to differentiate between OLE and .Net Librarys...

Regards Chris


RE: [question] Calling an external DLL by Patchou on 06-25-2006 at 09:41 PM

JScript doesn't support .net objects natively so you have to use COM interop to access them. As long as you have the option checked in your project, you shouldn't see any difference at all :). To instantiate your .NET object, just use new ActiveXObject().


RE: [question] Calling an external DLL by deAd on 06-25-2006 at 10:23 PM

What option? "Make assembly COM-Visible" ? And then we put it in <DotNetFiles> ? Also, how do I call it in ActiveXObject? Just ActiveXObject("MyDLL") ... or do I need something like ActiveXObject("MyDLL.Something-Else-Goes-Here") ?


RE: [question] Calling an external DLL by BlackSun1102 on 06-26-2006 at 03:26 PM

Hi,

Pachou, why you doesnīt add a .Net-Scriptingfeature for Plus! Live?
The Framework offers many Runtime Support...

Using COM Interop in .Net is mindless! The objective of .Net itīs to supersede COM...

Regards Chris


RE: [question] Calling an external DLL by deAd on 06-26-2006 at 08:58 PM

I'm still not catching this. BlackSun, if you got it, can you say something?


RE: [question] Calling an external DLL by BlackSun1102 on 06-27-2006 at 12:07 PM

Hi,

You must use COM Interop attribtes, to "brand" your functions as COM compactible.
Then use the "Call" function to from you JScript to call your function...

If you donīt know about COM Interop, you should read here.

Regards Chris


RE: [question] Calling an external DLL by deAd on 06-27-2006 at 01:34 PM

Well, I can set it as com-visible in the Assembly Information...is that it? Then just put it in DotNetFiles and use Interop.Call?


RE: [question] Calling an external DLL by BlackSun1102 on 06-27-2006 at 04:58 PM

Hi,

quote:
Originally posted by BlackSun1102
You must use COM Interop attribtes, to "brand" your functions as COM compactible.

ComVisible is one of this arributes, here you can find a list of all attributes, with decriptions and examples.

Regards Chris
RE: [question] Calling an external DLL by Griffo on 06-27-2006 at 07:10 PM

I'm having trouble with a DLL call in my script too, however mine was made in VB6.

I made a test DLL with this function:

code:
Public Function Test() As String
Test = "hello"
End Function

...and my script code is:
code:
function OnEvent_Initialize(MessengerStart)
{
Debug.Trace(Interop.Call(MsgPlus.ScriptFilesPath + "\\Project1.dll", "Test"));
}

However, I keep getting this error:
code:
Script is now loaded and ready
Function called: OnEvent_Initialize
Interop.Call failed to locate function "Test"
Error: unknown.
       Line: 4. Code: -2147467259.
Function OnEvent_Initialize returned an error. Code: -2147352567

Any ideas what I am doing wrong? Thanks :)

EDIT: I've tried Interop.Call2 as well, but no luck!
RE: [question] Calling an external DLL by mathieumg on 06-27-2006 at 09:22 PM

Was your dll registered with winsvr32?


RE: [question] Calling an external DLL by cloudhunter on 06-28-2006 at 01:18 AM

Maybe try this?

code:
function OnEvent_Initialize(MessengerStart)
{
Debug.Trace(Interop.Call(MsgPlus.ScriptFilesPath + "\\Project1.dll", "Test()"));
}

As far as I know, doesnt it need the ()?

Cloudy
RE: [question] Calling an external DLL by Griffo on 06-28-2006 at 07:50 AM

cloudhunter: I have tried adding the "()" at th end, still no luck! :(

mathieumg: Tried registering the DLL, but it doesn't make any difference.


RE: [question] Calling an external DLL by Griffo on 06-28-2006 at 10:52 PM

Anyone had any luck with DLL's yet? Still no joy with mine!


RE: [question] Calling an external DLL by Themuzz on 06-29-2006 at 07:52 AM

try:

Interop.Call(MsgPlus.ScriptFilesPath + "\\Project1.dll", "Test", "");

That works fine with me, else the dll is not working....


Greetz Themuzz


RE: [question] Calling an external DLL by Griffo on 06-29-2006 at 08:55 AM

Thanks for the reply!

Still no luck I am affraid, not sure what is going on now.

My DLL code is as follows; anything look suspicious?

CODE:

code:
Public Function Test() As String
Test = "hello"
End Function

RE: [question] Calling an external DLL by craigosaurous on 08-23-2006 at 07:42 AM

Had the same problem with a dll I was using, but managed to get it working by looking the the function names inside the DLL.

It seems as some C++ DLLs have mangled function names, I used dependancy walker to find the correct function names that worked.  You can also see it in wordpad once you know what to look for.

i.e. the Function name
     IdleTrackerInit
Turned into
     ?IdleTrackerInit@@YAHXZ

See if that works for you