Step-By-Step Guide to Call DLL Function in Ninjascript

Creating and calling a DLL function in Ninjascript can be confusing and tedious. As a developer, it's paramount to understand how to properly set up the function call and the underlying architecture. This document will provide clear guidance on how to call a DLL function in Ninjascript. We'll be discussing the various steps to correctly set up the function call, and provide helpful and relevant links to the documentation and tools.


Before beginning, it is important to know that before you can call a DLL function from Ninjascript, you will need the appropriate toolset and development environment.

  • A Ninjascript-compatible version of Visual C++
  • Access to Ninjascript syntax
  • DllExport
  • Platform Toolset
  • Microsoft Visual Studio 2015

Step 1: Set Up the Project

The first step is to create a DLL project. This can be done by creating a new project in Visual Studio and selecting the template.

  • Navigate to File > New > Project.
  • Select the Win32 project template and click OK.
  • In the Win32 Application Wizard, select Empty Project, and click Finish.

Step 2: Create a Header File

In this step, you will create a header file. This file will contain the functions and prototypes that you want to access through the DLL.

  • Right-click on your project and select Add New Item.
  • Choose a header file and click Add.
  • Enter a name for your header along with custom functions/prototypes as needed.

Step 3: Create a CPP File

Now that you have your header file set up, you will create a CPP file. This file will contain the actual code that gets executed when the function is called.

  • Right-click on your project and select Add New Item.
  • Choose a CPP File and click Add.
  • Enter a name for your source file and enter your code. Be sure to include the include statement in your code so that the compiler can find the header file.

Step 4: Configure the Project

The next step is to create a configuration file. This file will contain the settings and options that you want to apply to the project.

  • Right-click on your project and select Properties.
  • Select the Configuration Properties tab.
  • Switch the Platform Toolset to the version compatible with your version of Visual Studio.
  • Enable commands to be exported
  • Enable the DllExport library if it is not already enabled.

Step 5: Compile the Project

At this stage, you will compile the project. This is a mandatory step for the creation of the DLL.

  • Select Build > Build Solution.
  • Once the project is successfully built, the DLL is created in the Output folder.

Step 6: Access the DLL in Ninjascript

Now that the DLL is created and ready, you can access the exported functions and methods in Ninjascript.

  • Initialize the Ninjascript environment.
  • Use the external keyword to load the Ninjascript assembly.
  • Retrieve the necessary function pointers.
  • Pass the function pointers to the function you want to call.


What is the difference between a header file and a CPP file?

A header file (also known as a .h file) contains preprocessor directives, type and variable declarations, and function prototypes. A CPP file (also known as a .cpp file) contains code written in the C++ programming language.

What is a Platform Toolset?

Platform Toolset is a compiler used to compile programs written in a specific language. It specifies the version of the compiler, libraries and other tools needed to compile and execute the program.

What is DllExport?

DllExport is a tool used to generate stub functions in a DLL project. Stubs are functions that pass parameters from one function to another.

What is an assembly?

An assembly is a unit of deployment that contains code and metadata. Assemblies are used by the Assembly Loader to load an executable.

What is the external keyword?

The external keyword is a keyword used to load type information at runtime. It is used to access types in a referenced assembly.

Great! You’ve successfully signed up.

Welcome back! You've successfully signed in.

You've successfully subscribed to

Success! Check your email for magic link to sign-in.

Success! Your billing info has been updated.

Your billing was not updated.