The example below describes creating, adding, removing, loading and unloading a C DLL function in Visual Studio 2008.
From the Visual Studio startup panel, select the create Project option.
Select the Visual C++ Project Type.
Select the Win32 Project template.
Specify a Name, Location and Solution Name and then click OK
Click Next at the Custom Application Wizard Welcome screen.
Specify the DLL Application Type.
Select the Empty Project check box from Additional Options.
Click Finish.
The project is created.
Log to the DM account in TCL and add the user built in functions with the addbi command. For example:
Type the following command:
addbi MyFunc (f to:
The to: path is the path you specified in the Location text box in step 4 above).
The user branch table is created.
Run the following command from TCL:
ct messages user.builtin user.builtin 001 15 002 MyFunc]1
From the Solution Explorer, right-click Source Files and select .
Select pxusrtbl.cpp.
Click Add.
From the Solution Explorer, right-click Source Files and select .
Select C++ File.
Give this file a name in the format (filename.c).
Click Add.
Open this source file and enter the C++ code.
Code example:
/Comment here int MyFunc(int x) { return x+1; }
Select
from the Visual Studio menu bar.Expand the Configuration Properties item.
Expand the C++ item.
Select the Code generation item.
Click Runtime Library and specify the your Runtime Library:
Debug Multithreaded DLL (will use MSVCRTD.dll, the visual C debug runtime library, usually only available on systems where the VC++ development is installed. You can use this library while developing the dll.)
Multithreaded DLL (will use MSVCRT.dll, the visual C runtime library. This library is found in the system32 directory of Windows systems. After developing the dll, you should rebuild it using this library for deployment to systems running D3 that do not have VC++ installed.)
Click OK.
Select
from the Visual Studio menu bar.Select
from the Visual Studio menu bar.Log to the DM account in TCL and run the following command:
nt_cload 15 C:/temp/CLoad/debug/CLoad.dll
Note that the 15 is required.
Note that you can only load 1 dll. As such, all functions must be contained within the specified dll.
Run the following command from TCL to confirm the dll has been loaded:
nt_cinfo 15
From TCL, test the function:
u bp test.cload 001 cfunction user.builtin 002 print %MyFunc(3) compile bp test.cload (o run bp test.cload
Note that the (o option for Flash compiling is required.
After verifying the dll is working properly, you may need to rebuild it for deployment to systems that do not have VC++ loaded. See step 6.
Unload the dll.
nt_cunload 15
Delete messages user.builtin.
Delete the project workspace directory.
C:\temp\CLoad