VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



INI Read and INI Write Simple and Error Free

by Jeffrey C. Tatum (5 Submissions)
Category: Files/File Controls/Input/Output
Compatability: Visual Basic 3.0
Difficulty: Beginner
Date Added: Wed 3rd February 2021
Rating: (6 Votes)

INI Read and INI Write made simple. I included examples in each function. If you like my codes, then please vote for me. But only if you like them. Thanks =)

API Declarations
'INI Read and Write
Declare Function GetPrivateProfileString Lib "kernel32" _
Alias "GetPrivateProfileStringA" (ByVal lpApplicationName _
As String, lpKeyName As Any, ByVal lpDefault As String, _
ByVal lpRetunedString As String, ByVal nSize As Long, _
ByVal lpFilename As String) As Long
Declare Function WritePrivateProfileString Lib "kernel32" _
Alias "WritePrivateProfileStringA" (ByVal lpApplicationName _
As String, ByVal lpKeyName As Any, ByVal lpString As Any, _
ByVal lplFileName As String) As Long

Rate INI Read and INI Write Simple and Error Free

Public Function INIRead(iAppName As String, iKeyName As String, iFileName As String) As String
'Example:
  'x = INIRead("boot", "shell", "C:\WINDOWS\system.ini")
  Dim iStr As String
  iStr = String(255, Chr(0))
  INIRead = Left(iStr, GetPrivateProfileString(iAppName, ByVal iKeyName, "", iStr, Len(iStr), iFileName))
End Function
Public Function INIWrite(iAppName As String, iKeyName As String, iKeyString As String, iFileName As String)
'Example:
  'x = INIWrite("boot", "shell", "Explorer.exe", "C:\WINDOWS\system.ini")
r% = WritePrivateProfileString(iAppName, iKeyName, iKeyString, iFileName)
End Function

Download this snippet    Add to My Saved Code

INI Read and INI Write Simple and Error Free Comments

No comments have been posted about INI Read and INI Write Simple and Error Free. Why not be the first to post a comment about INI Read and INI Write Simple and Error Free.

Post your comment

Subject:
Message:
0/1000 characters