Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help whith Unkown API GetIni... 1

Status
Not open for further replies.

mgonzalez

Programmer
Aug 2, 2000
51
0
0
MX


Hello


I am new working whith API's and I have the to review a aplication that is using them.I have read some documents and couldn't find nothing about a API that is declared:


Declare Function GetIni Lib "Kernel32" Alias "GetPrivateProfileStringA" (ByVallpApplicationName As String, ByVal pKeyName As Any,ByVal lpDefault As String,ByVal lpReturnedString As String,ByVal nsize as Long,ByVal lpFileName As String) As Long

I undestand that is used to manage files but I would like if someones could tell me what is it funcion of GetInI or SetInI or where a could find information about this API's


Thanks
 
This API was declared with an Alias (GetIni). The real API name is GetPrivateProfileString. It is used to read data out of an ini file. Check in any API reference book or on MSDN for GetPrivateProfileString rather than Getini. - Jeff Marler B-)
 
I'm writing an application and made two function to read/write ini files. It's based on the api's mentioned above. Use it if you like..

Remedy

Option Explicit

Private Declare Function WritePrivateProfileString Lib "kernel32.dll" Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As String, ByVal lpString As String, ByVal lpFileName As String) As Long
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

Public Sub WriteINI(FileName As String, Key As String, SubKey As String, Value As String)

Dim liRetval As Long

liRetval = WritePrivateProfileString(Key, SubKey, Value, FileName)
End Sub

Public Function ReadINI(FileName As String, Key As String, SubKey As String, Optional DefaultValue As String) As String

Dim lsRetval As String
Dim liLength As Long
Dim lsDefVal As String

If IsMissing(DefaultValue) Then
lsDefVal = "(not found)"
Else
lsDefVal = DefaultValue
End If

lsRetval = Space$(255)
liLength = GetPrivateProfileString(Key, SubKey, lsDefVal, lsRetval, 255, FileName)
lsRetval = Left(lsRetval, liLength)

ReadINI = lsRetval
End Function

Example:

Dim liTest As Integer

liTest = Val(ReadINI(App.Path & "\test.ini", "main", "testvalue", "10"))

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top