hemenkap Posted April 29, 2003 Posted April 29, 2003 I wanted to write some form level settings in an ini file. i was abel to write them using the writeprivateprofilestring API call but i am unable to use the GetPrivateProfileString to Retrive the written values back. can you help me how to do that? Hemen Kapadia Quote
Leaders dynamic_sysop Posted June 4, 2003 Leaders Posted June 4, 2003 sorry about the delay lol. Imports System.Text '///at top of code page^^^ <DllImport("kernel32.dll")> _ Private Overloads Shared Function WritePrivateProfileString( _ ByVal lpApplicationName As String, _ ByVal lpKeyName As String, _ ByVal lpString As String, _ ByVal lpFileName As String) As Integer End Function <DllImport("kernel32.dll")> _ Private Overloads Shared Function GetPrivateProfileString( _ ByVal lpApplicationName As String, _ ByVal lpKeyName As String, _ ByVal lpDefault As String, _ ByVal lpReturnedString As StringBuilder, _ ByVal nSize As Integer, _ ByVal lpFileName As String) As Integer End Function '/// under the designer generated code area^^^ Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click WritePrivateProfileString("this", "KeyName", "This is the value", "c:\test.ini") Dim str As New StringBuilder(256) Dim l As Integer l = GetPrivateProfileString("this", "KeyName", "Default", str, str.Capacity, "C:\test.ini") MsgBox(str.ToString()) End Sub took a bit of messing about but i got it to run , the basis of it is from a vb6 code on allapi.net, but i modified it all to work in .net Quote
hemenkap Posted June 5, 2003 Author Posted June 5, 2003 hi dyanmic_sysop, thanks a lot for the much needed help. Hemen Kapadia Quote
Recommended Posts