View Single Post
Old 12-05-2007, 05:22 PM   #5 (permalink)
Hachima
Registered User
 
Join Date: Oct 2004
Posts: 1,757
that seems like a lot of messy hard coding just to grab INI data when there are already working methods to grab the key value pairs. I'd rather just make an INI file class to deal with it. Here is what I'd use in C#. You can probably do a VB equivalent.


Quote:
public class IniFile
{
public string path;

[DllImport("kernel32")]
private static extern long WritePrivateProfileString(string section,
string key, string val, string filePath);
[DllImport("kernel32")]
private static extern int GetPrivateProfileString(string section,
string key, string def, StringBuilder retVal,
int size, string filePath);


public IniFile(string INIPath)
{
path = INIPath;
}

public void IniWriteValue(string Section, string Key, string Value)
{
WritePrivateProfileString(Section, Key, Value, this.path);
}


public string IniReadValue(string Section, string Key)
{
StringBuilder temp = new StringBuilder(255);
int i = GetPrivateProfileString(Section, Key, "", temp,
255, this.path);
return temp.ToString();

}
}

Last edited by Hachima : 12-05-2007 at 05:25 PM.
Hachima is offline   Reply With Quote

 
Uberguilds Network