Shoutbox

newbie wants to call C++ program - 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: newbie wants to call C++ program (/showthread.php?tid=77074)

newbie wants to call C++ program by Hen on 08-28-2007 at 10:08 PM

Hi all,
I just read about this messenger scripting option few days ago, and its very freidnly programming.
1) Can I combine in my script, C++  / VB programs?
If a certain event happens, I want to send event parameters to a C++ program.

2) Do you know a way to send data to the serial port? (Js / C++ / C / VB )
Same as before:
On_certain_event(parameter_X) => send_Serial_port(parameter_X)

Thanks!

Hen.


RE: newbie wants to call C++ program by MeEtc on 08-28-2007 at 10:13 PM

you can make a C++ program, then compile it as a .dll file. The scripting environment can then call functions in the .dll file by way of the Interop.Call() function, as documented in the scripting documentation.


RE: RE: newbie wants to call C++ program by Hen on 08-29-2007 at 12:32 PM

quote:
Originally posted by MeEtc
as documented in the scripting documentation.


You mean something like this?
(1)
<OleFiles>   
    <FileName>C++_function.dll</FileName>
</OleFiles>

If this is it, what's the difference, and when to use:
<OleFiles> OR <DotNetFiles> ?

(2) I saw in one of the threads back in 2006, that if I want to register a dll file I need to write in the Initialization:
var sDll = new ActiveXObject('Project_Name.Class_name');

and what do they mean by "initialize"?
i.e ?
function OnEvent_Initialize(MessengerStart)
{
var sDll = new ActiveXObject('Project_Name.Class_name');
}

(3) calling the function:
sDll.function(parameters);

(4)
So what do I need to do? (1) + (3) ? or (1) + (2) + (3) ?

(5)
Now I guess I can handle the serial port with C++, but just for general knowledge, is there a way to handle it also with Js?
(Guess its harder, 'cause Js is more for web development unlike C++...)

Thanks!
quote:
Originally posted by MeEtc
can then call functions in the .dll file by way of the Interop.Call()


...oops didnt notice that one before.

OK, so I can call the function.
(So why back in 2006, they posted you should call a function using " sDll.function(parameters); " ?)
But regarding my previouse reply - I register it by (1) or (2) or someother way?, or if I just save it in the script library as .dll it will recognize it?

Thanks!
RE: newbie wants to call C++ program by matty on 08-29-2007 at 12:48 PM

C++ Dlls do not need to be registered and they have their functions Exported so you can simply call it like so.

code:
Interop.Call('dllname.dll', 'FunctionName', <params>);

The OleFiles is for Dlls that need to be registered before they can be used. For instance you need to register a Visual Basic DLL before  you can use it as an ActiveXObject.
RE: RE: newbie wants to call C++ program by Hen on 08-29-2007 at 12:59 PM

quote:
Originally posted by matty
you need to register a Visual Basic DLL before  you can use it as an ActiveXObject.


OK, cool. Now I can work with C++.
In case I need VB I understand I need to register using "OleFiles".
How do I register? using the next? :
<OleFiles>
<FileName>C++_function.dll</FileName>
</OleFiles>
Do I need also to write:
var sDll = new ActiveXObject('Project_Name.Class_name');

And how do I call it - using "sDll.function(parameters); " or just like for C++ : " Interop.Call('dllname.dll', 'FunctionName', <params>); " ?

Thanks!
RE: newbie wants to call C++ program by matty on 08-29-2007 at 01:03 PM

Visual Basic does not export the DLLs when you compile it. You need to create an ActiveXObject for it.

code:
var MyActiveXObj = new ActiveXObject('ProjectName.ClassName');

MyActiveXObj.MyFunction('hi', 'we', 'are', 'params);

matty's reply to [Resolved] Talking to VB.
RE: RE: newbie wants to call C++ program by Hen on 08-29-2007 at 01:05 PM

quote:
Originally posted by matty
Visual Basic does not export the DLLs when you compile it. You need to create an ActiveXObject for it.

code:
var MyActiveXObj = new ActiveXObject('ProjectName.ClassName');

MyActiveXObj.MyFunction('hi', 'we', 'are', 'params);



You were quicker than me in 10seconds... :-)
I just updated my reply....

By the way, what's excatly the difference between <OleFiles> and <DotNetFiles> ?

Thanks!


RE: newbie wants to call C++ program by matty on 08-29-2007 at 01:06 PM

quote:
Originally posted by Hen
You were quicker than me in 10seconds... :-)
I just updated my reply....

By the way, what's excatly the difference between <OleFiles> and <DotNetFiles> ?

Thanks!
OleFiles are Visual Basic (requiring regsvr32 for registering) and DotNetFiles are Visual Basic.Net and C#.Net (requiring regasm for registering)
RE: RE: newbie wants to call C++ program by Hen on 08-29-2007 at 01:19 PM

quote:
OleFiles are Visual Basic (requiring regsvr32 for registering) and DotNetFiles are Visual Basic.Net and C#.Net (requiring regasm for registering)


On the basis of .net_file = <DotNetFile> should have called it <VBFile> .... ;-)

Didnt see that at first... just didnt pop into my mind. <DotNetFile> much more logic name... :-)

Thanks!
RE: newbie wants to call C++ program by matty on 08-29-2007 at 01:48 PM

OLE stands for Object Linking and Embedding. It makes perfect sense but that is neither here nor there. Glad you made sense of it all now.


RE: RE: newbie wants to call C++ program by Hen on 08-29-2007 at 01:56 PM

quote:
Originally posted by matty
OLE stands for Object Linking and Embedding. It makes perfect sense but that is neither here nor there. Glad you made sense of it all now.



I guessed there was some acronym here which I didnt know... It was a joke... :-)

But yes, you explained well. Thank you.