How to create a regular Windows DLL by using Visual C++ .NET

A regular Windows DLL (dynamic link library) is a collection of functions that can be used in multiple applications. The NeuroShell Trader uses custom built DLLs to implement complex indicators that could not be built otherwise with the built-in Indicator Wizard. In Visual C++ .NET you can create a regular Windows DLL by using the Win32 Project template. Here are main steps.

1. Run Visual Studio .NET programming environment.

2. Click on the File menu, point to New, and then click Project. The New Project window appears.

3. In the left pane, under the Project Types, click on the plus sign (+) against the “Visual C++ Projects” line. This will expand all Visual C++ projects into several folders.

4. Click on the Win32 folder.

5. On the right pane, under the Templates section, click Win32 Project.

6. In the Name box, type TestNSTdll.

7. In the Location box, type C:\, and then click OK. (Don’t worry about C:\ location – Visual C++ .Net will automatically create the C:\TestNSTdll sub-folder and put all necessary project files into it.) The Win32 Application Wizard – TestNSTdll wizard starts.

8. On the Welcome to the Win32 Application Wizard page, on the left, click Application Settings.

9. On the Application Settings page, under Application type, click DLL. Under Additional options, check Empty ptoject.

10. Click Finish.

These main steps will only create an empty DLL project in the C:\TestNSTdll. Next you will need to create your C/C++ source code module with the indicator source and add it to the project.

UPDATE 8/23/2016: When DLL is written in C++, in order for the function names to be correctly read by NeuroShell Trader in the indicator wizard interface (without having extra characters in the function name) the function declarations either need to be declared in a .def file (as per our examples) or else declared with c naming conventions (as per https://msdn.microsoft.com/en-us/library/wf2w9f6x.aspx)

Update 12/31/2019:  VC++2012
If you previously created DLLs in VC++6.0 and they worked fine with NeuroShell Trader 6 and 7, you should consider the following to prevent errors when converting to VC++2012.

Make sure the DLL you are creating is a 32-bit DLL and not a 64-bit DLL.

Don’t use VC++ 2012 to convert the VC++6 project (dsp) to a VC++ 2012 project(sln).  VC++2012 will not convert the project correctly so the VC++2012 compiled DLL will not work with NeuroShell Trader 7.  Instead create a new project in VC++2019 with the previous .CPP,.DEF AND .h files.  Compile the new DLL and it will work with NeuroShell Trader 7.

Was this article helpful?

Related Articles