Using AxsunOCTControl.dll in C++
AxsunOCTControl.dll is a C#/.NET managed library. This document describes how to use AxsunOCTControl.dll from an unmanaged or native C++ application in Windows Visual C++.
Background
Calling methods in the .NET-based AxsunOCTControl.dll from a managed environment (.NET/C#, MATLAB, LabVIEW, Java, etc.) usually involves a straightforward constructor call. However, to call methods in AxsunOCTControl.dll from an unmanaged or native C++ environment, one needs to perform some additional configuration steps described here.
If your client application integration prefers a "plain-old" C interface or is based on an OS other than Windows, consider the light-weight AxsunOCTControl_LW library instead.
Assembly Registration using RegAsm.exe
If desired, copy AxsunOCTControl.dll (and all of its .dll dependencies, e.g. LibUsbDotNet.dll) to the desired location on your disk, such as your project directory. Alternatively, you can leave the library where it is installed alongside the OCT Host application or the Hardware Control Tool application.
A Microsoft Windows tool called RegAsm.exe registers managed libraries as a COM object in the Windows Registry. On Windows 7, RegAsm.exe is located at the following paths (the version part of the path “\vX.Y.ZZZZZ\” might be different than shown here):
32-bit:
C:\Windows\Microsoft.NET\Framework\v4.0.30319\RegAsm.exe
64-bit:
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\RegAsm.exe
Open a Windows
cmd
prompt as Administrator and change the current directory to that of your AxsunOCTControl.dll file, for example:
Execute the
RegAsm.exe
command (noting the correct bitness and version part of the path):
(or for 64-bit)
This will create the AxsunOCTControl.tlb file in the current directory. Move this .tlb file to the same project directory as your .cpp source code which will be calling the AxsunOCTControl.dll library functions.
WARNING: Once registered, do not move the AxsunOCTControl.dll file or its dependencies. Doing so will require you to repeat the RegAsm of the library from its new location.
Importing the .tlb file, starting COM, and accessing .dll functions in Visual C++
Import the AxsunOCTControl.tlb file using the
#import
directive at the top of your source code:
Use the
AxsunOCTControl
namespace:
Wrap the segment of your code that contains calls to AxsunOCTControl.dll with calls to initialize and uninitialize COM. For example, initialize COM at the beginning of your
main()
function and uninitialize it just before completing yourmain()
function:
Create a pointer to an AxsunOCTControl structure:
Dereference this pointer to access the API functions available in the AxsunOCTControl structure:
Example C++ Source Code
For simplicity, no error checking is shown in this code.
Last updated