Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Deleting an INI section

Status
Not open for further replies.

phinoppix

Programmer
Jul 24, 2002
437
0
0
US
The MSDN docu on WritePrivateProfileString states that setting to NULL the value parameter will delete the key. Tried to follow that and it did deleted the key name and value pair, BUT left the equal sign.
Code:
[section1]
key1=value1
=                 'equal sign left!!!
Is that a norm with the function? Or am I missing something?

I used the ffg similar code:
Code:
Dim pvarReturn 
pvarReturn = WritePrivateProfileString("section1","key2",vbNullChar,"C:\TEMP\test.ini")

TIA [peace]
 
Sorry for the late reply. I'm about to try your suggestio, but one question, how does vbNullChar differ from vbNullString?
 
I'm not sure, but I think (comparing with c++):

vbNullChar = Chr$(0)
vbNullString = NULL (but still a string)

The latter is a bit weird, but you could say that it's not Chr$(0), not "", but sort of a null of type string.

Remedy
 
Haven't tried looking what MSDN has to say, but it is indeed awfully weird (or maybe it's just because I don't know anything about C). However, if vbNullChar=Chr(0), I guess I'll be using vbNullString more often with text returning APIs. Although, I've read Chr(0) is more likely useful with communication stuff.

By the way, tnx for help. It worked. [peace]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top