Call LabVIEW Virtual Instrument through ActiveX Server from C/C++

I am trying to access a VI by C/C++ almost identical to the reference example that can be found on this site for Visual Basic. However, somehow, I am unable to succeed to use the ActiveX Call() function. The program always crashes, whatever I try. Because the Visual Basic version works without any problems, I hope someone can point me the error in the code.
Thanks!
#include "stdafx.h"
#import "LabVIEW.tlb"
#define VIPATH "D:\\Program Files\\National Instruments\\LabVIEW 7.0\\examples\\apps\\freqresp.llb\\Frequency Response.vi"
using namespace LabVIEW;
int _tmain(int argc, _TCHAR* argv[])
// Initialization
HRESULT he = NULL;
he = CoInitialize(NULL);
// Create instance of
labview application engine
_ApplicationPtr pLV;
he = pLV.CreateInstance("LabVIEW.Application");
// Create instance of virtual instrument
VirtualInstrumentPtr pVI;
he = pVI.CreateInstance("LabVIEW.VirtualInstrument"); /* ?not? mandatory */
// Get reference to a VI at location VIPATH
_bstr_t viPath(VIPATH);
_bstr_t password("");
VARIANT_BOOL resvForCall = FALSE;
long options = 0;
pVI = pLV->GetVIReference(viPath,password,resvForCall,options);
// Show front panel
pVI->FPWinOpen = TRUE;
// Call the referenced VI as subVI
_variant_t paramNames[5] = {"Amplitude", "Number of Steps", "Low Frequency", "High Frequency", "Response Graph"};
_variant_t paramVals[5] = {}; /* VT_EMPTY */
/* Fill ParamVals with values from VI */
for (int i = 0; i < 5; ++i) paramVals[i] = pVI->GetControlValue(paramNames[i].bstrVal);
/* Call VI -> !!! CRASH !!! :-( */
pVI->Call(paramNames,paramVals);
// Release references and close application
pLV->AutomaticC
lose = TRUE;
pVI.Release();
pLV.Release();
CoUninitialize();
return 0;

This may not be the easiest way. Although i have not used _variant_t. But it seems like your VARIANT type is VT_EMPTY for everything. You need to build up an array of variants with correct type, that matches the type of control you are assigning data to like VT_INT for int numeric, VT_BSTR for string control etc
VARIANT paramNamesVarArg, paramValuesVarArg;
SAFEARRAY *paramNames, *paramValues;
::VariantInit(&paramNamesVarArg);
paramNamesVarArg.vt = VT_ARRAY | VT_BYREF | VT_BSTR;
// create safearray of strings
SAFEARRAYBOUND rgsabound[1];
rgsabound[0].lLbound = 0;
rgsabound[0].cElements = 1;
paramNames = SafeArrayCreate(VT_BSTR, 1, rgsabound);
paramNamesVarArg.pparray = &paramNames;
long index = 0;
_bstr_t paramName = "Numeric";
BSTR *bstrVal;
retVal = SafeArrayPtrOfIndex(paramNames, &index, (void **)&bstrVal);
*bstrVal = paramName.copy();
//do the same method for paramValuesVarArg
::VariantInit(&paramValuesVarArg);
paramValuesVarArg.vt = VT_ARRAY | VT_BYREF | VT_I4;
rgsabound[0].lLbound = 0;
rgsabound[0].cElements = 1;
paramValues = SafeArrayCreate(VT_VARIANT, 1, rgsabound);
paramValuesVarArg.pparray = &paramValues;
VARIANT *dispVarVal;
VARIANT tempVar;
tempVar.vt = VT_I4;
retVal = SafeArrayPtrOfIndex(paramValues, &index, (void **)&dispVarVal);
*dispVarVal = tempVar;
viPtr->Call(&paramNamesVarArg, &paramValuesVarArg);
Hope it helps.
A Rafiq

