0

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

3
Contributors
2
Replies
7
Views
8 Years
Discussion Span
Last Post by __avd
0

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.

0

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
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.