Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

How to call the function of GPIB4882

       I want to use the function of GPIB4882(like Send,Receive, etc.), but it seems not easy to call the function defined in the files of ni4882.h and ni4882.dll . Please tell me the way how to call the function step by step. I with VC6.0.

       Thank you for you kindly help.

0 Kudos
Message 1 of 10
(7,070 Views)

Hello,

 

How far have you gotten with calling the DLL? What is your experience level with calling DLLs in C++?

 

This is a good starting point for calling a DLL in VC.

 

http://zone.ni.com/devzone/cda/tut/p/id/3927

 

Eric

Eric Liauw
Senior AE Specialist - Automated Test | CLD | CTA
National Instruments
0 Kudos
Message 2 of 10
(7,051 Views)
Dear Eric, Thank you. Actually, I have not much experience about calling DLLs in C++. I know how to call the lib files but never try to call dlls. NI offers two files,ni4882.h and ni4882.dll, and there is no lib files. It seems easy to call the lib files.
0 Kudos
Message 3 of 10
(7,046 Views)
Dear Eric, Can you give me some examples about how to call the function in ni4882.dll? Thank you! I am looking forwaid to hearing from you. My email:xjtuthermo@foxmail.com
0 Kudos
Message 4 of 10
(7,040 Views)

Hello,

 

I don’t write much code, but examples calling a function within a DLL in VC can be found in the following link. Calling the function starts at step 4.

 

http://www.codeproject.com/KB/DLL/XDllPt1.aspx

 

Also have a look at this link; it points to a location for example code.

 

http://forums.ni.com/t5/Measurement-Studio-for-VC/What-files-to-I-need-to-implement-GPIB-functions-i...

 

You can also look for examples in the start menu under National Instruments/NI-488.2/Examples

 

Eric

Eric Liauw
Senior AE Specialist - Automated Test | CLD | CTA
National Instruments
0 Kudos
Message 5 of 10
(7,035 Views)

Hi,

   I wrote the following code but I can not link the the dll.

    Linking...
   GPIBtoSR785-01.obj : error LNK2001: unresolved external symbol _Receive@20
   GPIBtoSR785-01.obj : error LNK2001: unresolved external symbol _Ibsta@0
   GPIBtoSR785-01.obj : error LNK2001: unresolved external symbol _Send@20
   GPIBtoSR785-01.obj : error LNK2001: unresolved external symbol _ibrsp@8
   GPIBtoSR785-01.obj : error LNK2001: unresolved external symbol _ibwait@8
   Debug/GPIBtoSR785-01.exe : fatal error LNK1120: 5 unresolved externals

  

 

 /*add ni4882.dll*/

     typedef int(*IPAddFunSend)(int,int,const void*,int,int);
     typedef int(*IPAddFunReceivw)(int,int,const void*,int,int);
     typedef int(*IPAddFunIbsta)(void);
     typedef unsigned long(*IPAddFunIbdev)(int,int,int,int,int,int);
     typedef unsigned long(*IPAddFunIbwait)(int,int);
     typedef unsigned long(*IPAddFunIbrsp)(int,char*);
     HINSTANCE hDll; //DLL

     IPAddFunSend Send;
     IPAddFunReceivw Receivw;
     IPAddFunIbsta ibsta;
    IPAddFunIbdev ibdev;
    IPAddFunIbwait ibwait;
    IPAddFunIbrsp ibrsp;
  //Load DLL ni4882.dll
  hDll=LoadLibrary("C:\\Program Files\\Microsoft Visual Studio\\MyProjects\\GPIB\\ni4882.dll");
  if(hDll!=NULL)
  {
    Send=(IPAddFunSend)GetProcAddress(hDll,"Send");
   Receivw=(IPAddFunReceivw)GetProcAddress(hDll,"Receivw");
   ibsta=(IPAddFunIbsta)GetProcAddress(hDll,"ibsta");
   ibdev=(IPAddFunIbdev)GetProcAddress(hDll,"ibdev");
   ibwait=(IPAddFunIbwait)GetProcAddress(hDll,"ibwait");
   ibrsp=(IPAddFunIbrsp)GetProcAddress(hDll,"ibrsp");
  }

0 Kudos
Message 6 of 10
(7,031 Views)

Hello,

 

It would be easier if you use the 488.2 API. Did you have a look at the example included with the NI-488.2 Drivers? I attached the example and readme if have not yet; it should be easier than calling the DLL.

 

Eric

 

 

Eric Liauw
Senior AE Specialist - Automated Test | CLD | CTA
National Instruments
Download All
0 Kudos
Message 7 of 10
(7,024 Views)

Hi,

   Eric, I have the 4882query file. But i think the probles is how to link the functions. Because the the functions realize in DLL( or LIB )file, so we need fistly link the DLL( of LIB) files, and then the function which defined in the head file ni4882.h can be used. What confused me is how to call or link these functions but not how to use them. Thank you for your kindly reply!

0 Kudos
Message 8 of 10
(7,021 Views)

Hello,

 

To include the header/DLL file, you should beable to add

 

#include "ni4882.h"

 

to your code. There may be a couple of other steps as listed in the other How-to. I am not that familar with C++ or Visual C++.

 

I hope this helps,

 

Eric

Eric Liauw
Senior AE Specialist - Automated Test | CLD | CTA
National Instruments
0 Kudos
Message 9 of 10
(7,014 Views)

Hi,

   The header file ni4882.h has been added. Thank you for your kindly help.

   I hope someone familiar with C++ could share the experience how to call the DLL or help me find the errors listed before.

0 Kudos
Message 10 of 10
(7,010 Views)