Results 1 to 2 of 2

Thread: [RESOLVED] vb6 to .NET (GetPrivateProfileStringKey, ini files)

  1. #1
    Shurijo
    Guest

    Resolved [RESOLVED] vb6 to .NET (GetPrivateProfileStringKey, ini files)

    Anyone have any idea why this works in VB6, but not in VB.NET?

    I can use the WriteProfileString without any problems (after changing the As Any to As String), but I can't get it to read the .ini file.

    -----------
    Private Declare Function GetPrivateProfileStringKey Lib "kernel32" Alias _
    "GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal _
    lpKeyName As String, ByVal lpDefault As String, ByVal _
    lpReturnedString As String, ByVal nSize As Long, ByVal _
    lpFileName As String) As Long

    Public Sub LoadDefaults()

    Dim sValue As String ' server
    Dim s As Integer
    Dim sSize As Integer

    sValue = " " '50 spaces
    sSize = 50

    Dim iFile As String
    iFile = Application.StartupPath & "\" & Application.ProductName & ".ini"

    'server
    s = GetPrivateProfileStringKey("Settings", "Server", "sd-web", sValue, sSize, iFile)
    tbServer.Text = sValue

    End Sub

    ------------


    thanks,

  2. #2
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    api usage has changed some

    http://www.devx.com/dotnet/discussio...cominterop.asp


    but I would STRONGLY suggest learning and using XML instead as ini has been made obsolete by XML.
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width