04-22-2011 04:29 AM
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.
04-25-2011 03:54 PM
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
04-25-2011 09:43 PM - edited 04-25-2011 09:45 PM
04-26-2011 08:54 AM
04-26-2011 03:51 PM
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.
You can also look for examples in the start menu under National Instruments/NI-488.2/Examples
Eric
04-26-2011 08:51 PM
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");
}
04-27-2011 05:46 PM
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
04-27-2011 10:17 PM
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!
04-28-2011 12:51 PM
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
04-28-2011 07:44 PM
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.