Get data from .ini file?

I must be overlooking something really basic. I'm building a new version of an application that was using .ini files to store various data. But, when Setup installs my new version, I want to switch to using the Registry. I want Setup to read the .ini file data and copy it into the Registry.

Trouble is, I am having no luck finding a way to get VB5 to read from the .ini file! I first tried the GetSetting function, but no luck--just returns an empty string every time. Surely, there must be a way. Ideas, anyone?!
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

JimKirbyAuthor Commented:
I could add a reference to MS Word, and us "system.PrivateProfileString(...)", but that seems to be a bit awkward...
Here are the functions and sample code for reading/writting to INI files:

    Private Declare Function GetPrivateProfileString Lib "kernel32" Alias _
            "GetPrivateProfileStringA" (ByVal lpApplicationName As String, _
            ByVal lpKeyName As Any, ByVal lpDefault As String, _
            ByVal lpReturnedString As String, ByVal nSize As Long, _
            ByVal lpFileName As String) As Long
    Private Declare Function WritePrivateProfileString Lib "kernel32" Alias _
            "WritePrivateProfileStringA" (ByVal lpApplicationName As String, _
            ByVal lpKeyName As Any, ByVal lpString As Any, _
            ByVal lpFileName As String) As Long

'Writting to the INI file:
            RetVal = WritePrivateProfileString(lpAppName$, lpKeyName$, WriteValue$, lpFileName$)

Reading from the INI file:
            RetVal = GetPrivateProfileString(lpAppName$, lpKeyName$, lpDefault$, ReturnValue$, Size&, lpFileName$)

Hope that helps.
If you have any questions, leave me a comment.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
BTW, the lpAppName$ is the section name. ex. Desktop.
The value of the key you read is returned in the ReturnValue$ argument.
JimKirbyAuthor Commented:
This is good stuff! I would never have thought of the API call approach. Microsoft's VB documentation was surely no help at all. Thank you!  jk
You are welcome.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.