This is m y code::

Private Declare Function WritePrivateProfileString Lib "kernel32" Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As String,[B] ByVal lpKeyName As Any[/B], [B]ByVal lpString As Any[/B], ByVal lpFileName As String) As Long

    Private Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, [B]ByVal lpKeyName As Any[/B], ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Long, ByVal lpFileName As String) As Long

What needs to be done to properly declare the function using vb.net

in your case you can change Any to String. since you wanna read and write to ini files it makes sense since the keyName and the lpString are always strings.

As Any variable type in a Declare statement. This is not supported in Visual Basic .NET. Variables of the As Any type were often used to pass a variable that was either a string or Null; you can replace this Visual Basic 6.0 usage by declaring two forms of the API, one with longs, one with strings.

For example, the GetPrivateProfileString API has a parameter lpKeyName of type As Any:

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
Private Declare Function GetPrivateProfileStringNullKey Lib "kernel32"
   Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String,
      ByVal lpKeyName As Long, ByVal lpDefault As String, ByVal
         lpReturnedString As String, ByVal nSize As Long, ByVal
            lpFileName As String) As Long
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.