![]() ![]() If InStr(1, sContents, vbCrLf & KeyName & "=", vbTextCompare)>0 Then SContents = Mid(INIContents, PosSection, PosEndSection - PosSection) INIContents = INIContents & "" & vbCrLf & _Įnd if 'if PosSection>0 Then WriteFile FileName, INIContentsĮnd Sub Function GetINIString(Section, KeyName, Default, FileName)ĭim INIContents, PosSection, PosEndSection, sContents, Value, Found INIContents = INIContents & vbCrLf End If If Right(INIContents, 2) vbCrLf And Len(INIContents)>0 Then Add section data at the end of file contents. NewsContents & Mid(INIContents, PosEndSection)Įlse 'if PosSection>0 Then 'Section Not found. INIContents = Left(INIContents, PosSection-1) & _ NewsContents = Left(NewsContents, Len(NewsContents) - 2)Įnd If 'Combine pre-section, new section And post-section data. NewsContents = NewsContents & KeyName & "=" & ValueĮlse 'remove last vbCrLf - the vbCrLf is at PosEndSection NewsContents = NewsContents & Line & vbCrLf Next If isempty(Found) Then 'key Not found - add it at the end of section If LCase( Left(Line, Len(sKeyName))) = sKeyName Then ![]() ![]() OldsContents = split(OldsContents, vbCrLf) OldsContents = Mid(INIContents, PosSection, PosEndSection - PosSection) If PosEndSection = 0 Then PosEndSection = Len(INIContents)+1 PosEndSection = InStr(PosSection, INIContents, vbCrLf & "[") PosSection = InStr(1, INIContents, "", vbTextCompare) 'Get contents of the INI file As a string Sub WriteINIString(Section, KeyName, Value, FileName)ĭim INIContents, PosSection, PosEndSection 'Sub WriteINIString(Section, KeyName, Value, FileName) 'Function GetINIString(Section, KeyName, Default, FileName) GetINIStringVirtual = GetINIString(Section, KeyName, Default, _ WriteINIString Section, KeyName, Value, _Įnd Sub Function GetINIStringVirtual(Section, KeyName, Default, FileName) Sub WriteINIStringVirtual(Section, KeyName, Value, FileName) ![]() You can also simply create web-based modifications: Wscript.echo GetINIString( "Mail", "MAPI", "-", "win.ini") WriteINIString "Mail", "MAPI", "1", "win.ini" Will not allow you to install an ASP component that would do the INI reading - you can use these VBS functions with Scripting.FileSystemObject. But there is also simeple VBS solution, without external components. You can use some free or comercial components (see our INIFile class). Sometimes you will need read formatted Windows INI files. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |