我读取一个INI
比如:[a]
b=aaa
c=bbbPrivate 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 LongDim A as String
A=GetPrivateProfileString("a", "b", "", useres, 256, App.Path & "/info.ini")取出来useres为空值,A却能得出字符的长度,为3这是什么问题,找了很久都很找不到?

解决方案 »

  1.   

    Dim str As Long
        Dim A As String
        A = Space(1024)
        str = GetPrivateProfileString(parent, child, "", A, Len(A), App.Path + "\info.ini")
        取出的字符值 = Left(A, str)
      

  2.   

    Dim str As Long
    Dim A As String
    A = Space(1024)
    str = GetPrivateProfileString(a, b, "", A, Len(A), App.Path + "\info.ini")
    取出的字符值 = Left(A, str)修改了一下,不好意思
      

  3.   

    Dim str As Long
    Dim useres As String
    useres = Space(1024)
    str = GetPrivateProfileString(a, b, "", useres, Len(useres), App.Path + "\info.ini")
    取出的字符值 = Left(useres, str)这样呢?应该没问题的,我就是这样写的。再试下,注意变量名
      

  4.   

    Dim FILE_NAME As String
        Dim Str As String
        Dim A as String
        Dim i As Integer
        On Error Resume Next
        FILE_NAME = App.Path + "\info.ini"
        Dim Str1 As String * 50
        Call GetPrivateProfileString("a", "b", "", Str1, 256, FILE_NAME)
        For i = 1 To 50
            If Asc(Mid(Trim(Str1), i, 1)) = 32 Or Asc(Mid(Trim(Str1), i, 1)) = 0 Then
            Else
                Str = Str & Mid(Trim(Str1), i, 1)
            End If
        Next
        A = Trim(Str)   '取出的字符串
      

  5.   

    会不会是Private 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
    这段的问题,但我又不是很清除是什么问题
      

  6.   

    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
    Dim str As String * 255
    Dim A as String
    A=GetPrivateProfileString("a", "b", "", useres, 255, App.Path & "/info.ini")
      

  7.   

    Dim str As String * 255
    Dim A as String
    FileNumber=GetPrivateProfileString("a", "b", "", str, 255, App.Path & "/info.ini")
    useres=str
      

  8.   

    Option Explicit
    Private 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 LongPrivate Sub Form_Load()
    Dim Str1 As String * 50, strlen As Long
        strlen = GetPrivateProfileString("a", "b", "", Str1, 256, "D:\A.ini")
        MsgBox Str1      '后面有多余尾巴
        MsgBox strlen    '返回的实际字符数
        MsgBox Left(Str1, strlen)  '截取实际内容
    End Sub
      

  9.   

    theforever鐨勫簲璇ュ彲浠ヤ簡锛屼笉琛岀殑璇濓紝鍐嶅洖甯