How can I determine the name of the computer with a script and write it into a variable?
Implement the following project functions in your WinCC project:
void ComputerName(char* TagName)
#pragma code ("Kernel32.DLL");
BOOL GetComputerNameA(LPSTR Computername, LPDWORD size);
int size=16; //buffersize
The size of the variable "computer[" and "size" depends on the length of the computer name. In this example, the length of the computer name is 15 characters. The total length of 16 characters results from the length of the computer name (15 characters) and the zero at the end of the string (1 character).
These functions can be called up in any actions whenever necessary. The parameter "TagName" represents the variable in which the computer name will be written. This is a variable of the type text variable with a 8-bit character set which needs to be configured manually in the variable container of WinCC as a project wide refreshed variable. If you attach this variable to a IO field in a WinCC server image, the computer name is displayed when calling this image.
This function could be used to recognize a redundancy switch from the master to the standy server from the MultiClient. To achieve this, the computername has to be saved in a local text variable and then be displayed in a I/O field in a server image.
API call, DLL integration, redundancy switch