AnsweredAssumed Answered

vrf How can I delete a Key from an INI.file ??? w/ ATTACHMENT THIS TIME

Question asked by VRFuser on Aug 30, 2006
Thanks Paul. I'll see what I can do with that :o)
 
/Alex

  _____  

From: Paul.Fowler@raytheon.co.uk [mailto:Paul.Fowler@raytheon.co.uk]
Sent: den 30 augusti 2006 18:44
To: VRF
Cc: VRF
Subject: Re: [vrf] How can I delete a Key from an INI.file ??? w/ ATTACHMENT THIS TIME



There is a (somewhat dodgy) workaround for this.

You can incorrectly define the function prototype for WritePrivateProfileStringA to set the type of lpString to 'long' - like this:

long __stdcall WritePrivateProfileStringA(const char* lpAppName, const char* lpKeyName, long lpString, const char* lpFilename);

Then pass a 0 as the lpString parameter - this will be interpreted as a NULL. If you pass anything other than 0 you will get a nasty BRB.

To use this in your application you will need to load Kernel32.dll twice into differently named libraries - once with the correct definition file and once with the altered one.
 
If you also wish to be able to delete an entire section, you will need to load Kernel32.dll a THIRD time, this time with the type of lpKeyName set to 'long' as well, like this:

long __stdcall WritePrivateProfileStringA(const char* lpAppName, long lpKeyName, long lpString, const char* lpFilename);

Good luck with it.

Cheers
Paul F.





"Alexander Poulikakos (KI/EAB)" <alexander.poulikakos@ericsson.com>
Document Marked as Unclassified

"Alexander Poulikakos (KI/EAB)" <alexander.poulikakos@ericsson.com>

30/08/2006 15:54
Please respond to
"Alexander Poulikakos (KI/EAB)" <alexander.poulikakos@ericsson.com>


To
VRF <vrf@agilent.com>
cc
Subject
[vrf] How can I delete a Key from an INI.file ??? w/ ATTACHMENT THIS TIME

     




Hi VRF

How can I delete a Key (or section) from an INI-File, by using the
Get/WritePrivateProfileStringA functions from Kernel32?
I have attached an example I made (INI-file.vee).

I found this VisualBasic example on the internet, which explains how to
do it:
=============================================
Private Sub ProfileDeleteItem(sSection As String, sKeyName As String,
sIniFile As String)
 'this call will remove the keyname and its
 'corresponding value from the section sepcified
 'in sSection. This is accomplished by passing
 'vbNullString as the sValue parameter. For example,
 'assuming that an ini file had:
 ' [Colours]
 '  Colour1=Red
 '  Colour2=Blue
 '  Colour3=Green
 '
 'and this sub was called passing "Colour2"
 'as sKeyName, the resulting ini file
 'would contain:
 ' [Colours]
 '  Colour1=Red
 '  Colour3=Green
 
  Call WritePrivateProfileString(sSection, _
                                 sKeyName, _
                                 vbNullString, _
                                 sIniFile)
End Sub
(see entire link here:
http://vbnet.mvps.org/index.html?code/file/pprofilebasic.htm )
=============================================


I just can't make this happen in VEE!?!? How can I make a
"vbNullString"? Someone must have done this before..... HELP!

Regards,
Alex

---
You are currently subscribed to vrf as: Paul.Fowler@raytheon.co.uk
To subscribe please send an email to: "vrf-request@lists.it.agilent.com" with the word subscribe in the message body.
To unsubscribe send a blank email to "leave-vrf@it.lists.it.agilent.com".
To send messages to this mailing list,  email "vrf@agilent.com".  
If you need help with the mailing list send a message to
"owner-vrf@it.lists.it.agilent.com".
Search the "unofficial vrf archive" at "www.oswegosw.com/vrf_archive/".[attachment "INI-file.vee" deleted by Paul Fowler/H9569/RAYTHEONUK]
--- You are currently subscribed to vrf as: alexander.poulikakos@ericsson.com To subscribe please send an email to: "vrf-request@lists.it.agilent.com" with the word subscribe in the message body. To unsubscribe send a blank email to "leave-vrf@it.lists.it.agilent.com". To send messages to this mailing list, email "vrf@agilent.com". If you need help with the mailing list send a message to "owner-vrf@it.lists.it.agilent.com". Search the "unofficial vrf archive" at "www.oswegosw.com/vrf_archive/".
---

To subscribe please send an email to: "vrf-request@lists.it.agilent.com" with the word subscribe in the message body.
To unsubscribe send a blank email to "leave-vrf@it.lists.it.agilent.com".
To send messages to this mailing list, email "vrf@agilent.com".
If you need help with the mailing list send a message to
"owner-vrf@it.lists.it.agilent.com".
Search the "unofficial vrf archive" at "www.oswegosw.com/vrf_archive/".  

Outcomes