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

  • 相关阅读:
    虚拟机安装CentOS不能联网的解决
    64位openSUSE12.3最完整的安装QQ的方法
    打水井
    一个阶乘中末尾零的个数
    DiscuzX开发手册【精品】
    一个获取PHP消耗时间的小函数
    php获取本月的第一天与最后一天
    在博客园创建了一个自己的博客~
    ie6 fixed 很纠结~这个js就解决了
    现在各个网站都在使用瀑布流布局吧~
  • 原文地址:https://www.cnblogs.com/ryhan/p/2036529.html
Copyright © 2011-2022 走看看