Using external C++ DLL's in Ranorex (non .net dll)

Best practices, code snippets for common functionality, examples, and guidelines.
Posts: 20
Joined: Tue Nov 06, 2018 9:14 pm

Using external C++ DLL's in Ranorex (non .net dll)

Post by Bassem.Ibrahim » Tue Sep 21, 2021 9:40 pm

Recently came up on this road block. My coworker created a C++ DLL using Gcc/G++ compiler. In order to use the DLL in my Ranorex project I had to do the following:
1) Target the Ranorex project to the correct Target CPU that the DLL was also targeted to. For me I had to change the Target CPU to 64 bit under the "Compiling" tab of the project properties
2)Add using System.Runtime.InteropServices; to the code module you will be using
3)Add the following attribute to your code module class:
[DllImport(@"C:\API_Tester\API_Tester\bin\Debug\RBTASl.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern void setup( [In] string cmd, [Out] char [] result);

Notice the [In]/[Out] attributes in the arguments signifying if they are input or output variables.

here's a good resource for parameter passing: ... rs-part-3/

Hope that helps someone else!

Certified Professional
Certified Professional
Posts: 120
Joined: Mon Mar 22, 2021 10:01 pm

Re: Using external C++ DLL's in Ranorex (non .net dll)

Post by Jacob » Wed Sep 22, 2021 9:17 pm

Hi Bassem.Ibrahim!

This is really good information. Thank you for sharing with the community!