LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

How to import a CVI dll in Visual Studio 2003

Good Morning,


I have made a CVI program with my collegue which allows the users to exchange some data with the TCP protocol, and now we must integrate this fonctionnality to an other program, which has been developped in Visual Studio 2003.

So we have created a dll from our CVI project and this one works, But can't call this dll from a visual studio project. Does anybody know how to do this (in a very simple visual studio project, just in way to understand...) or somebody who can indicate me a link to a good tutorial about integration of CVI dll in visual studio?

Thanks
0 Kudos
Message 1 of 5
(3,841 Views)

Can you give more details of the problem? (Compile errors, link errors, program doesn't load, or what?

JR

0 Kudos
Message 2 of 5
(3,838 Views)
Hello,

To use your CVI DLL in .NET, you will need to make use of the DllImport command.  Using this command allows you to specify which functions you want to import from your CVI DLL, and make use of them within your .NET project.  An example of DllImport can be found in the following KB:

How Can I Make DLL Calls to Traditional-DAQ or DAQmxBase Functions in my .NET Program?

Although this KB specifically refers to the Traditional-DAQ or DAQmxBase DLL's, you will use the same practice for your CVI DLL.

NickB
National Instruments
Applications Engineering
Message 3 of 5
(3,828 Views)
Hi,

Thanks for your quick answers.

Here is the code of a little Visual project which import our DLL successfully :

int APIENTRY _tWinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPTSTR    lpCmdLine,
                     int       nCmdShow)
{
    HMODULE hDll = LoadLibrary( "TCP_serveur_DLL.dll" );

    typedef void (WINAPI * DLL_Function_TCP) ();

    DLL_Function_TCP pTCP;

    pTCP = (DLL_Function_TCP) GetProcAddress( hDll, "LanceLePanelEmbarqueDansLaDLL" );

    pTCP( );

    FreeLibrary( hDll);

    return 0;

}

But We must import this DLL in a visual project which contains the following main :

int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLine, int nCmdShow)
{

If we insert the code precedently described in this main (whithout the int APIENTRY _tWinMain evidently...), we obtain the followings errors :

c:\P_WIN_OBAO\source\panneau_commande_dyn.c(385): error C2065: 'hDll' : identificateur non déclaré
c:\P_WIN_OBAO\source\panneau_commande_dyn.c(385): error C2143: erreur de syntaxe : absence de ';' avant 'identificateur'
c:\P_WIN_OBAO\source\panneau_commande_dyn.c(385): error C2144: erreur de syntaxe : '<Inconnu>' doit être précédé de '<Inconnu>'
c:\P_WIN_OBAO\source\panneau_commande_dyn.c(385): error C2144: erreur de syntaxe : '<Inconnu>' doit être précédé de '<Inconnu>'
c:\P_WIN_OBAO\source\panneau_commande_dyn.c(385): error C2146: erreur de syntaxe : absence de ';' avant l'identificateur 'hDll'
c:\P_WIN_OBAO\source\panneau_commande_dyn.c(385): error C2275: 'HMODULE' : utilisation non conforme de ce type comme expression
c:\P_WIN_OBAO\source\panneau_commande_dyn.c(385): warning C4047: '=' : 'int' diffère de 'HMODULE' dans les niveaux d'indirection
c:\P_WIN_OBAO\source\panneau_commande_dyn.c(387): error C2143: erreur de syntaxe : absence de ';' avant 'type'
c:\P_WIN_OBAO\source\panneau_commande_dyn.c(389): error C2065: 'DLL_Function_TCP' : identificateur non déclaré
c:\P_WIN_OBAO\source\panneau_commande_dyn.c(389): error C2065: 'pTCP' : identificateur non déclaré
c:\P_WIN_OBAO\source\panneau_commande_dyn.c(389): error C2143: erreur de syntaxe : absence de ';' avant 'identificateur'
c:\P_WIN_OBAO\source\panneau_commande_dyn.c(389): error C2144: erreur de syntaxe : '<Inconnu>' doit être précédé de '<Inconnu>'
c:\P_WIN_OBAO\source\panneau_commande_dyn.c(389): error C2144: erreur de syntaxe : '<Inconnu>' doit être précédé de '<Inconnu>'
c:\P_WIN_OBAO\source\panneau_commande_dyn.c(389): error C2146: erreur de syntaxe : absence de ';' avant l'identificateur 'pTCP'
c:\P_WIN_OBAO\source\panneau_commande_dyn.c(391): error C2143: erreur de syntaxe : absence de ';' avant 'identificateur'
c:\P_WIN_OBAO\source\panneau_commande_dyn.c(391): error C2144: erreur de syntaxe : '<Inconnu>' doit être précédé de '<Inconnu>'
c:\P_WIN_OBAO\source\panneau_commande_dyn.c(391): error C2144: erreur de syntaxe : '<Inconnu>' doit être précédé de '<Inconnu>'
c:\P_WIN_OBAO\source\panneau_commande_dyn.c(391): error C2146: erreur de syntaxe : absence de ';' avant l'identificateur 'GetProcAddress'
c:\P_WIN_OBAO\source\panneau_commande_dyn.c(391): warning C4047: 'fonction' : 'HMODULE' diffère de 'int' dans les niveaux d'indirection
c:\P_WIN_OBAO\source\panneau_commande_dyn.c(393): error C2063: 'pTCP' : n'est pas une fonction
c:\P_WIN_OBAO\source\panneau_commande_dyn.c(395): warning C4047: 'fonction' : 'HMODULE' diffère de 'int' dans les niveaux d'indirection
editeur warning LNK4075: ' /EDITANDCONTINUE' ignoré à cause de la spécification '/INCREMENTAL:NO'

Sorry for the lisibility of my post....Smiley Wink

Best regards
0 Kudos
Message 4 of 5
(3,793 Views)
Although my knowledge of French is close to non-existant, if I had to guess at the cause of the problem I would suggest that an include file is missing in the project - for instance the one in which the HMODULE typedef is defined.
 
JR
0 Kudos
Message 5 of 5
(3,791 Views)