先定义 
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 ret As Long
    Dim buff As String
    buff = String(255, 0)
    ret = GetPrivateProfileString("IcoPath", "图标1", "未找到设置项", buff, 255, ".\path.ini")
    Label3.Caption = buff
 
vaul值是路径名
高手帮忙看下哪里有错误  读取出来的一直是默认值“未找到”
ini大概是这个样子[IcoPath]
图标1=xx:\xx\xx.ico

解决方案 »

  1.   

    http://download.csdn.net/detail/veron_04/3057337
      

  2.   

    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 LongDim lResult As Long
    Dim sResult As String * 255
        lResult = GetPrivateProfileString(SectionHeader, Item, "", sResult, 255, App.Path & "\SDB_2.ini")
        GetValue = Left(sResult, InStr(sResult, Chr(0)) - 1)这是我在项目中用的可以正确取到值
      

  3.   

    路径是没有问题的  在form2窗体中用file1.path & "\" & file1.filename得到的