Shoutbox

[Request] Read, write and delete from/to ini file - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Messenger Plus! for Live Messenger (/forumdisplay.php?fid=4)
+---- Forum: Scripting (/forumdisplay.php?fid=39)
+----- Thread: [Request] Read, write and delete from/to ini file (/showthread.php?tid=83351)

[Request] Read, write and delete from/to ini file by Skarbo on 04-23-2008 at 09:21 AM

This was a bit hard to search for (since ini is a 3 letter word^^), sorry if its a repost.

I found these scripts:
Ini to object: http://mpscripts.net/code.php?id=12
Read INI Files: http://mpscripts.net/code.php?id=23
Text Files Operations: http://mpscripts.net/code.php?id=7
But they dont have all the commands that i need.

I would like a script that has these commands:

ReadIni(path, header, key) -> Returns the key value
WriteIni(path, header, key, value) -> Writes the value beneath the header, creates a new header if it does not already exist.
DeleteIni(path, header) -> Deletes the header, keys and the values
DeleteIni(path, header, key) -> Deletes the key and the value

Or is there an easier way to store simple data?
My data will be used to store game statistics etc.


RE: [Request] Read, write and delete from/to ini file by felipEx on 04-23-2008 at 09:56 AM

try this :)

code:
function DeleteHeader(path, header){
Interop.Call('kernel32', 'WritePrivateProfileSectionW', header.toString(), 0, path )
}

function DeleteKey(path, header, key){
Interop.Call('kernel32', 'WritePrivateProfileStringW', header.toString(), key.toString(), 0, path)
}

function WriteIni(path, header, key, value){
Interop.Call('kernel32', 'WritePrivateProfileStringW', header.toString(), key.toString(), value.toString(), path);
}

function ReadIni(path, header, key, default_value){
    var cRetVal = Interop.Allocate(2 * (256 + 1) );
    var lTmp = Interop.Call('kernel32','GetPrivateProfileStringW', header, key.toString(), default_value.toString(), cRetVal, cRetVal.Size, path);
    return lTmp == 0 ? default_value : cRetVal.ReadString(0);
}



RE: [Request] Read, write and delete from/to ini file by Skarbo on 04-23-2008 at 10:15 AM

Thanks!