Function dll C# in scripts ( Msg+ ) |
Author: |
Message: |
melliott
New Member
Posts: 1
Joined: Mar 2008
|
O.P. Function dll C# in scripts ( Msg+ )
Hi,
I have problem. How can I use function dll written in C# to writting scripts ( to Msg+ ) in JS?
Namespace dll:
testdll
Class:
connect
Function:
polacz
|
|
03-02-2008 01:40 PM |
|
|
Spunky
Former Super Mod
Posts: 3658 Reputation: 61
36 / /
Joined: Aug 2006
|
RE: Function dll C# in scripts ( Msg+ )
You want to take a look at Interop.Call:
quote: The Interop::Call function allows scripts to call functions located in external libraries. For example, it can be used to call functions from the Windows API.
code: [number] Interop.Call(
[string] DllName,
[string] FunctionName,
[var, optional] Param1,
[var, optional] Param2,
[var, optional] Param3,
[var, optional] Param4,
[var, optional] Param5,
[var, optional] Param6,
[var, optional] Param7,
[var, optional] Param8,
[var, optional] Param9,
[var, optional] Param10,
[var, optional] Param11,
[var, optional] Param12
);
The return value is whatever the function returns. Example:
code: var value = Interop.Call("User32","EnableWindow", hWnd, false);
<Eljay> "Problems encountered: shit blew up"
|
|
03-02-2008 05:43 PM |
|
|
ShawnZ
Veteran Member
Posts: 3146 Reputation: 43
32 / /
Joined: Jan 2003
|
RE: Function dll C# in scripts ( Msg+ )
quote: Originally posted by SpunkyLoveMuff
You want to take a look at Interop.Call:
no, he doesn't.
Spoiler: the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
|
|
03-02-2008 07:43 PM |
|
|
roflmao456
Skinning Contest Winner
Posts: 955 Reputation: 24
30 / /
Joined: Nov 2006
Status: Away
|
RE: Function dll C# in scripts ( Msg+ )
isn't it Interop.Call2 ?
quote: The Interop::Call2 function allows scripts to call functions located in custom made external libraries and return a string. It acts exactly like Call except that it expects a BSTR as return value.
This post was edited on 03-02-2008 at 10:39 PM by roflmao456.
[quote]
Ultimatess6: What a noob mod
|
|
03-02-2008 10:38 PM |
|
|
deAd
Scripting Contest Winner
Posts: 1060 Reputation: 28
– / /
Joined: Jan 2006
|
RE: Function dll C# in scripts ( Msg+ )
Interop::Call can also call from custom libraries, the only difference is that Interop::Call2 returns a string.
Melliott, you will need to make sure the function you want to call is exported from the dll. Then just put the path of the library, name of the export, and the parameters you want into Interop::Call or Interop::Call2 (depending on if the function returns a string or not).
EDIT: From a quick google search, it looks like you cannot export with C# (I may be wrong, I do not use C#) but you can create a library which can be registered to use with COM.
This post was edited on 03-02-2008 at 10:58 PM by deAd.
|
|
03-02-2008 10:48 PM |
|
|
ShawnZ
Veteran Member
Posts: 3146 Reputation: 43
32 / /
Joined: Jan 2003
|
RE: Function dll C# in scripts ( Msg+ )
quote: Originally posted by roflmao456
isn't it Interop.Call2 ?
no, because neither of them work on .NET libraries. besides, call and call2 do the same thing, except call2 is for functions that return a string.
Spoiler: the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
|
|
03-02-2008 10:53 PM |
|
|
vikke
Senior Member
Posts: 900 Reputation: 28
31 / /
Joined: May 2006
|
RE: Function dll C# in scripts ( Msg+ )
C# is dotNet, which means that the executable-format is way different. It doesn't have anything such as exports, so you cannot use any Interop method to call it. DotNet is managed code, so you there's not a chance you can call it just like it would be native, but of course, there are workarounds. They're dirty, bad and they're called COM.
Oh, and they don't work well on Vista.
|
|
03-02-2008 11:40 PM |
|
|
|