LogoLogo
Software DownloadsDatasheetsRequest Support
  • Axsun Knowledge Base
  • OCT Product Configurations
  • Essential Information Guide
  • Getting Started Guides
    • SS-OCT Laser Engine
    • Integrated Engine (Laser & DAQ)
      • Making Connections
      • Installing Software
      • Operating the Integrated Engine
  • Reference Manuals
    • Dimensions
    • Electrical Interfaces & Connectors
    • Environmental Requirements
    • SS-OCT Laser Engine
      • Advanced Laser Engine Features
      • Laser Accessories
      • Laser Test Report
      • Frequently Asked Questions
      • Laser Troubleshooting
    • Ethernet/PCIe DAQ Board
      • Architecture & Interface Background
      • Basic Operation
      • Advanced DAQ Features
      • FPGA Register Reference
      • Frequently Asked Questions
      • DAQ Troubleshooting
    • Camera Link DAQ Board
  • How-Tos
    • Upgrading Board Firmware
    • Upgrading FPGA Bitstreams
    • Using AxsunOCTControl.dll in C++
    • Operating a Variable Delay Line
    • Using the Interface Board
    • Installing the PCIe Device Driver
  • Using Bus Power for the PCIe DAQ
  • Software Tools
    • OCT Host
    • Hardware Control Tool
    • Image Capture Tool
  • API References
    • AxsunOCTControl (.NET)
      • Using the Control.NET API
      • AxsunOCTControl Function Reference
    • AxsunOCTControl_LW (light-weight)
      • Using the Control_LW API
      • AxsunOCTControl_LW Function Reference
    • AxsunOCTCapture
      • Using the Capture API
      • Linux Installation
      • AxsunOCTCapture Function Reference
  • Other
    • Software Downloads
    • Datasheets
    • References
    • Contact Excelitas For Help
      • Tech Support Request Form
Powered by GitBook

© 2025 Excelitas Technologies

On this page
  • Background
  • Assembly Registration using RegAsm.exe
  • Importing the .tlb file, starting COM, and accessing .dll functions in Visual C++
  • Example C++ Source Code

Was this helpful?

  1. How-Tos

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++.

PreviousUpgrading FPGA BitstreamsNextOperating a Variable Delay Line

Last updated 6 years ago

Was this helpful?

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 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 application or the 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:

cd c:\Program Files (x86)\Axsun\Axsun OCT Control
  • Execute the RegAsm.exe command (noting the correct bitness and version part of the path):

c:\Windows\Microsoft.NET\Framework\v4.0.30319\RegAsm.exe AxsunOCTControl.dll /tlb:AxsunOCTControl.tlb /codebase

(or for 64-bit)

c:\Windows\Microsoft.NET\Framework64\v4.0.30319\RegAsm.exe AxsunOCTControl.dll /tlb:AxsunOCTControl.tlb /codebase
  • 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:

#import “AxsunOCTControl.tlb”
  • Use the AxsunOCTControl namespace:

using namespace AxsunOCTControl;
  • 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 your main() function:

main () {
CoInitialize(NULL);		// init COM
	// AxsunOCTControl.dll calls go here
CoUninitialize(); 		// un-init COM
}
  • Create a pointer to an AxsunOCTControl structure:

IAxsunOCTControlPtr pAxsunOCTControl(__uuidof(struct AxsunOCTControl));
long numDevices = pAxsunOCTControl->GetNumberOfOCTDevicesPresent();

Example C++ Source Code

For simplicity, no error checking is shown in this code.

#include <iostream>
#import "AxsunOCTControl.tlb"			// import the assembly’s .tlb file
using namespace AxsunOCTControl;

int main() {

    // initialize COM
    CoInitialize(NULL);

    // create pointer
    IAxsunOCTControlPtr pAxsunOCTControl(__uuidof(struct AxsunOCTControl));

    // check how many OCT devices are connected
    long numDevices = pAxsunOCTControl->GetNumberOfOCTDevicesPresent();

    // report status
    std::cout << "num of devices is " << numDevices << '\n';
	
	// call additional functions in pAxsunOCTControl 
	// here as needed for your application workflow
	
	// uninitialize COM
    CoUninitialize();

    return 0;
}

Dereference this pointer to access the available in the AxsunOCTControl structure:

AxsunOCTControl_LW
OCT Host
Hardware Control Tool
API functions