How do you incorporate user-created DLLs in WinCC?
1. Sample DLL
Use a C compiler to create the library "T1_C.dll" from the following program code.
You can download the ready-compiled DLL here:
extern "C" __declspec (dllexport) int aufruf1 (int a);
extern "C" __declspec (dllexport) int aufruf1(int a)
h_test= fopen ("C:/temp/test_dll.txt","a");
fprintf(h_test, "Function 'aufruf1' was called!\n");
fclose (h_test );
- The DLL must be created without debug information.
- All the DLL functions used in WinCC must be specified in the corresponding syntax at the beginning of the DLL (see the first line in the sample DLL "T1_C.dll").
- In order to be able to use the DLL functions, they must be incorporated in the action or function in WinCC at the beginning with the "#pragma code" instruction.
- The Visual Studio version used to create the DLL must be compatible with the version of WinCC in which this DLL is integrated. For example, WinCC V7.0 requires Visual Studio 2005 SP1 to compile the DLL.
2. Incorporate the "T1_C.dll" library in WinCC with C script and execute the "aufruf1" function:
The following WinCC tags were used in the example:
- var1 (signed 32-bit value)
- result (signed 32-bit value)
Create the following C script on the "mouse-click" event of a button:
void OnClick(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName)
#pragma code ("c:/temp/T1_C.dll")
int aufruf1(int a);
#pragma code ()
value = GetTagDouble("var1"); //Return type: double
SetTagDouble("result",aufruf1(value)); //Return type: BOOL
Function call, API
- You have a technical question / problem: Ask the Technical Support
- You want to discuss in our forum and exchange experiences with other users
- You want to create CAx data for one or more products
- You would like to send us feedback on this Entry