DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

How to call a function of registered DLL in Diadem8.10?

Please make the entire procedure after registering DLL in Diadem8.1. Notably, i can't use LAbview. I need it in VBS file. Can you put a sample code example, as i already exhausted in searching the help.
0 Kudos
Message 1 of 7
(4,483 Views)
First of all, I am not really sure what you are trying to do. Still, following information might be useful for you:

1) You cannot register any DLL in DIAdem. DLLs have to be created in C++ using the GPI Wizard (GPI-DLL): http://digital.ni.com/softlib.nsf/websearch/D605AA96CF81760C86256C7600742EC5?opendocument&node=132060_US

2) You cannot call functions out of a DLL in VBS, the scripting language does not support the usage of DLLs.

3) If you have registered a GPI-DLL which is containing functions and commands you can call those functions directly from a VBScript. If the dll is a file import or export filter, use gpifileload and gpifilesave, respectively. If it is a hardware driver you have to configure it in DAC and cannot use if from VBS.
Message 2 of 7
(4,483 Views)
Hi mv_rajk,

I have to agree with IS that I'm not completely sure what you want either. But I'd like to round out IS's excellent points with two more:

4) VBScript can create object variables from an ActiveX object file (*.ocx) and call methods and read and write properties of the new object variable natively. So you can call a DLL from VBScript, but only if you first wrap that DLL in an ActiveX layer and create an object variable with the CreateObject() command.

5) VBScript can similarly create an object variable for any application's OLE Automation Server, again with the CreateObject() command. So you can absolutely call a LabVIEW VI from a DIAdem VBScript, and you can pass DIAdem channels to the VI and create new DIAdem channels based on the
outputs of that VI. Note that this works with all LabVIEW inputs and outputs EXCEPT clusters. So you might have to wrap the VI you're interested in in another VI that builds the clusters to send to the VI you want or unpacks the clusters you get back from the VI you want.

If either of these points sound interesting to you, we'd be happy to provide VBScript code and examples.

Regards,
Brad Turpin
DIAdem Product Support Engineer,
National Instruments
0 Kudos
Message 3 of 7
(4,483 Views)

Hey Brad

 

Once I have a .DLL registered how would I gain access to its functions?

 

I have used the following code to register a .DLL that I am able to use in VBA below is my code in VBScript

 

Dim myObject, sh, fso, sys, test, hdl

  Set sh = CreateObject("WScript.Shell")
  set fso = CreateObject("Scripting.FileSystemObject")
  set sys =  fso.GetSpecialFolder(1)
  sh.Run(sys &"\regsvr32.exe  " &chr(34) &"C:\Program Files\Linkeng\Applications\Linkdata_Vb.dll" &chr(34))

When I execute the code above I get the following pop up.

 

 

Untitled5.png

 

In VBA I gain access to the DLL like so;

Public Declare Function OpenTest Lib "linkdata_vb.dll" _
    Alias "Open_Test" (ByRef hdl As Long, ByVal Name As String) As Long
Tim
0 Kudos
Message 4 of 7
(3,316 Views)

Hi Tim,

 

VBScript can't access the external DLL by direct declaration, because VBScript, unlike VBS, doe NOT support direct IEEE data types such as the required "long" type in the DLL function prototype.  If you wrap the DLL as a COM object, then VBScript can instantiate a variable using that COM object definition with the CreateObject() function.  Your other options are to 1) connect to the DLL via LabVIEW and call LabVIEW via the LVRuntime object available in DIAdem VBScripts, or 2) register the DLL as a GPI-DLL with DIAdem.

 

You're not really still using DIAdem 8.1 are you?

Brad Turpin

DIAdem Product Support Engineer

National Instruments

0 Kudos
Message 5 of 7
(3,310 Views)

Thanks Brad

 

No I am not using 8.1.  I just replied to this post as it was similar to what I was looking for. 

I have tried to register the DLL as a GPI- DLL but when I restart DIadem I get status of "No GPI-DLL"

Untitled9.png

 

importing it into Labview requires a *.h file which I am not sure where to get that for this .DLL

 

My last option is the COM wrapper but I haven't had much luck implementing this

 

Tim
0 Kudos
Message 6 of 7
(3,306 Views)

Hi Tim,

 

Yeah, it's not that simple.  Your DLL needs to be wrapped as a DIAdem GPI-DLL.  You can look into how to do that here:

 

http://www.ni.com/download/diadem-development-system-2015/517/en/

 

The resulting GPI-DLL can be added to that dialog, thereafter the commands and variable declared by the GPI-DLL will be globally available in all DIAdem VBScripts and SUDialogs.

 

Brad Turpin

DIAdem Product Support Engineer

National Instruments

0 Kudos
Message 7 of 7
(3,304 Views)