09-13-2008 03:21 PM
09-15-2008 06:07 PM
Hey Tim,
What accompanying files do you have with this DLL? Do you have a .h and .lib file? This will make it much simpler to call the DLL. You mentioned that you couldn't add the DLL as a reference. What method were you using to reference this DLL? Depending on whether you have the .h and .lib file, you will have to either explicitly or implicitly link it.
Lars
09-16-2008 02:05 AM
Yes, I do have an H and lib file....just don't know how to use them correctly 😕
Using VBA 2008 DE, I go to'Projects' --> 'Add Reference', click the 'Browse' tab, navigate to the directory, select the dll, and get the error message that I've attached.
09-16-2008 08:56 AM - edited 09-16-2008 08:57 AM
You will not be able to select that dll as a reference, because if it has been created in CVI it is a C style dll. You can only add ActiveX/COM dll's as a reference. You will have to import the functions from the dll using syntax similar to the following:
Private Declare Function SampleFunction Lib "SampleDLL.dll" (ByVal x As Integer) As Integer
This line would import the C function with the following prototype:
int SampleFunction (int x)
You can then use the function in your various subroutines as needed.
NickB
National Instruments
09-17-2008 12:13 AM
I think I've got it working now, thanks guys for the help.
One last question:
Some of the functions require a pointer to be passed as a parameter.
for example:
MP_OpenCamera(int Head, int *CamHandle)
How are you supposed to pass the address of a variable in VBA? AddressOf operator creates function pointers/
09-17-2008 10:33 AM
Hello,
you would pass the address of the variable as follows:
Private Declare Function MP_OpenCamera Lib "SampleDLL.dll" (ByVal Head As Long, ByRef CamHandle As Long)
If your CVI parameters are ints, it is important to pass them as longs from VBA, as integers in VBA are only 16 bit.
NickB
National Instruments