Retreiving data from .ini file.
I'm new to this aspect of .net so be forgiving.
I want to retrieve a database connection string that is stored in an ini file.
This is what I have so far:
<Runtime.InteropServices.DllImport("kernel32", EntryPoint:="GetPrivateProfileStringA")> _
Private Shared Function GetPrivateProfileString(ByVal lpApplicationName As String, ByVal lpKeyName As String, ByVal lpDefault As String, ByVal lpReturnedString As System.Text.StringBuilder, ByVal nSize As Integer, ByVal lpFileName As String) As Integer
End Function
Public Function PGetIniStr(ByVal INIsection As String, ByVal INIKey As String, _
ByVal IniFile As String, Optional ByVal KeyLen As Integer = 128) As String
Dim item As New System.Text.StringBuilder(KeyLen)
Dim ret As Integer
ret = GetPrivateProfileString(INIsection, INIKey, "?", item, KeyLen, IniFile)
PGetIniStr = item.ToString
End Function
sSource = PGetIniStr("Company", "dbPath", strPath & "/ini/default.ini")
:confused:
What exactly am I missing here? Am I missing an argument or is my call wrong? I found this when I started working but I'm still stuck:
http://forums.dev-archive.com/showthread.php?t=153896

