Creating user-defined C functions (D3 Windows)
.mdThe example below describes creating, adding, removing, loading and unloading a C DLL function in Visual Studio 2008.
Step 1: Create a new Project:
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.
Step 2: Create the user branch table (pxusrtbl.cpp)
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.
Step 3: Verify the user builtin functions
Run the following command from TCL:
ct messages user.builtin user.builtin 001 15 002 MyFunc]1
Step 4: Add the pxusrtbl.cpp to the project
From the Solution Explorer, right-click Source Files and select .
Select pxusrtbl.cpp.
Click Add.
Step 5: Create and add the C++ source code file
Step 6: Set Compile options
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.
Step 7: Build the dll
Select from the Visual Studio menu bar.
Step 8: Load the dll
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.
Step 9: View the dll
Run the following command from TCL to confirm the dll has been loaded:
nt_cinfo 15
Step 10: Test the new function
Step 10a: Rebuild using the non-debug run-time library if necessary.
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.
Step 11: To start all over
Unload the dll.
nt_cunload 15Delete messages user.builtin.
Delete the project workspace directory.
C:\temp\CLoad