[ Home |
Alpha index |
Topic index |
The OS/2 API Project
[ Syntax |
lRC = PrfQueryProfileInt( hini,
- HINI hini (input)
- Handle to profile to be searched for data. This may be one of the
||Search both the USER and SYSTEM profiles.
||Search only the USER profile.
||Search only the SYSTEM profile.
||Search a program-defined profile. This is a HINI returned by
- PSZ pszAppName (input)
- Pointer to a null-terminated string that holds the application name to
search for within the profile. This string is case-sensitive.
- PSZ pszKeyWord (input)
- Pointer to a null-terminated string that holds the keyword name to
search for within the application name specified. This is case-sensitive
- LONG lDefault (input)
- The value of lDefault is returned if the application/keyword pair cannot be
located in the specified profile.
- LONG lRC
- This return value is the result of searching for the application/keyword
pair in the specified profile. It may be:
||The data associated with the application and keyword is not an integer.
||The last parameter of PrfQueryProfileInt() is returned to you if
the application or keyword could not be found in the profile.
||The value associated with the application/keyword pair is returned.
If lDefault, you may use WinGetLastError() to find out what went wrong.
Possible errors PrfQueryProfileInt() may incur:
||One of the parameters to PrfQueryProfileData() was invalid.
||The application name, keyword, or program handle was not found.
||An error related to the spooler occured. (?)
The one feature that makes PrfQueryProfileInt() useful is how it interprets
data. If you store a long integer as a four byte data type, then you'll have
to use PrfQueryProfileData() to retrieve it. However, PrfQueryProfileInt()
allows you to store an integer as an ASCII string. For example, if the string
"32462" is stored in a profile and PrfQueryProfileInt() is called, it will
convert this string to its binary equivalent for you.
Both the application name and the keyword are CASE SENSITIVE. It is
recommended that all your references to these strings come from a single
source, such as a #define or a global variable, so as not to get tripped up
on this. It is recommended that strings are null-terminated to reduce errors,
but it seems that PrfQueryProfileInt() will just stop reading the string when
it hits a non-numeric character. So, "123xyz" will return 123. The
implication is that comma-delimited strings make this function useless.
For example, "100,000" will return 100. Obviously, floating point numbers get
truncated. Also, the numerics must be the first characters in the string. The
one non-numeric character that seems to be allowed is a '-', to signify a
negative integer. "-123" returns -123. If there's a possibility that you
might pass a zero for the last parameter, or the string should legitimately
return a zero, then you should call WinGetLastError() to see if there was a
static UCHAR szAppName = "MyApp";
static UCHAR szKeyName = "MyKey";
/* I write this string to give you a basis for experimentation... */
PrfWriteProfileString(HINI_USER, szAppName, szKeyName, "-100.10,000x");
* I specified 2 for the last param, as there's no way a two will get
* returned by accident in this experiment.
lRC = PrfQueryProfileInt(HINI_USER, szAppName, szKeyName, 2);
printf("PrfQueryProfileInt returned %d\n", lRC);
} /* main */
Ryan C. Gordon --
Last modified June 13/1996
Please send all errors, comments, and suggestions to:
The OS/2 API Project