Newsgroup: it.comp.os.win.win9x
Titolo: I file .ini

Ciao tutti
non capisco niente dei file con estensione .ini.Vorrei sapere come sono le
funzioni, il linguaggio ed i comandi che viene usato in questo file. se
potete darmi delucidazioni vi sarò grato.
Grazie
_Shari

 GetProfileString ou WritePrivateProfileString function.
Two free COM objects that uses API to manipulate INI files and that
can be usedfrom a VBScript:
AutoItX
http://www.hiddensoft.com/AutoIt/
- and -
JSSys.dll (Note: Requires VB6 Runtime Files)
A description can be found here:
http://www.jsware.net/jsware/scripts.html
Direct link:
http://www.jsware.net/jsware/zips/jssys2.zip
*************************************************
Without having to register a COM object, just use this two functions, ReadIni
and WriteIni. Note: It is using FSO, so it should not be used against ini files
that can be updated simultaneous by another process.
Example:   (*.vbs) >> 
www.google.it
  "Windows script host"
' -------------------- Code Start -----------------------
sFileName = "c:\data\ExchInst.ini"
sSection = "gfn_mid microsoft exchange 2000"
sKey = "{599AD9B5-707B-4CC1-A4E3-24614A619F2B}"
sData = "MIGRATION\AdminUser"
' update the ini file
WriteIni sFileName, sSection, sKey, sData
' read the data back
sUser = ReadIni(sFileName, sSection, sKey)
WScript.Echo sUser
' ===================================
' ================= FUNCTIONS & SUBS
' ===================================
'~~Author~~. ANTOINE Jean-Luc
'*** Modified by Torgeir Bakken 2001.06.26
'~~Script~~.
' READINI ( file, section, item )
' file = path and name of ini file
' section = [Section] must not be in brackets
' item = the variable to read
Function ReadIni(file, section, item)
  Set oFSO  = CreateObject("Scripting.FileSystemObject")
  ReadIni = ""
  file = Trim(file)
  item = Trim(item)
  If oFSO.FileExists( file ) Then
    Set ini = oFSO.OpenTextFile( file, 1, False)
    Do While ini.AtEndOfStream = False
      line = ini.ReadLine
      line = Trim(line)
      If LCase(line) = "[" & LCase(section) & "]" Then
        line = ini.ReadLine
        line = Trim(line)
        Do While Left( line, 1) <> "["
          'If InStr( 1, line, item & "=", 1) = 1 Then
          equalpos = InStr(1, line, "=", 1 )
          If equalpos > 0 Then
            leftstring = Left(line, equalpos - 1 )
            leftstring = Trim(leftstring)
            If LCase(leftstring) = LCase(item) Then
              ReadIni = Mid( line, equalpos + 1 )
              ReadIni = Trim(ReadIni)
              Exit Do
            End If
          End If
          If ini.AtEndOfStream Then Exit Do
          line = ini.ReadLine
          line = Trim(line)
        Loop
        Exit Do
      End If
    Loop
    ini.Close
  End If
End Function
' WRITEINI ( file, section, item, myvalue )
' file = path and name of ini file
' section = [Section] must not be in brackets
' item = the variable to write;
' myvalue = the myvalue to assign to the item.
'
Sub WriteIni( file, section, item, myvalue )
  Set oFSO  = CreateObject("Scripting.FileSystemObject")
  path = Mid( file, 1, InStrRev( file, "\" ) )
  ' Check if path to file exists, quit if not so
  If Not oFSO.FolderExists ( path ) Then
    MsgBox "Error: WriteIni failed, folder path to ini file " _
            & file & " not found!"
    Wscript.Quit
  End If
  in_section = False
  section_exists = False
  item_exists = ( ReadIni( file, section, item ) <> "" )
  wrote = False
  file = Trim(file)
  itemtrimmed = Trim(item)
  myvalue = Trim(myvalue)
  Set read_ini = oFSO.OpenTextFile( file, 1, True, TristateFalse )
  Set write_ini = oFSO.CreateTextFile( path & "temp_ini.ini", False)
  While read_ini.AtEndOfStream = False
    line = read_ini.ReadLine
    linetrimmed = Trim(line)
    If wrote = False Then
      If LCase(line) = "[" & LCase(section) & "]" Then
        section_exists = True
        in_section = True
        ElseIf InStr( line, "[" ) = 1 Then
          in_section = False
        End If
    End If
    If in_section Then
      If item_exists = False Then
        write_ini.WriteLine line
        write_ini.WriteLine item & "=" & myvalue
        wrote = True
        in_section = False
      Else
        equalpos = InStr(1, line, "=", 1 )
        If equalpos > 0 Then
          leftstring = Left(line, equalpos - 1 )
          leftstring = Trim(leftstring)
          If LCase(leftstring) = LCase(item) Then
            write_ini.WriteLine itemtrimmed & "=" & myvalue
            wrote = True
            in_section = False
          End If
        End If
        If Not wrote Then
          write_ini.WriteLine line
        End If
      End If
    Else
      write_ini.WriteLine line
    End If
  Wend
  If section_exists = False Then ' section doesn't exist
    write_ini.WriteLine
    write_ini.WriteLine "[" & section & "]"
    write_ini.WriteLine itemtrimmed & "=" & myvalue
  End If
  read_ini.Close
  write_ini.Close
  oFSO.DeleteFile file
  oFSO.MoveFile path & "temp_ini.ini", file
End Sub
' -------------------- Code Stop -----------------------
--
Fosco