Does anyone haver a working sample of API function GetPrivateProfileString which reads values from ini files 
Author Message
 Does anyone haver a working sample of API function GetPrivateProfileString which reads values from ini files



yes

Public Function VBGetPrivateProfileString(ByVal iFilename As String,
ByVal iSection As String, ByVal iKey As String) As String
' **************************************************************
' Description:    VB wrapper for GetPrivateProfileString API call
'
' Parameters:
'     input:
'        iFilename:  name of the .ini file
'        iSection:   section in the .ini file
'        iKey:       key in the section
'
'     output:
'        (none)
'
' Return value:   the string for the specified entry or an empty
'                    string if the entry is not found
'
' Comments:    input parameters should not be empty or null strings
' **************************************************************
   Dim lngTemp As Long

   VBGetPrivateProfileString = String$(256, 0)
   lngTemp = GetPrivateProfileString( _
               lpApplicationName:=iSection, _
               lpKeyName:=iKey, _
               lpDefault:="", _
               lpReturnedString:=VBGetPrivateProfileString, _
               nSize:=257, _
               lpFileName:=iFilename)
   VBGetPrivateProfileString = Left$(VBGetPrivateProfileString,
lngTemp)

End Function

--
Paul Marshall



Sat, 03 Feb 2001 03:00:00 GMT  
 Does anyone haver a working sample of API function GetPrivateProfileString which reads values from ini files
I used this function to get the default printer name.

'This goes into the declarations section ofcourse.

Private Declare Function GetProfileString Lib "kernel32" Alias
"GetProfileStringA" (ByVal lpAppName As String, ByVal lpKeyName As
String, ByVal lpDefault As String, ByVal lpReturnedString As String,
ByVal nSize As Long) As Long

Private Function GetDeviceName() As String
Dim ipos                    As Integer
Dim sDefaultPrinter         As String
Dim lReturnValue            As Long

gsProcedureName = "frmReportManager.GetDeviceName"

sDefaultPrinter = String$(128, 0)

'get the default printer info into sDefaultprinter

lReturnValue = GetProfileString("WINDOWS", "DEVICE", "",
sDefaultPrinter, 127)
ipos = InStr(sDefaultPrinter, ",")
GetDeviceName = Left(sDefaultPrinter, ipos - 1)
End Function



Sat, 03 Feb 2001 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Does anyone haver a working sample of API function GetPrivateProfileString which reads values from ini files

2. function GetPrivateProfileString did not work....

3. Can't get GetPrivateProfileString API to work

4. API GetPrivateProfileString and WritePrivateProfileString don't work.

5. Problem with Win API function GetPrivateProfileString.

6. Problem with Win API function GetPrivateProfileString.

7. Need a working VB sample of Status Bar API

8. VB Samples, APIs, Functions, Source-Codes,...

9. Sample code for using named pipe API functions?

10. Anyone worked with CommInput and CommOutput Functions?

11. Does anyone know how to call the Run API function

12. Can anyone send Sleep API function implimentation code in VB

 

 
Powered by phpBB® Forum Software