by Karthikeyan (187 Submissions)
Category: Windows API Call/Explanation
Compatability: Visual Basic 5.0
Difficulty: Unknown Difficulty
Originally Published: Wed 17th January 2001
Date Added: Mon 8th February 2021
Rating: (1 Votes)
Get a string data from WIN.INI using GetProfileString API
' Read the value "Wallpaper" from under the [Desktop] section of WIN.INI. If an error occurs, the function will return "Error"
Dim wallpaper As String ' receives string read from WIN.INI
Dim slength As Long ' receives length of string read from WIN.INI
Dim buffer As String * 255
' Read the string from WIN.INI
slength = GetProfileString("Desktop", "Wallpaper", "Error", buffer, 255)
wallpaper = Mid(buffer, 1, InStr(buffer, Chr(0)) - 1) ' extract the returned string from the buffer
If wallpaper = "Error" Then
MsgBox "Could not read information from WIN.INI."
Else
MsgBox "Current Wallpaper is " & wallpaper
End If
End
End Sub