Click to See Complete Forum and Search --> : What is the syntax of GetPrivateProfileInt ???? I always get an error on nDefault part...


AndyK
December 3rd, 1999, 11:12 PM
Thank You

lalitha
October 23rd, 2001, 02:01 AM
Hi,

The syntax is :

Public Declare Function GetPrivateProfileInt Lib "kernel32" Alias "GetPrivateProfileIntA" (ByVal lpApplicationName As String, ByVal lpKeyName As String, ByVal nDefault As Long, ByVal lpFileName As String) As Long


where

lpApplicationName = Section name
lpKeyName = keyname
nDefault = default value
lpFileName = .ini file with the path.

Eg. if you have a file Reports.ini as below:

[Reports]
Print=1

and want to retrieve the value of Print, use the command as :

Msgbox GetPrivateProfileInt("Reports", "Print", -1, "c:\temp\Report.ini")

where -1 is teh default value.

Hope this helps you.

Regards,
Lalitha

Cakkie
October 23rd, 2001, 02:10 AM
You are using GetPrivateProfileInt, which means that the value returned is an integer (not VB integer, but long integer, that is a VB Long). Make sure the default value passed is a long, and not a string, if you need strings, use GetPrivateProfileString instead.

Tom Cannaerts
slisse@planetinternet.be

Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning -- Rich Cook