PrfQueryProfileInt

Syntax
PrfQueryProfileInt( hini, pszAppName, pszKeyWord, lDefault )

Parameters

 * HINI hini (input)
 * Handle to profile to be searched for data. This may be one of the following:


 * 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 as well.


 * LONG lDefault (input)
 * The value of lDefault is returned if the application/keyword pair cannot be located in the specified profile.

Returns

 * LONG lRC
 * This return value is the result of searching for the application/keyword pair in the specified profile. It may be:

Include Info
or or
 * 1) define INCL_WINSHELLDATA
 * 1) define INCL_WIN
 * 1) define INCL_PM
 * 2) include 

Usage Explanation
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.

Gotchas
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 problem.

Sample Code
static UCHAR szAppName[] = "MyApp"; static UCHAR szKeyName[] = "MyKey"; int main(void) {  HINI hini; LONG lRC; /* 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); return(0); } /* main */
 * 1) define INCL_WINSHELLDATA
 * 2) include 
 * 3) include 