Does anyone know how to use GetPrivateProfileStringA correctly?
I'm trying to use this to read in all of the key names of a section in an INI file. All key names in a section will be read if a Null value is passed in for the KeyName (see declaration below)
In my code (upgraded from VB 6), when I make this function call, it does not return the string of key names.
Here is my function declaration:
and here is my code related to the function callCode:Declare Function GetPrivateProfileStringNullKey Lib "kernel32" Alias "GetPrivateProfileStringA" _ (ByVal lpApplicationName As String, ByVal lpKeyName As Integer, ByVal lpDefault As String, ByVal lpReturnedString As String, _ ByVal nSize As Long, ByVal lpFileName As String) As Integer
I've tried just about everything I can think of and nothing works. Nothing ever gets returned. I have a similar call in another function where I'm retrieving the value associated with a particular key. The only difference in that call is that I pass a Key Name instead of Null to the function. That works fine.Code:Dim sKeyNames As New VB6.FixedLengthString(30002) Dim sDefault As New VB6.FixedLengthString(1) Dim nLen As Integer ' Get all key names for a section in file ' Keys names are seperated by Chr(0), ' last key name is followed two Chr(0) characters sDefault.Value = "" nLen = GetPrivateProfileStringNullKey(sSectionName, 0, sDefault.Value, sKeyNames.Value, 30000, sFileName)
Any help in this matter would be greatly appreciated! Thanks!
--Dave




Reply With Quote