Ejemplo n.º 1
0
 /// <summary>
 /// Read Data Value From the Ini File
 /// </summary>
 /// <PARAM name="Section"></PARAM>
 /// <PARAM name="Key"></PARAM>
 /// <PARAM name="Path"></PARAM>
 /// <returns></returns>
 public static bool IniReadValue(string Section,string Key, ref string sValue, ref string Err)
 {
     if (mutex.WaitOne(Ini_Mutex_Timeout))
     {
         string sLiteral = null;
         if (ini == null)
         {
             ini = new Ini(path);
         }
         if (ini.GetPrivateProfileString(Section, Key, ref sLiteral, ref Err))
         {
             string sv = StringFromCSharpLiteral(sLiteral);
             sValue = take_from_partanthesis(sv);
             mutex.ReleaseMutex();
             return true;
         }
         mutex.ReleaseMutex();
         return false;
     }
     else
     {
         MessageBox.Show("ERROR:IniReadValue MUTEX TIMEOUT");
         return false;
     }
 }
Ejemplo n.º 2
0
 public static bool IniWriteValue(string Section, string Key, string sValue, ref string Err)
 {
     if (mutex.WaitOne(Ini_Mutex_Timeout))
     {
         if (ini == null)
         {
             ini = new Ini(path);
         }
         ini.inifile = path;
         //MessageBox.Show("IniWriteValue(Section="+Section+",  Key = " + Key+ ", sValue ="+sValue+", ref string Err)");
         string sLiteralString = ToLiteral(sValue);
         bool breswrite = ini.WritePrivateProfileString(Section, Key, sLiteralString, ref Err);
         mutex.ReleaseMutex();
         return breswrite;
     }
     else
     {
         MessageBox.Show("ERROR:IniWriteValue MUTEX TIMEOUT");
         return false;
     }
 }
Ejemplo n.º 3
0
        //[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);
        /// <summary>
        /// INIFile Constructor.
        /// </summary>
        /// <PARAM name="INIPath"></PARAM>
        /// <summary>
        /// Write Data to the INI File
        /// </summary>
        /// <PARAM name="Section"></PARAM>
        /// Section name
        /// <PARAM name="Key"></PARAM>
        /// Key Name
        /// <PARAM name="Value"></PARAM>
        /// Value Name
        /// 
        public static bool Check_Section_And_Key(string sSection, string Key)
        {
            //MessageBox.Show("IniFile:bool Check_Section_And_Key(string sSection, string Key)");
            //if (mutex == null)
            //{
            //    MessageBox.Show("IniFile:mutex = null");
            //}

            if (mutex.WaitOne(Ini_Mutex_Timeout))
            {
            //                MessageBox.Show("IniFile:bool Check_Section_And_Key(string sSection, string Key) GOT MUTEX");
                bool bRes = false;
                if (ini == null)
                {
                    ini = new Ini(path);
                }
                bRes = ini.Check_Section_And_Key(sSection, Key);
                mutex.ReleaseMutex();
                return bRes;
            }
            else
            {
                MessageBox.Show("ERROR:Check_Section_And_Key MUTEX TIMEOUT");
                return false;
            }
        }