Ini Read and Ini Write
Posted on 2000-03-20
I am trying to get the following two functions to work within VB V5.0.
Right now I am working with the "GetPrivateProfileString", and have no success at it. Yes, I have searched EE under the text 'GetPrivateProfileString' and picked off the second best VB example, and tried to implement that idea into my VB program. And still no success. Currently I am running under Win95-Vers B. I am not into the Registry bit, and that is why I using the INI file. I believe, before I upgraded to Win95-Version B, I was running under Win95-Version A and I was using these two function within a VC++ DLL file that I put together - and it is still working well. I haven't rebuilt the DLL File since my system upgrade. Am I going to run into some trouble with my VC++ DLL functions with Version B?
But any rate, can get a copy of examples of these functions to work. I'll enclose my function code below...
Function GetSysIni(ByVal section As String, ByVal skey As String) As String
Dim retVal As String
Dim defstrg As String
Dim AppName As String
Dim KeyName As String
Dim worked As Long
Dim lnsize As Long
Dim filedir As String
Dim WinPath As String
'' 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
AppName = section
KeyName = skey
WinPath = WindowsDirectory()
filedir = UCase(WinPath & "\" & "System.ini")
retVal = ""
lnsize = 255
defstrg = Chr(0)
' lpApplicationName, lpKeyName, lpDefault, lpRetunedString, nSize, lpFileName)
worked = GetPrivateProfileString(AppName, KeyName, defstrg, retVal, lnsize, filedir)
If worked = 0 Then
GetSysIni = "unknown"
GetSysIni = Left(retVal, InStr(retVal, Chr(0)) - 1)
Are they any drivers that I need to install to make it work??
See what you can do...
Thanks in Advance...