//Write to ini file public static long IniWriteValue(string strFileFullPath, string strSectionName, string strItemName, string strDataToWrite) { // If string greater than 254 characters (255th spot is null-terminator), // string will be truncated. if (ChkExist.CheckFileExist(strFileFullPath) == false) { //System.Windows.Forms.MessageBox.Show(strFileFullPath + " file not exist!", "GetPrivateProfile() Error"); return(9999); //Error Code } else { long lngret = 0; lngret = ApiDeclaration.WritePrivateProfileString(strSectionName, strItemName, strDataToWrite, strFileFullPath); return(lngret); } }
//********************************************************************************************************* public static string IniReadValue(string Section, string Key, string strFileFullPath) { // If string greater than 254 characters (255th spot is null-terminator), // string will be truncated. if (ChkExist.CheckFileExist(strFileFullPath) == false) { //System.Windows.Forms.MessageBox.Show(strFileFullPath + " file not exist!", "GetPrivateProfile() Error"); return("error"); //Error Code } else { const int capacity = 1023; StringBuilder temp = new StringBuilder(capacity); int i = ApiDeclaration.GetPrivateProfileString(Section, Key, "error", temp, capacity, strFileFullPath); return(temp.ToString()); } }