1
votes

In python, I'm using win32api to read and write INI settings as and when they are required into specific sections based on IDs.

Once I have finished with the section, I want to be able to delete the entire section from the INI file. How would I go about doing this using the win32api python library?

2

2 Answers

1
votes

My proposal is to use native Python module for handling INI files ConfigParser. Have you tried it already? It has remove_section method that probably will work for you.

1
votes

This is not a Python specific answer, but look into calling WritePrivateProfileString with the lpKeyName parameter set to NULL. With this parameter set to NULL the entire section named in lpAppName, including all entries within the section, is deleted.