LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

How to integrate windows scripting components written in jscript/vbs into Labwindows/LabView?

Hey,

I've a problem that I cannot connect to a .wsc file in Labwindows/Labview.
I've generated a typelibary in windows, I've registered this .wsc file, I'm able to connect to the component over the Internet Explorer or a .wsf (windows scripting host ) file.

I've generated with the help of the ActiveX Controller Wizard an .fp file without any problems.

But I'm not able to call the NewAutomation function, or any other function. This always crash with the return code 0x80004002 "interface not accesible", because it tries to open the Automation Server and not the IUnknown Interface. When I replace the automation IID in the Iunknown IID it works. But that is not possible from
LabView, only in Labwindos. And it is not the way I want it to do.

I've tried it under Windows 2000 and Windows NT.
I've installed all runtimes from microsoft.

I hope someone as an idea.

Thanks,

chris
0 Kudos
Message 1 of 3
(3,971 Views)
Do you want to use the wsc object in LabVIEW or CVI? It sounds like you want to use it in LabVIEW so let me know if this is not the case.
The crash may be because you are trying to use an ActiveX Control as you would an ActiveX Server. Please see the following links and example programs and let me know if this helps.


How Does ActiveX Server Automation Differ from ActiveX Controls?
http://digital.ni.com/public.nsf/websearch/53BAD0DF6128E846862568E7006E2DF7?OpenDocument

Receiving Error -2147418113 "Catastrophic failure in xxx.vi" When Using ActiveX Server
http://digital.ni.com/public.nsf/websearch/E0FA5D83F1E5276B86256C7E005FD83C?OpenDocument

Look at these examples to see how to use WSC (Windows Script Components) COM objects in LabVIEW:


Running
an Executable from LabVIEW Using the Windows Scripting Host (WSH)
http://venus.ni.com/stage/we/niepd_web_display.DISPLAY_EPD4?p_guid=B123AE0CBA9A111EE034080020E74861&p_node=DZ53002&p_submitted=N&p_rank=&p_answer=&p_source=Internal

Creating Windows Shortcuts Using LabVIEW and the Windows Scripting Host COM Object
http://venus.ni.com/stage/we/niepd_web_display.DISPLAY_EPD4?p_guid=B45EACE3DF8856A4E034080020E74861&p_node=DZ53002&p_submitted=N&p_rank=&p_answer=&p_source=Internal

Generating an Event in LabVIEW Programmatically
http://venus.ni.com/stage/we/niepd_web_display.DISPLAY_EPD4?p_guid=B123AE0CBC98111EE034080020E74861&p_node=dz52023_us&p_submitted=N&p_rank=&p_answer=&p_source=Internal
0 Kudos
Message 2 of 3
(3,971 Views)
Hey C.Hahn,

first thanks for your answer!

I want to use the .wsc component as an ActiveX Server.
For Example, I can access this component from a .wsf
windows scripting host or from IE with a call
in JScript like:

myComponent = new ActiveXObject("MyComponent.wsc");

I can also access this .wsc also from VB or VC++.

Even from Labwindows/CVI 5.5 I can access this component by a call like:

const IID IID_IUnknown = {0x00000000,0x0000,0x0000,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46};
const IID IID_IDispatch = {0x00020400,0x0000,0x0000,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46};

{
error = CA_CreateObjectByProgIdEx ("MyComponent.wsc", NULL, &IID_IUnknown, 1, LOCALE_NEUTRAL, 0, &handle);
error = CA_MethodInvokeEx (handle, NULL, &IID_IDispatch, 1, CAVT_VARIANT, &result, 1, intPoi, 1);
}

When I now use the ActiveX Control Wizard in Labwindows/CVI 5.5 to
create a .fp file from the .tlb file, wich was generated by microsoft for
this .wsc component, the wizard generated all needed files. Without any errors.

But when I try this:
error = ScriptletTypeLib_NewAutomation (NULL, 1, LOCALE_NEUTRAL, 0, &handle);
it crashes. The error code indicates that the interface is not supported.

As I looked through the code, generated by the wizard, I found, that the wizard
does not use the same IID like I use in the example above. It generated registry entries,
which are pointing to the same olexxx.dll, as the IDISPATCH interface but it does not work.

It is easy to understand that my example is not very practicable.
You have no function names, just the function numbers. Not very nice for other
programmers.

The other problem is, that some programmers want to use this component
in LabView. But as you can think of, they have the same problems to
access this component, like I have it with the ActiveX Control Wizard.

For us the last possibility is to write a .dll in Labwindows, so LabView
programmers have access to the Component functions.

But I think there must be an easier way to integrate this .wsc functions.

Do you have an idea?
0 Kudos
Message 3 of 3
(3,971 Views)