Similar Messages

  • Looking for a labview virtual instrument program we can modify

    Hi, I’m looking for a canned labview virtual instrument program we can modify for the OMB DAQ 55 from Omega to measure three temps and control three DO.  I have the driver at:ftp://ftp.omega.com/public/DASGroup/products/OMB-DAQ5455&56/ The driver is labviewpdaq5xsetup.exe. I have the OMB DAQ 55 from http://www.omega.com/pptst/OMB-Daq55.html  with a USB interface. I am trying to set it up to control a 24V electric valve. I’d like it to measure temperatures (5 separate temps), allow a set point to be programmed for three of them and turn on and off a DO based on the temperature. PID is not required yet. Maybe in the future… We have labview 7.1 and 8.0 but my colleague prefers 7.1  Do you have an labview VI programs that you can share that will do this with the DAQ 55? If you have something that will be close, we can modify it. But starting from scratch will likely mean we can not get this done in time for a project test. Simple set point and control is all I’m looking for… I’m new (my colleague knows it better than me, but has less time) to labview and do not have the resources to learn it from scratch to figure this out. Is there something you have I could modify? Can you help. Or are there canned programs you have that will do this? Labview is the preferred language. Thanks. Attached is what Omega shared with us, it might help…it’s a screen capture from a similar program, but far from the mark.

    Hi vestel,
    These discussion forums are more geared for questions - not necessarily having everyone else code for you.
    You have a few options if you want code.
    1) Look at the shipping examples that come with LabVIEW.  This will give you a starting point from which to ask questions.
    2) Look at the Instrument Driver Network that exits on National Instrument's Web site.  Here are all the Omega instrument drivers listed.
    3) Look at the list of Alliance members who you can pay to develop your code for you.  Look here.
    I hope this helps,
    Kevin S.
    Applications Engineer
    National Instruments

  • Calling LabView ActiveX Server from TCL?

    Does anyone have experience calling a LabView ActiveX server vi from
    TCL? I created a simple VI with one control (labeled "A") and one
    indicator (labeled "B") and a +1 adder between them. I can load and
    open the VI from TCL:
    package require tcom
    set lv [::tcom::ref createobject "LabView.Application"]
    set viPath "D:\\National Instruments\\LabView\\Activity\\a.vi"
    set vi [$lv GetVIReference $viPath]
    $vi FPWinOpen True
    But when I try to send in data:
    $vi -namedarg Call A 1
    I get the error message "unknown parameter A".
    I have also attempted to duplicate the "ActiveX Server" example
    from the LabView help file, calling "Frequency Response.vi". This
    approach encounters the same error message:
    % package require t
    com
    3.0
    % set lv [::tcom::ref createobject "LabView.Application"]
    ::tcom::handle0x013202F4
    % set viPath "D:\\National
    Instruments\\LabView\\examples\\apps\\freqresp.llb\\frequency
    Response.vi"
    D:\National Instruments\LabView\examples\apps\freqresp.llb\frequency
    Response.vi
    % set vi [$lv GetVIReference $viPath]
    ::tcom::handle0x01335AE8
    % $vi FPWinOpen True
    % $vi -namedarg Call Amplitude 10
    unknown parameter Amplitude
    If anyone can point me in the right direction, or give me an
    example of how to do this I would greatly appreciate it.
    TIA.
    Leslie

    In article ,
    Leslie Brooks wrote:
    >"Bruce Hartweg" wrote in message
    >news:...
    >> "Chin Huang" wrote in message
    >news:[email protected]...
    >> >
    >> > I don't use LabView, but from the Visual Basic example I saw, it seems
    >> > the Call method takes two arguments. The first is an array of parameter
    >> > names and the second is an array of parameter values. Try to send in
    >> > data with the Tcl command
    >> >
    >> > $vi Call [list A] [list 1]
    >>
    >> I'm unable to help the original question (don't know LAbView or VB stuff) but
    >> just want to point out that [list A] is equal to A and [list 1] is the
    >same as 1.
    >>
    >> Bruce
    >
    > I know what is supposed to be passed to the 'Call' method. Doing
    >this:
    >
    >set inst [::tcom::info interface $vi]
    >$inst methods
    >
    > produces (among other things):
    >
    >{1015 VOID Call {{{in out} {VARIANT *} paramNames} {{in out} {VARIANT
    >*} paramVals}}}
    >
    > So the 'Call' method is expecting two parameters, both pointers
    >to variants. TCOM appears to be passing the correct parameter type
    >because the TCOM documentation says that a TCL List maps to a
    >one-dimensional array of VT_VARIANT. However, the results are
    >INvariant (bad pun intended):
    >
    >% $vi -namedarg Call Amplitude 10
    >unknown parameter Amplitude
    >% $vi -namedarg Call [list Amplitude] [list 10]
    >unknown parameter Amplitude
    >% $vi -namedarg Call [list Amplitude] [list [::tcom::na]]
    >unknown parameter Amplitude
    >% set i 5
    >5
    >% $vi -namedarg Call [list Amplitude] {incr i}
    >unknown parameter Amplitude
    >% $vi -namedarg Call [list Amplitude] [list [incr i]]
    >unknown parameter Amplitude
    >% $vi -namedarg Call Amplitude [incr i]
    >unknown parameter Amplitude
    >
    > Who can help me with this? Who is the LabView Guru?
    Try invoking the Call method without the -namedarg option. The
    -namedarg option doesn't work the way you seem to think it works. The
    -namedarg option provides a way to specify arguments named from the
    method's parameter specification. For example, you discovered that the
    Call method take two parameters named "paramNames" and "paramVals".
    Tcom returns the error "unknown parameter Amplitude" because "Amplitude"
    doesn't match either parameter name.

  • Making the URL of an HTTP data service call the same domain it is served from

    Hi All,
    I've got an HTTP service I defined in Flash Builder, via the "Data Services" tab.  I've got an absolute URL in there right now.  Here's what it looks like:
    What I really want is to not define a path that includes a domain name at all--I want the service to simply call an absolute path that's on the same domain as whatever domain the SWF was served from... can I do that?  When I got rid of the base URL and then gave an absolute URL path (e.g., /roster/deleteMember), Flex Builder complained that "File does not exist."  Well, of course it doesn't exist, it isn't a file, it's a URL to a service call--there is no corresponding file on the filesystem.
    Can anyone advise me how to do that?  Changing the domain name has at least once caused me a great deal of trouble, and the only workaround I was able to figure out was to create a whole new project and copy/paste all the code from my previous project into that new project, and recreate the data service definitions.  Big headache!

    mmh,
    from the adobe documentation:
    The configuration files sometimes contain special {server.name} and {server.port} tokens. These tokens are replaced with server name and port values based on the URL from which the SWF file is served when it is accessed through a web browser from a web server. Similarly, a special {context.root} token is replaced with the actual context root of a web application.
    Whenever is a RemoteService, HttpService or WebService... if you specify the endpoint as http://{server.name}:{server.port}/{context.root}
    automatically on runtime, the variables are set by the flashplayer depending on where you've been downloaded the application. So, if the webservices are deployed on the same server where the flex application is downloaded, this is the solution.
    But in your case,  maybe you cannot do that through the plugin you are using for declaring your services, but have to programmatically solve it.
    Bye,
    Lionel

  • Webservice call to XI Interface through SOAP Adapter from a Web application

    I  am getting  the following error, when I try to call the XI Interface using soap adapter from a web application.
    ERROR  :
    SystemError:
              <context>XIAdapter</context>
              <code>ADAPTER.JAVA_EXCEPTION</code>
              <text><![CDATA[
    com.sap.aii.af.ra.ms.api.DeliveryException: XIAdapterFramework:GENERAL:com.sap.aii.af.ra.ms.api.DeliveryException
    at some time i am getting the following error.
    faultCode: HTTP
    faultSubcode:
    faultString: (500)Internal Server Error
    faultActor:
    faultNode:
    faultDetail:
         {}:return code:  500
    &lt;SAP:Error&gt;&lt;SAP:Category&gt;XIServer&lt;/SAP:Category&gt;&lt;SAP:Code&gt;RCVR_DETERMINATION.NO_RECEIVER_CASE_BE&lt;/SAP:Code&gt;&lt;SAP:Stack&gt;No receiver could be determined&lt;/SAP:Stack&gt;&lt;/SAP:Error&gt;
         HttpErrorCode:500
    (500)Internal Server Error
    can any of  one help to resolve this.
    Thanks  in advance

    Ganie
    You are getting the exception at very first point of Pipeline Service i.e Receiver Determination, do compare the namespace, Sender Interface Name & Sender Service name with the payload you are sending from web-application, they must be exactly same.
    The best way to get the test payload is suggested in above reply.

  • Calling an image inside an IXOS server from OTD server

    Hi
    how do u retrieve image stored inside IXOS server from OTD/E1B server using a BSP application.
    Thanks and Regards
    Bhavana Advani

    NO issues anymore

  • Trying to call a method on an RMI server from a GUI

    Hi all, I'm new to the forums and I desperately need some help!
    My question fits into the RMI category but also the database/GUI side so sorry if this is posted in the wrong place.
    My application is a client/server system (programmed in Netbeans 6.8) that also uses GUIs and JDBC-ODBC. Basically, I am trying to call a method that adds an entry to my database from a GUI button.
    Due to the required RMI, I have the ServerInterface that extends Remote and I have a ServerImpl class that implements the Interface, and the RMI works fine so there is no problem there.
    My code for the button is:
    private void addUserActionPerformed(java.awt.event.ActionEvent evt) {                                       
    try{server.addNewUser("new");}
    catch(Exception e){}
    addUser.setText("buttonhaschanged");
    The server variable is declared above as ServerImpl server;
    The actual addNewUser method works fine when it is called explicitly via RMI in my main "Client" class, but this GUI is going to be like an "administrator GUI" that can manipulate the database, so there is no RMI involved here.
    Anyway, my button doesn't have any effect on the database, but the button changes text as desired so the button itself works, but it doesn't do what I want to the database, so I think my problem is the use of my "server" variable. I've tried making it static and I've tried making it of type ServerInterface, but no luck. Would I have to make the GUI class extend the interface too?
    Sorry for rambling on!
    Many thanks in advance
    David
    Edited by: DHD on Feb 26, 2010 6:15 AM

    Would I have to make the GUI class extend the interface too?Your GUI has nothing to do with the RMI. How did you obtaint the "server" ? have you looked in the RMI registry to get the stub object ?
    The second thing to notice is you are invoking a RMI calls on a EDT which you should not do it. Your RMI method calls should be invoked via SwingWorker-->doInBackground(); please take a look at the Java Doc
    [http://java.sun.com/javase/6/docs/api/javax/swing/SwingWorker.html|java Doc SwingWorker sample usage]
    You mentioned that the RMI method invocation works fine from the main class and not from the GUI so what did you do in the main class to get the stub do it in the doInBackground() method
    Regards,
    Alan
    London

  • Calling a remote program on the server from the client

    Hi, I'm new to Java/Jdeveloper/Oracle I'm writing a small app in
    Jdeveloper 3.2 running on Windows that connects to an Oracle
    8.1.6 on a Redhat Linux. I have a few programs writen in C that
    run on the server, and would like to call them from the client
    machine with a few parameters. is there a way of doing that?
    it's just like calling "ls -la filename" from the remote
    client. BTW, I don't need to get a response from the server, I
    just need to initiate the call.
    Thanks for any help.
    John

    JDeveloper is an IDE not a platform. what sort of app are you
    writing: client server application, applet, JSP?
    APC

  • How to call webservices deployed in Oracle edentity server from BPEL .

    my application requires to call a web service which is deployed on the OES server. This web service will accept user name and password as paremeter and rerurn true if the user is a valid user .

    You can try to right click on the EJB in JDeveloper and choose "create test client", then choose the connection you used for deployment and it should create a client for you that can access the EJB.

  • Where can I get an example of how to call Labview.exe (Active X Server) from Visual C++

    I would like to Call Labview application (as Active X Server) from Visual C++. I need any type of exemple on how to do this, any input will be greatly apriciated.

    In the summer there has been an example in the Developer Zone, but i can't find it again. I can send you the attached zipfile from that example. The example is resricted to single threaded applications. In multi threaded applications you must initialise OLE in the thread where you communicate with the active-X server.
    If you need more information contact me at [email protected]
    Waldemar
    Using 7.1.1, 8.5.1, 8.6.1, 2009 on XP and RT
    Don't forget to give Kudos to good answers and/or questions
    Attachments:
    VCandLabVIEW.zip ‏91 KB

  • How do you pass an ActiveX Variant from an external application to LabVIEW?

    Background: I created a LabVIEW ActiveX server. I can access it with my external application (Matlab). I have a control variable in my LabVIEW executable. I want to use Active X to set the value of my control variable from my external application.
    Documentation: The only reference in the documentation for this task is in the Using ActiveX with LabVIEW in the LabVIEW 2009 help. It simply says "Use the variant control and indicator to pass data to or from ActiveX controls." I also went through all the ActiveX examples in the example finder and did not find any vis that passed variables using ActiveX.
    Questions:
    What should my control variable look like in LabVIEW? Should it be a refnum, a variant, or a data type? Does it have to be wired to a vi connector?
    Do I need to do any magic on this variable, such as change its properties?
    How do I pass the value from my external application to the variable in my LabVIEW executable?
    Thank you.

    Hello Lyn,
     The control variable should be a refnum and it would have to be wired to Automation Open with the correct reference.
    Here are some great examples of using ActiveX Server in LabVIEW
    LabVIEW Executable Used as ActiveX Server in LabVIEW
    http://decibel.ni.com/content/docs/DOC-9647
     Calling ActiveX Code from LabVIEW
     http://decibel.ni.com/content/docs/DOC-9073
    Andy Chang
    National Instruments
    LabVIEW Control Design and Simulation

  • LabVIEW application as ActiveX server

    Hello all,
    is there a possibility to detect (within the LabVIEW application), if a LabVIEW application (enabled as ActiveX server) is called through ActiveX or called through shortcuts (desktop, program menu, ...).
    The background is, i want to do different things on startup depending on the kind of call.
    Thanks in advance
    Heinrich Eidloth

    Hello Heinrich,
    sorry, but the only thing I can tell you is, that there is no built in
    mechanism in LabVIEW for detecting how the application was called.
    If it is possible, than it would be somehow through Windows (WinAPI or
    COM?). So the question would be, does Windows provide a way to
    determine how an application was called. I hope you can get help from
    Microsoft with this issue.
    If you get a solution, it would be great if you could post it. This really is an interesting question.
    Good luck.
    D. Ackermann
    Applications Engineer
    National Instruments Germany

  • Passing an ActiveX reference from TestStand to Labview

    How can I pass and ActiveX reference (for a dll) created and used in a TestStand sequence (under Locals) to a VI running within that sequence so that I can then call the same instance of the dll from Labview?
    (I know this isn't the best approach to programming but I'm more interested in proving the point than anything else)
    Cheers
    Dan

    Here's what I think you are tyring to do. Within your sequence, instantiate an object from an ActiveX DLL, storing a reference to it within a TS variable. Then, within a VI called by this sequence, call a method of the intantiated object.
    To do this, when specifying your module on your LV step you must check the Sequence Context ActiveX Pointer check box. In the called VI you must have the a Sequence Context control on your front panel and have it wired to your connector pane along with a TestData cluster control and a LV Error Out cluster control.
    Within the VI you use an invoke node to invoke the AsPropertyObject method on the SequenceContext (Make sure you use the ActiveX close function on this new reference when you are done with it.). Use another invoke node to call GetValInterface method on the sequence context property object reference (you could probably also use the GetValIDispatch method. See the help). For this invoke node you will want to use a lookupstring that reference the variable, relative to yo sequence context, in which you stored the refernce to the instantiated object in your sequence file. This will return a variant reference. You must convert this reference to a LV reference using the "To G Data" function in the ActiveX palette. The "To G Data" function requires a type input. You will need an ActiveX Automation Refnum control as the input to this (see ActiveX control palette). You will need to right click on this automation refnum control and browse the ActiveX automation server until you find the DLL ActiveX server from which you instantiated your object within your sequence. Once selected, also select the object that you instantiated. The "To G Data" function will then give you a reference to you object on which you can happily used in your desired manner. Make sure to close this reference with an ActiveX Automation close function when you are done with it.
    I would definitely clean this up with a subVI to perhaps generalize the solution.

  • Possible to use third-party virtual instrument sounds in Mainstage?

    Hi guys,
    I've tried to find the answer to this question with no luck. When using Mainstage during live performances (or at rehearsals, off course, will I be limited to using Apple's built in sounds in Mainstage, or will I be able to add sound from other virtual instruments like the ones from Native Instrument for instance? Let's say I want to play my favorite piano sound from Akoustik Piano and want to use this conveniently from within the Mainstage interface - is this somehow possible?
    Thank you!
    Best,
    Thomas

    Absolutely --- Native Instruments plugins are all available as AUs and work very well with MainStage.

  • Is it possible to querry all of the Virtual Instruments in a VI using the ActiveX Server Virtual Instrument Class?

    Is it possible to querry all of the Virtual Instruments that exist in the Front panel of a VI using the ActiveX Server Virtual Instrument Class? I can't seem to find a method or property that returns all the Instruments I may want to control from another application.
    I wish not to have to reference to the VI to figure the ControlName by looking at the VI FrontPanel.
    But rather have a prop that exposes the strings of all the Instruments.
    Example:
    allinstr=ObjectVIInstrument.VIControlNames
    Object.SetControlValue(AllInstr(1),value)
    Thanks.
    -Abe

    Abe,
    There is a VI method called "Get All Control Values" that returns an array of {name,typedesc,flatstrvalue} but this method is not exposed to ActiveX interface, most probably because type descriptors and flattened strings are data format internal to LabVIEW.
    However you can make a subVI that inputs the target VI name and returns the name of all controls on the Panel invoking the internal method. Then you call this VI via ActiveX to retrieve the list of Front Panel controls of the target VI.
    LabVIEW, C'est LabVIEW

Maybe you are looking for

  • Fontbook activated Fonts not showing up in CS4 apps

    I have a relatively brand new MacBook Pro (3 months) with a clean install of CS4. Until recently I was only using Web standard fonts so did not notice this problem. Fonts I open in Fontbook do not show up in any of the CS4 apps. Searched the Apple an

  • Wish list and bug reports?

    In my short acquaintance with xcelsius 2008 (fix pack 2 now) I have come across a number of bugs (not saying how big a number...) and come up with a number of new features suggestions which I consider crucial (sure, maybe noone else does) but I don't

  • I7 Struggling with Streaming

    I finally got my i7 after 2 months of waiting for apple to get them sorted out, and have been 100% satisfied with the performance up until now. It seems I am incapable of streaming nearly anything. Here is my set up. My iMac is located in my room, co

  • Split the IDOC into multiple IDOC if the IDOC has more than 500 records

    Hi All, I developed an outbound IDOC in which we are facing an issue. There is some limitation on the maximum idoc size it can handle. If number of records is more than 500, split the idoc into multiple iDoc's, e.g. if it would have 1300 records , th

  • Logging level warning not working.

    We have logging set to "warning" in our sessions.xml file, but we still see fine and finer logging lines. Is there anything we are missing? Any help is appreciated. We are on Toplink version 10.1.3 Here are the lines from the sessions.xml file. <logg