
Does anyone haver a working sample of API function GetPrivateProfileString which reads values from ini files
I used this function to get the default printer name.
'This goes into the declarations section ofcourse.
Private Declare Function GetProfileString Lib "kernel32" Alias
"GetProfileStringA" (ByVal lpAppName As String, ByVal lpKeyName As
String, ByVal lpDefault As String, ByVal lpReturnedString As String,
ByVal nSize As Long) As Long
Private Function GetDeviceName() As String
Dim ipos As Integer
Dim sDefaultPrinter As String
Dim lReturnValue As Long
gsProcedureName = "frmReportManager.GetDeviceName"
sDefaultPrinter = String$(128, 0)
'get the default printer info into sDefaultprinter
lReturnValue = GetProfileString("WINDOWS", "DEVICE", "",
sDefaultPrinter, 127)
ipos = InStr(sDefaultPrinter, ",")
GetDeviceName = Left(sDefaultPrinter, ipos - 1)
End Function