Calling a Visual C++ dll from CVI

I created a dll in visual C++, try to access it using .Net library APIs of CVI.
I am able to create the object of the class “Class1” correctly, but when I try to invoke a function of the class, I got error  -6587(inaccessible error).
I attached my code, dll code for your reference.
Attachments:
Maxnumeber.zip ‏3 KB
test1.zip ‏820 KB

Can you provide a screen shot of the error you are receiving? Have you marked the functions you are trying to call with extern C to specify that they are going to be used with the C compiler? Please see the followling link which discusses this topic.
http://www.ni.com/white-paper/3341/en#toc9
Regards,
Anjelica W.
National Instruments
Applications Engineer

Similar Messages

  • I get error 998 when calling a LabVIEW buildt DLL from MSVC++

    I created a DLL in LV 6.0.2. This DLL contains 39 VIs and controls. 13 of the VIs are exported, the others are subVIs, which one of them is a dynamic VI.
    I do not have all connectors used by defining the VI prototype in the build file for the application builder.
    Using this DLL I get four effects:
    From LV 6.0.2 FDS all works fine until I quit LV immediatly after the application VI stoppes. Then LV wants to save some of the VIs of the DLL.
    If I do the same but close the VI before I quit LV one want save anything.
    After Building an exe from the application VI and running the exe all works fine. The VI will only stop and if I close or quit noone wants to save something.
    Then I built an application with M
    SVC++ 6.0 using this DLL. There will be no errors or warnings during the build. If I start the application i get an error message dialog with the number 998 stating "system error loading LV Runtime engine. My application needs a Version 6.0 or compatible Runtime-engine". The path to teh Runtime-engine is given in the dialog and the lvrt.dll there has version 6.0.2.
    Does someone run on such a problem?
    Has someone a solution to this?
    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

    Waldemar,
    I. LabVIEW wanting to save VIs
    The DLL created is just a group of VIs, not actually compiled DLL code. When the subVIs are called, they might be cached from the disk copy, not the one in the DLL. LabVIEW then loads the separate copy of that subVI. It will then ask if you want to save changes because there were value changes when it was run (this makes since) or it is in LabVIEW 6.0 version and has not been mass compiled for LabVIEW 6.0.2. When it is compiled to an exe, the search path for the subVIs goes through the executable and not the LabVIEW development environment. Also, saving VIs is not an option in an executable so the save dialog does not pop up.
    II. MSVC++ error
    This is actually a Microsoft issue. It has something to do with static and
    dynamic linking of the MFC DLL. Our R&D engineers have verified this with projects created with no LabVIEW code at all (that is why we believe it to be solely a Microsoft issue). There are three options at this time:
    1. Link with the DLL form of MFC.
    2. Do not link with the .lib from the LV DLL, instead use LoadLibrary and GetProcAddress to dynamically load the DLL and call the function.
    3. Use the VC delayload feature to make the LV DLL not get loaded until the first call is made into it. See VC help on "delayload" for information on setting this up.
    Randy Hoskin
    Applications Engineer
    National Instruments
    http://www.ni.com/ask

  • Calling a third Party dll from java using JNI

    Hi
    I want an immediate help from u all.
    I have athird party c dll with .h and .lib file
    I wont be able to cahnge any thing in those files.
    I want to call the functions of that from my Java code.
    Ist possible to call the dll without writing any c or c++ wrapper over it?if yes , how to do it?

    Hi,
    You may use a generic wrapper like JNative.
    Commercial wappers also exists.
    --Marc (http://jnative.sf.net)                                                                                                                                                                                                                               

  • How do I call a LabVIEW created DLL from within Microsoft Excel (VBA)?

    Hi,
    I'm trying to get Microsoft Excel 2003 to call a function stored in a dll that I created using LabVIEW 7.1.  The function is very simple and is called "binary_file_to_ascii".  Basically it just reads a LabVIEW created binary spreadsheet file and outputs the columns as float arrays.
    The function arguments are as follows:
    INPUT : String that contains the path to the binary spreadsheet file
    OUTPUT : Number of rows in the spreadsheet
    OUTPUT : Number of columns in the spreadsheet
    OUTPUT : Float array containing the elements in column 1
    OUTPUT : Float array containing the elements in column 2..
    OUTPUT : Float array containing the elements in column 11
    However, for some reason there is something wrong with my VBA code and/or the way I created the DLL in LabVIEW because Excel crashes when it loads my DLL.
    What do I need to change in my VBA code or my LabVIEW DLL build settings to fix this?
    I've attached to this post a ZIP file that contains all my code and a sample binary file.
    Your help with this will be much appreciated.  Thanks!
    Richard
    P.S.  Here is the VBA code I'm using:
    Private Declare Function binary_file_to_ascii Lib "C:\temp\binary_file_to_ascii\binary_to_ascii.dll" _
    (ByVal binaryFile As String, ByVal nrows As Long, ByVal ncols As Long, ByVal column1 As Variant, _
    ByVal column2 As Variant, ByVal column3 As Variant, _
    ByVal column4 As Variant, ByVal column5 As Variant, _
    ByVal column6 As Variant, ByVal column7 As Variant, _
    ByVal column8 As Variant, ByVal column9 As Variant, _
    ByVal column10 As Variant, ByVal column11 As Variant)
    Private Sub load_binary_spectra()
      Dim nrows, ncols As Long
      Dim col1(), col2(), col3(), col4(), col5(), col6(), _
          col7(), col8(), col9(), col10(), col11() As Variant
      Dim lRetVal As Long
      Dim spectra_path As String
        spectra_path = "C:\temp\binary_file_to_ascii\sample_binary_file\sample_binary_file.dat"
        lRetVal = binary_file_to_ascii(spectra_path, nrows, ncols, _
                  col1(), col2(), col3(), col4(), col5(), col6(), _
                  col7(), col8(), col9(), col10(), col11())
        MsgBox (spectra_path)
    End Sub
    Message Edited by Richard Ballantyne on 07-25-2007 02:39 PM
    Message Edited by Richard Ballantyne on 07-25-2007 02:39 PM
    Attachments:
    binary_file_to_ascii.zip ‏192 KB

    Hi,
    I don't know anything about Visual Basic, but here's my guess.
    When you load the DLL with this line of code
    Private Declare Function binary_file_to_ascii Lib "C:\temp\binary_file_to_ascii\binary_to_ascii.dll" _
    (ByVal binaryFile As String, ByVal nrows As Long, ByVal ncols As Long, ByVal column1 As Variant, _
    You are defining how the parameters are sent. It seems that all are sent by value (ByVal), but in the DLL header, some of the function's
    parameters are defined as pointers(see the function prototype below, look for asterisk(*))
    void __stdcall binary_file_to_ascii(PStr binaryFile,
                                                    long *numberOfRows,
                                                    long *numberOfColumns,
                                                    float column1[],
                                                    float column2[],
                                                    float column3[],
                                                    float column4[],
                                                    float column5[],
                                                    float column6[],
                                                    float column7[],
                                                    float column8[],
                                                    float column9[],
                                                    float column10[],
                                                    float column11[]);
    Can you define in VBA that you want to use pointer instead? Maybe by using ByRef (as by reference).
    Hope this helps.

  • Calling existing C/C++ dll from Java Prog

    Hi,
    From within the Java code I want to use the
    functionality of an existing C API. The dll's of C are available. Is it possible to directly call the C Api using Jni or some other technique or do I need to implement a native method in C which would Use the existing C Api to get the values and Pass them to the Java prog.
    Istikhar.

    Is it possible to directly call the C Api using Jni...Depends on what you mean. You can't call it directly from java. You can use JNI, including C/C++ to call it.

  • Trying to call GetFileVersionInfo in versio.dll from LV

    I'm trying to use the Windows call GetFileVersionInfo in the version.dll file to get the version info of an executable. Either I get garbage back for the version info or LV crashes. I am able to call GetFileVersionInfoSize successfully. I know these calls can be tricky and I probably don't have the parameters right, but I'm at a loss for what to try next. I've included the VI I'm using.
    Attachments:
    fileinfo.vo.vi ‏13 KB

    A few things...
    1. The lpData returned by the GetFileVersionInfo is an opaque pointer (void*), meaning you should not try to associate anything other than an int32 with it. This is probably where you are getting your problems. Simply define the parameter as an int32 rather than a CStr and then pass the int32 into VerQueryValue.
    2. VerQueryValue is going to be more problems because the output of that is a variety of different possible structures. Getting those mapped correctly into LV data types is a fraught exercise and in general I don't recommend it. It is generally much easier to create a C wrapper DLL that does the structure manipulations for you and returns the basic data types you need.
    3. HOWEVER - what I really recommend that you do is drop the attempt to use the Win32 functions and use the .NET API instead (look at System.Diagnostics.FileVersionInfo). Due to the way .NET works, LV can provide automatic data conversions for the .NET APIs and all of these problems just go away.
    Brian Tyler
    http://detritus.blogs.com/lycangeek

  • How do you call a Visual Basic App From Labview?

    I have a Visual Basic executable application that is collecting data from a USB port and displaying it in an MS grid control. I would like to read the same data in a LabVIEW application. The LabVIEW app would periodically poll the VB App to collect the current data. Does anyone have any insight or examples?

    Go to the Resource Libary at http://zone.ni.com/devzone/devzone.nsf/webcategories/9C6DF90777E5A78206256874000FA14E?opendocument (Resource Library>LabVIEW>Connectivity>ActiveX) for some examples. You'll need access to the VB source code.

  • Calling a Visual C++ COM from java

    Hi all, I have a problem very strange:
    I have developed , using JNI, a java class wich interacts with a COM Interface.
    When I use the java class that implements jni connection form the main method in my java app, it works fine, but when I try to access this class in a different class outside main, I obtain an error creating the Com instance. Anyone knows why?
    //C++ Com initialize
    BOOL CECardIdWorks::Initialize()
    CUtilLog oUtilLog = CUtilLog();
    try
    // Get our instance of the PrintServer's IDataInput interface:
    HRESULT hr = m_pDataInput.CreateInstance(__uuidof(PrintServer::DataInput2));
    if (FAILED(hr))
         oUtilLog.NuevoLog("CECardIdWorks","InitCard","Fallo en m_pDataInput.CreateInstance.");
              return TRUE;
    catch (_com_error& ce)
    oUtilLog.NuevoLog("CECardIdWorks","Initialize","Excepcion , Initialize exception.");
    LogComError(ce);
    AfxMessageBox("Initialize Exception. Exit");
    return FALSE;
    }

    This is the C++ code part.
    // extract of code in ECard.cpp
    //class intance
    CECardIdWorks* oECardIdWorks = new CECardIdWorks();
    // Initialize
    JNIEXPORT jint JNICALL Java_ECard_Initialize(JNIEnv *env, jobject obj)
         CUtilLog oUtilLog = CUtilLog();
         oUtilLog.NuevoLog("CECard","Java_ECard_Initialize","Begining Initialize.");
         if (oECardIdWorks->Initialize())
              return EC_SUCCESS;
         else
              return EC_ERROR_NOT_INITIALIZED;
    // extract of code in ECardIdWorks.cpp
    BOOL CECardIdWorks::Initialize()
         CUtilLog oUtilLog = CUtilLog(); 
         try
                // Get our instance of the PrintServer's IDataInput interface:
                HRESULT hr = m_pDataInput.CreateInstance(__uuidof(PrintServer::DataInput2));
                if (FAILED(hr))
                     oUtilLog.NuevoLog("CECardIdWorks","InitCard","Fallo en m_pDataInput.CreateInstance.");
                return TRUE;
       catch (_com_error& ce)
             oUtilLog.NuevoLog("CECardIdWorks","Initialize","Excepcion , Initialize exception.");
           LogComError(ce);
           AfxMessageBox("Initialize Exception. Exit");
           return FALSE;
    // extract of code in ECardIdWorks.h
    class CECardIdWorks : public CWinApp
    public:
         // Print Server IDataInput
         PrintServer::IDataInput2Ptr      m_pDataInput;    
         DECLARE_MESSAGE_MAP()
    // Extract of code from StdAfx.h
    #import "D:\Archivos de programa\Datacard\ID Works\bin\PrintServer.DLL"This is the java code part
    public class ECard {
        // Load the dll that exports functions callable from java
        static {System.loadLibrary("ECard");}
           // Imported function declarations
            public native int Initialize();
         public void ECard()
         public static void main(String [] args)
          ECard t = new ECard();
         int intResult=0;
          // Initialize
          intResult = t.Initialize();
          System.out.println("->Initialize. Return value:" + intResult);
    }My problem is that, if this code
    ECard t = new ECard();
         int intResult=0;
          // Initialize
          intResult = t.Initialize();
          System.out.println("->Initialize. Return value:" + intResult);is outside main method, for example, in a method of another class, I get an error like this:
    Com error 80004005
    Source: PrintServer.IDataInput.2
    Description: Error creating instance of card object
    Please help me I�m desperate...

  • How to call a labview dll from excel-VBA?

    How to call a simple Labview DLL from Excel VBA?
    I have seen examples of DLL calls from VB but does it work the same way for VBA? I have 2000 excel and Labview 8.5. I created the DLL and tried to call it from VBA using the same type of code as in NI's website example(ofcourse its a bit diff with 8.5)
    http://zone.ni.com/devzone/cda/tut/p/id/...
    BUT it errors out when called from excel
    ERROR: The object invoked has disconnected from its client

    You would need to provide more details about the LabVIEW DLL, such as the prototypes of the functions (VIs) that you're trying to call, and your actual VBA code. Specifically, what object you're trying to create. You should also make sure the Run-Time Enginer is installed, as well as any required libraries such as the VISA Run-Time if you're using VISA. Have you made sure to enable the ActiveX server for the DLL?
    A search yielded the following items that you may wish to peruse:
    http://forums.ni.com/ni/board/message?board.id=170&message.id=261345&requireLogin=False
    http://forums.ni.com/ni/board/message?board.id=170&message.id=45099&requireLogin=False
    http://forums.ni.com/ni/board/message?board.id=170&message.id=299209&requireLogin=False
    http://forums.ni.com/ni/board/message?board.id=170&message.id=195846&requireLogin=False

  • Calling LV DLL from VB

    I have a vi that initializes, measures, and releases
    an OSA instrument. I want to call this routine from VB.
    I used Standard calling convention when making DLL from LV.
    Here is my VB declaration:
    Private Declare Sub OSAMeasurement Lib "C:\ADE\OSAMeasurement.dll" Alias "OSADFBMeasurement" _
    (ByVal GPIB As Long, _
    ByVal Serial_Number As String, _
    ByVal FileName As String, _
    ByVal File_Path As String, _
    ByVal Start_Wavelength_nm As Double, _
    ByVal Stop_Wavelength_nm As Double, _
    ByVal Level_Scale_dB As Double, _
    ByVal Res_nm As Double, _
    ByVal Peak_Wavelength As Double, _
    ByVal Peak_Level As Double, _
    ByVal SMSR As Double, _
    ByVal FWHM As Double, _
    ByVal Mode_Offset As Double, _
    ByRef Level_Array() As Double, _
    ByRef Wa
    velength_Array() As Double, _
    ByVal Array_Length As Long)
    Here is my VB call:
    Call OSAMeasurement(Form1.OSA.PrimaryAddress, _
    (strOXM & Form1!txtOPMNumber), _
    (CStr(CInt(dblSetVoltage)) & "v_Scan.txt"), _
    (txtDataStoragePath & strOXM & " " & Form1!txtOPMNumber & "\"), _
    1520, 1620, 5, 1, Peak_Wavelength, Peak_Level, _
    SMSR, FWHM, Mode_Offset, _
    Level_Array, Wavelength_Array, 1001)
    I get RunTime Error "49"
    Bad DLL calling convention
    What is wrong?
    Any suggestions/comments?
    Attachments:
    OSA.zip ‏703 KB

    Basically what i want to do is to call the microchip's dll called "mpusbapi.dll" from VB6. This dll is written in C++. This dll has some basic functions of usb like MPUSBRead() , MPUSBWrite , MPUSBOpen() etc.
    I have made a usb data acquisition card and i want to communicate with this card by means of VB 6. Please tell me or send a tutorial of calling a DLL from VB 6.
    Any help greatly appreciated
    Attachments:
    _mpusbapi.cpp ‏42 KB
    _mpusbapi.h ‏19 KB

  • Calling external C dll from Portal

    I have been trying to find the best way to call an external c dll from portal. In forms we used a built-in ora_ffi to make the call. What is the best way to do it in portal. Would I need to call from plsql using the extproc?

    depends where the DLL is living.. if you were building the portlet in Java on the midtier you could use JNI to access the DLL. If the DLL is on the infrasture tier then you would need an access method from PLSQL

  • Calling 64-bit dll from labview 8.2 on Windows7

    Hello,
    I have tried the LABview driver from the OMNIDRIVER (OceanOptics) package. But when calling functions from the “OmniDriver32.dll” , LABView is crashing and  says that the memory is corrupted.
    I am using LABVIEW 8.2 (32-bit) running on Windows 7 (64-bit).  I have tried some LABView code examples given for LABview 7.1 and 8.0. These example are using the OmniDriver32.dll (not the OmniDriver64.dll).
    But maybe these example are assuming that you are on a 32-bit operating system, which is not my case.
    So I have tried calling the OmniDriver64.dll. but LABView seems not to recognised the dll and can’t read the included functions.
    Is there a way to call some 64-bit dll from LABview 8.2 ?
    Or do I need to buy a new license for LABVIEW 64-bit ?
    Thanks,
    Pierre

    There is no virtualization support for DLL bitness issues outside of the Windows standard directories. The Windows and System directories that an application "sees" depends on its bitness. All other directories are not mapped depending on the calling process' bitness.
    So if you have installed 32 Bit LabVIEW and are not calling one of the system DLLs, you have to point the path of the DLL to the real 32 bit DLL. Pointing it to a 64 bit DLL should not even be able to get the VI compilable, since Windows will refuse to load the DLL into the 32 bit process as being an unknown file format, and that should make the VI broken.
    If you need to call a system DLL you simply enter the DLL name without path and Windows will find the according DLL for LabVIEW.
    Rolf Kalbermatter
    CIT Engineering Netherlands
    a division of Test & Measurement Solutions

  • Fall into a trouble when calling a dll from java in linux

    Hi, experts:
    I encountered a big trouble when using JNI to call a C++-compiled DLL from java in Linux: The DLL function didn't execute immediately after the invocation, and was deferred till the end of the Java execution. But all worked well after migrating to windows. This problem made me nearly crazy. Can somebody help me? Thanks in advance.
    Linux: fedora core 8, jdk1.6.0_10,
    compile options: g++ -fPIC -Wall -c
    g++ -shared

    It looks like the OP compiled the C source file and linked it into a Windows .dll, which would explain why it worked flawlessly in Windows. (Though I must say the usage of GCC would make someone think it was compiled in Linux for Linux, GCC also exists for Windows, so I'm not sure it's a Windows .dll either...)
    @OP: Hello and welcome to the Sun Java forums! This situation requires you to make both a .dll and a .so, for Windows and Linux. You can then refer to the correct library for the operating system using System.loadLibrary("myLibrary"); without any extension.
    s
    Edited by: Looce on Nov 21, 2008 11:33 AM

  • Calling test sequence from CVI DLL that use ATL COM object does not work

    I am trying to call some DLL function writen in CVI from teststand. The CVI DLL is using ATL COM object(Written by me).
    The ATL COM object making instance of several ATL COM object inside it (including two controls that contains dialog). If I use a client writen in VC++ 6 and use the ATL COM (writen by me) works perfectly. But if I try to use it from CVI DLL it does not work any more.
    What is wrong? The client is passing an IUnknow interface to my component. Can anybody explain me what is wrong?

    It is not clear from your question as to what is specifically failing. If possible, one option would be to remove TestStand from the picture and see if the problem still occurs using a CVI EXE that invokes the CVI DLL.
    Scott Richardson - NI
    Scott Richardson
    National Instruments

  • How to call labview DLL from visual C++?

    Hi,
    I'm trying to call a LV DLL from a VC++ application
    by using the LoadLibrary and GetProcAddress functions.
    The DLL contains a simple sum function. The Library is
    loaded correctly, but the result is always 0.0000.
    I have loaded a VC++ DLL in a similar way and it works
    correctly. Also, I have tested the DLL by loading it in LV,
    and it works correctly. The calling convention is defined
    to be stdcall in LV Application Builder.
    I have also tried this solution, but I will get a compiler error
    from one the header files that are created by the LV when
    the DLL is made. The error comes from this line
    typedef char                int8;
    and the error states that
    ..\fundtypes.h(107) : error C2371: 'int8' : redefinition; different basic types
    If someone knows of newer tutorial(for LV 8.2) or knows how to use those
    LoadLibrary and GetProcAddress function for LV DLLs, I will appreciate the
    information greatly.
    Below is the code that I'm using for loading the LV DLL.
    Thanks
    #include "stdafx.h"
    #include <stdio.h>
    #include <stdlib.h>
    #include <map>
    #include <windows.h>
    int _tmain(int argc, _TCHAR* argv[])
        HINSTANCE LVLib = LoadLibrary(TEXT("Testdll"));
        typedef double (__stdcall *MYPROC)(double, double);
        if (LVLib != NULL)
            MYPROC ProcAdd = (MYPROC) GetProcAddress(LVLib, "Add");
            if (ProcAdd != NULL)
                double d = (ProcAdd)(5.5, 6.6);
                printf("sum = %f\n", d);
            else
                printf("Invalid function pointer\n");
        else
            printf("Failed to load the library\n");
        return 0;

    I was just about to post the header file of the DLL, when
    I noticed that there's a function called LVDLLStatus.
    This little thingie turned out to be a rather handy tool.
    With that function I found that in the DLL I had a problem
    with another function that prevented the DLL to be correctly
    loaded.
    This other function in the DLL is for generating digital output
    and it worked as it should, when tested from LV.
    Anyway if someone is interested, I got it working by using
    the LoadLibrary and GetProcAddress function, as in the
    source code thatI posted earlier.
    I will investigate what is wrong with that digital output, and
    post into a another thread if I have problems with that.

Maybe you are looking for

  • Is it possible to use a variable to control the path where a sub-flow is found ?

    I have a customer on UCCX 7.0.2 SR5. They are developing a script that uses many sub-flows and they wish to have a "Development" , "QA" and a "Production" versions of the application all on the same box. I can build the applications easily enough but

  • ITunes Directory Problem

    I recently installed Windows Vista Service Pack 1 on to my laptop. After the install I can't open itunes. Now, I uninstalled service pack 1 and uninstalled Quicktime and iTunes. Now, after downloading the newest version of iTunes...it seems I have a

  • When to shut down completely.

    What is the "best practice" to keep my Mac Pro well and healthy - as far as shutting it down? Shut down nothing but put the CPU to sleep? Shut down the CPU completely but not the monitor? Shut down the monitor but put the CPU to sleep? If I was going

  • I made the window big and now I have no tabs at top. How do I get them back?

    ''duplicate of https://support.mozilla.com/en-US/questions/901319'' All I have is a white screen. Escape does not work.

  • What are the seeburger adapters needed?

    hi, what are the seeburger adapters neded to implement EDI integration with XI?I mean what we need to install on XI? And also please explain me the end to end process while implementing EDI using Seeburger and XI?I know Converison agent part. thank y