zoukankan      html  css  js  c++  java
  • [转]VB 读写ini 配置文件

    转自 百度知道

    C# 读写 ini配置文件 点此链接

    'API 声明
    Public Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Long, ByVal lpFileName As String) As Long
    Public Declare Function WritePrivateProfileString Lib "kernel32" Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpString As Any, ByVal lpFileName As String) As Long
    '声明结束

    Public Function WriteToIni(ByVal FileName As String, ByVal Section As String, ByVal Key As String, ByVal Value As String) As Boolean
    Dim buff As String * 128
    buff = Value + Chr(0)
    WriteToIni = IIf(WritePrivateProfileString(Section, Key, buff, FileName) = 1, True, False)
    End Function
    '写入(Section不带中括号),Value是写入值(最好先CStr成String),返回“True”写入成功,反之失败

    Public Function ReadFromIni(ByVal FileName As String, ByVal Section As String, ByVal Key As String) As String
    Dim I As Long
    Dim buff As String * 128
    If GetPrivateProfileString(Section, Key, "", buff, 128, FileName) = 0 Then ReadFromIni = "": Exit Function
    I = InStr(buff, Chr(0))
    ReadFromIni = Trim(Left(buff, I - 1))
    End Function
  • 相关阅读:
    Codeforces 424C(异或)
    CodeForces
    Codeforces 424A (思维题)
    HDU 1197 Specialized Four-Digit Numbers
    ZOJ 2301 Color the Ball 线段树(区间更新+离散化)
    HDU 1106 排序
    Codefroces 831B Keyboard Layouts
    POJ 1082 Calendar Game
    HDU 多校联合 6045
    HDU 5976 Detachment
  • 原文地址:https://www.cnblogs.com/z5337/p/3689308.html
Copyright © 2011-2022 走看看