ini file and dll library question - page 3

 
aaa o in practical is not possible to do with c++ right ?
 
faustf #:
aaa o in practical is not possible to do with c++ right ?
not possible + C/C++ = undefined

:-)
 

till the  end  not do it with dll  with little regret , but  i do it   this function , i gift  at the community ,if someone needs it, at least there is... so they'll say I'm waiting a spoon feed thanks at all


 
 string ReadIniValue(string filename, string section, string key, string defaultValue = "")
{
    bool foundValue1 = false;
    string value = defaultValue;
    int fileHandle = FileOpen(filename, FILE_READ);
    if (fileHandle == INVALID_HANDLE)
    {
        Print("Impossibile aprire il file ", filename);
        return defaultValue;
    }

    
    string line="";
    bool foundValue=False;
    // Ciclo per leggere il file INI linea per linea
    while (!FileIsEnding(fileHandle))
    {
         line = FileReadString(fileHandle);
        if (StringFind(line, "[" + section + "]") != -1)
        {
            // Sezione trovata, leggi le righe successive fino a trovare la chiave
            while (!FileIsEnding(fileHandle))
            {
                 line = FileReadString(fileHandle);
                int keyPos = StringFind(line, key);
                if (keyPos != -1)
                {
                    int equalsPos = StringFind(line, "=", keyPos);
                    if (equalsPos != -1)
                    {
                        // Chiave trovata, estrai il valore
                        value = StringSubstr(line, equalsPos + 1);
                        foundValue = true;
                        break;
                    }
                }
            }
            break;
        }
    }

    FileClose(fileHandle);

    if (!foundValue)
    {
        Print("Valore non trovato per la chiave ", key, " nella sezione ", section);
        return defaultValue;
    }

    return value;
}