zoukankan      html  css  js  c++  java
  • 用FileSystemObject对象读取INI 文件 支持 VB读INI VBS读INI ASP 读INI

    '作者:CSDN 许仙
    'Homepage : jjweb.126.com
    'MSN :Coderxu#hotmail.com
    'QQ:19030300
    '转载请保持文章完整,保存以上作者信息 请珍惜他人劳动成果


    由于卡巴斯基 太厉害 弄的 OFFCIE编写的程序 调用API读取配置文件都不可以 于是 想到了用FileSystemObject对象读取INI 文件 代码如下, 修改了一下, 同时 支持了 VBS 当然 也支持ASP 网页读配置文件了....


    VB代码
    Public Function GetIni1(ByVal strPrimary As String, ByVal strSubKey As String, ByVal strIniFilePath As String) As String
        Dim myFso As FileSystemObject
        Dim MyFile As TextStream

        Dim intCount As Integer, strState As String
        Set myFso = New FileSystemObject
        Set MyFile = myFso.OpenTextFile(strIniFilePath, 1, False, False)
        With MyFile
            Do Until .AtEndOfStream
                If intCount = 0 Then
                    If .ReadLine = "[" & strPrimary & "]" Then
                        intCount = 1
                    End If
                Else
                    strState = .ReadLine
                    If UCase(Left(strState, Len(strSubKey & "="))) = UCase(strSubKey & "=") Then
                        GetIni1 = Right(strState, Len(strState) - Len(strSubKey & "="))
                    End If
                End If
            Loop
            .Close
        End With
        Set MyFile = Nothing
        Set myFso = Nothing
    End Function

    VBS 代码

    '将以下信息 拷贝到文本里 改名.vbs运行查看效果
    msgbox GetIni ("boot loader","timeout","c:\boot.ini")

    'VBS读取  INI 配置文件

    Function GetIni( strPrimary  ,  strSubKey,  strIniFilePath )
        Dim myFso
        Dim MyFile
        Dim intCount , strState
        Set myFso =  CreateObject("Scripting.FileSystemObject")

        Set MyFile = myFso.OpenTextFile(strIniFilePath, 1, False, False)
        With MyFile
            Do Until .AtEndOfStream
                If intCount = 0 Then
                    If .ReadLine = "[" & strPrimary & "]" Then
                        intCount = 1
                    End If
                Else
                    strState = .ReadLine
                    If UCase(Left(strState, Len(strSubKey & "="))) = UCase(strSubKey & "=") Then
                        GetIni = Right(strState, Len(strState) - Len(strSubKey & "="))
                    End If
                End If
            Loop
            .Close
        End With
        Set MyFile = Nothing
        Set myFso = Nothing
    End Function


    本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/hot1kang1/archive/2006/07/04/875861.aspx

  • 相关阅读:
    图像的加载与保存
    numpy初学
    深入精通JavaScript插件
    Python图像处理库:Pillow 初级教程
    PIL包的应用
    UIWebView的离线缓存
    UITableView优化技巧
    UIKit Dynamics入门
    CALayer 一些重要属性
    一个Demo展示Storyboard的强大
  • 原文地址:https://www.cnblogs.com/ryhan/p/2036529.html
Copyright © 2011-2022 走看看