Kkula
Browse Questions » SIMATIC WinCC: Manage .ini files

About User

Questions Asked: 37.9K

Answers Given: 32

0
  • Open

SIMATIC WinCC: Manage .ini files

Is it possible to read/write .ini files via a C script?
I was thinking that the windows.h functions was included, but if I use for example the function
GetPrivateProfileInt the compiler tells that is not a function.

0 Likes 0 Favourites 0 Followers 0 Comments
Answers(1)

Reading/Writing .INI Files with C Scripts

Yes, it's possible to read and write .INI files using C scripts on Windows, but requires linking with the appropriate library.

The functions like GetPrivateProfileInt, GetPrivateProfileString, WritePrivateProfileString, etc., are part of the Windows API and reside in the kernel32.lib library.

The error "is not a function" indicates that you haven't linked against kernel32.lib during compilation.

Solution: You need to explicitly link kernel32.lib to your C project. How you do this depends on your compiler/IDE:

  • Visual Studio: Project Properties -> Linker -> Input -> Additional Dependencies. Add kernel32.lib
  • GCC (MinGW): Use the -lkernel32 linker flag during compilation (e.g., gcc your_file.c -o your_program -lkernel32).

For more detailed information on Windows API INI file functions, refer to the official Microsoft documentation:

Microsoft INI File Documentation

SiePortal Knowledge Article: Reading and writing INI files from a WinCC script (While WinCC specific, provides useful context on INI file handling in Windows)

0