Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

delete entire section from ini file

155 views
Skip to first unread message

Leonard Bosco

unread,
Apr 8, 1999, 3:00:00 AM4/8/99
to
Is there a way I can delete an entire section, including the header,
from an ini file? I can delete all the keys and values by calling
WritePrivateProfileSection and using "" as a parameter, but it leaves
the header. I can also copy the file a line at a time to a temp file,
and not copy the section I want to delete, but this has led to some
weird bugs. Does anyone have any ideas? Thanks.


Jimmy Fike

unread,
Apr 9, 1999, 3:00:00 AM4/9/99
to
pass a chr$(0) or a vbNull instead of "" as the value and that will delete
the key.
pass a chr$(0) or a vbNull instead of "" as the key and that will delete the
section.

in your declaration of the WritePrivateProfileSection, change the "As
String" to "As Any".

Jimmy

Leonard Bosco <ldmfu...@worldnet.att.net> wrote in message
news:370D4B4B...@worldnet.att.net...

Da Man

unread,
Apr 9, 1999, 3:00:00 AM4/9/99
to

Jimmy Fike wrote in message ...

>pass a chr$(0) or a vbNull instead of "" as the value and that will delete
>the key.
>pass a chr$(0) or a vbNull instead of "" as the key and that will delete
the
>section.


Not quite accurate. Try bvNullString instead. vbNull is a special types of
Null, I think used mainly for VBA type stuff. The Chr$(0) would probably
work though, since I think the function would interpret it as a pointer to a
null.

Sometimes I get really confused about the difference between a pointer to a
Null, and a Null pointer. If anyone would care to elaborate on this topic,
Please Do!

Barry L. Wallis

unread,
Apr 10, 1999, 3:00:00 AM4/10/99
to
The following is from a C/C++ perspective. A VB programmer may put a
different spin on the examples, however, the definitions should be the same.

Unless I am misunderstanding your question, the problem stems from
overloading the word "null". In the domain of computer programming the word
"null" can have at least three distinct meanings:

1) An ASCII character represented by a value of 0 (e.g., '\0'). Generally
interpreted as "end of string", at least in C.

2) A special value a pointer can have that indicates it is not pointing to
any memory location (e.g., int* x = 0);

3) A special value a database field can contain to indicate the value it
contains is unknown.


Notes:

N1) A "null string" is a string consisting of a single ASCII "null"
character as defined in 1, above.

N2) A "null pointer" is a pointer as defined in 2, above. A "null pointer"
can never point to a "null string" ( or anything else for that matter).

N3) A "null" generally means a "null" character as defined in 1, above.
However, you need to understand the context to be sure.

Confusing enough?
--

- Barry L. Wallis
- Oceanside, California, USA

Da Man wrote in message ...

Tom Serface

unread,
Apr 16, 1999, 3:00:00 AM4/16/99
to
Why not read in all of the parameters, delete the file, then write it again
sans the offending section. If this is an .ini file for your application
this may be the easiest way. We just decided to move some older
applications over to the registry (from .ini files) so we read the old .ini
file (to get legacy settings) then updated the registry, then wrote a
special key to the registry so we knew we'd done this for the next time. It
worked pretty well.

Tom


Leonard Bosco wrote in message <370D4B4B...@worldnet.att.net>...

Rene Whitworth

unread,
Apr 19, 1999, 3:00:00 AM4/19/99
to
Hi Barry,

Barry L. Wallis <walli...@earthlink.net> schrieb in im Newsbeitrag:
7ennsi$esq$1...@holly.prod.itd.earthlink.net...


> The following is from a C/C++ perspective. A VB programmer may put a
> different spin on the examples, however, the definitions should be the
same.
>
> Unless I am misunderstanding your question, the problem stems from
> overloading the word "null". In the domain of computer programming the
word
> "null" can have at least three distinct meanings:
>
> 1) An ASCII character represented by a value of 0 (e.g., '\0'). Generally
> interpreted as "end of string", at least in C.
>
> 2) A special value a pointer can have that indicates it is not pointing to
> any memory location (e.g., int* x = 0);
>
> 3) A special value a database field can contain to indicate the value it
> contains is unknown.

Sorry, but ... no.
If a database field (at least a jet database field) is NULL it means the
field is not CREATED.
The field defenition exists in the table, but on storing the values for the
record, the field was not filled, and therefore not created.
To make it more clear, a text field can be set to 255 chars.
On saving only 1 char in it, 255 chars are reserved on the HD.
If, on the other hand, you put 0 chars in it (either by putting NULL or not
putting anything at all in it), the field won't exist on the HD.
BTW, this goes for any type of field, not only for text fields :-)

>
>
> Notes:
>
> N1) A "null string" is a string consisting of a single ASCII "null"
> character as defined in 1, above.
>
> N2) A "null pointer" is a pointer as defined in 2, above. A "null pointer"
> can never point to a "null string" ( or anything else for that matter).
>
> N3) A "null" generally means a "null" character as defined in 1, above.
> However, you need to understand the context to be sure.
>
> Confusing enough?
> --
>
> - Barry L. Wallis
> - Oceanside, California, USA
>

--
Hope this helps ...

Rene Whitworth
Whitworth Software Solutions - Germany
http://www.w-s-s.de
Please reply to the newsgroup :-)


0 new messages