LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Trouble to call ActiveX control

post-9524-126331294154_thumb.jpg

 

 Manufacture provides an ActiveX control to use in LabVIEW. One function "OpenConnection (ServerName: PChar; out Result: OleVariant) requires a Pascal PChar type; when accessed from LabVIEW, it is converted to String type. I tried to wire a normal LabVIEW string, it returned an error saying the ActiveX Server is not installed or registered. I manually registered the server, but it still returns the same error.


I tried to convert the LabVIEW string to a Pascal type, like shown in the picture (put the string length in the beginning and a NULL in the end to make it a null-terminated string), still the same error. My guess is that the problem still lies in the string, it is not compatible with the Pascal type. But how can I convert the string in this case? 
0 Kudos
Message 1 of 6
(3,484 Views)
That error message would have nothing to do with the string. It's telling you it can't instantiate the ActiveX class. When you turn on highlighting which node actually generates the error? If it's an issue with the ActiveX class not being registered, then it would be from the Automation Open.
0 Kudos
Message 2 of 6
(3,475 Views)

Actually, there is no error message from LabVIEW. The error I referred to is the message from manufacture program. 

 

The attached LabVIEW code runs fine until the last step which is trying to close the connection that never established.  The automation open is working well without error. 

0 Kudos
Message 3 of 6
(3,470 Views)

Do the activeX calls return the correct data? It only gives an error at close connection?

 

National Instruments
0 Kudos
Message 4 of 6
(3,441 Views)

The first call to "OpenConnection" returns '-2' (no LabVIEW error), which means 'the ActiveX server' is not installed or registered. Then at closing, it returns a LabVIEW error saying "Catastrophic Failure", which I think is because the connection was never established in the first place. 

 

So I still think it is the LabVIEW string is not compatible with the Pascal string, when I feed the name of the ActiveX server, although it looks to the right name, it is converted to a different pascal string. Then the program cannot find the proper server.

 

I don't think anything can be done from LabVIEW to fix it in this case.  

0 Kudos
Message 5 of 6
(3,435 Views)

Here we go. Problem solved, not by NI, but by the Pascal programmer. I think here is a good lesson for those manufacture programmers who provide driver set. Don't use variable type like Pascal string, because it is different from string type in other language including LabVIEW. Use Variant type instead, it makes everything easier.

 

I don't know if this makes any sense to other people, but that is how it solved our problem. 

0 Kudos
Message 6 of 6
(3,371 Views)