Siemens Industry Online Support
Siemens AG
Entry type: FAQ Entry ID: 8301801, Entry date: 04/10/2008

How do you incorporate user-created DLLs in WinCC?

  • Entry
  • Associated product(s)
You want to use the functions of a user-created library in WinCC. In this entry we show how a sample DLL is incorporated in WinCC. At the moment, DLLs created in Visual Basic cannot be incorporated in WinCC at Runtime with VBS.

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:

 Registration required T1_c.zip (17.2 KB)

extern "C" __declspec (dllexport) int aufruf1 (int a);

#include <stdio.h>
#include <windows.h>
FILE *h_test;
FILE *h_trace;
extern "C" __declspec (dllexport) int aufruf1(int a)
h_test= fopen ("C:/temp/test_dll.txt","a");
if (h_test)
fprintf(h_test, "Function 'aufruf1' was called!\n");
fclose (h_test );
return a;


  • 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:

#include "apdefap.h"
void OnClick(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName)
#pragma code ("c:/temp/T1_C.dll")
int aufruf1(int a);
#pragma code ()

int value;
value = GetTagDouble("var1"); //Return type: double
SetTagDouble("result",aufruf1(value)); //Return type: BOOL

3. Result

Fig. 01

Additional Keywords
Function call, API
Security information
In order to protect technical infrastructures, systems, machines and networks against cyber threats, it is necessary to implement – and continuously maintain – a holistic, state-of-the-art IT security concept. Siemens’ products and solutions constitute one element of such a concept. For more information about cyber security, please visit
Rate entry
no rating
Requests and feedback
What do you want to do?
Note: The feedback always relates to the current entry / product. Your message will be forwarded to our technical editors working in the Online Support. In a few days, you will receive a response if your feedback requires one. If we have no further questions, you will not hear from us.