PrfReset

PrfReset changes the default profiles being used by the system.

Syntax
PrfReset( hab, pprfProfile )

Parameters

 * HAB hab (input): Handle to an anchor block. This is a return value from WinInitialize.
 * PPRFPROFILE pprfProfile (input):Pointer to a PRFPROFILE structure. This will contain the names of the new profiles to be used. This may contain any valid filename. If a filename isn't fully qualified, it is assumed to reside in the current working directory. If a file doesn't exist, it is created by this API call.

Returns

 * BOOL bRC: This return value is always either:
 * TRUE  Success
 * FALSE Error occurred

If FALSE, you may use WinGetLastError to find out what went wrong. There is only one possible error PrfReset may generate: PMERR_OPENING_INI_FILE 0x1301  Due to an error, the files could not be opened. This may be due to a lack of disk space, or                                something similar.

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

Usage Explanation
The reason for this is to allow applications, such as a login program, to change system defaults to accommodate a new user. The user profile contains settings for various programs, as well as Presentation Manager preferences (color schemes, the desktop, etc.). The system profile contains computer-specific variables. For this reason, PrfReset will only let you change the user profile. When the profiles are changed, PrfReset broadcasts a PL_ALTERED window message to all running applications. This notifies the program that the profiles have been changed, and they should re-read them to get the default values for the new user. (Although there is no guarantee all programs will process this message. DOS, Windows, and Text-based OS/2 programs do not receive this message, either.

Gotchas
First, don't expect all the applications running at any given time to be certain to process a PL_ALTERED message. Second, you must pass the current system profile to this function, since you aren't allowed to change it. Usually it is OS2SYS.INI, but a different filename may be specified in the config.sys. Hence, you must also call PrfQueryProfile twice before PrfReset to get that information. And since you need a handle to an anchor block, this call may only be issued from inside a Presentation Manager program. Third, it has been my experience that the WorkPlace Shell crashes (this is with Warp without Windows and no fixpak, though.) sometimes when it receives the PL_ALTERED message. I've also run out of stack space in this call (although this could be a symptom of the WPS, and not the code). So, to be safe, don't shirk on the stack space. If the WPS crashes, after the standard error message, it will reload without a need to reboot. Fourth, you can SEVERELY frighten the unsuspecting user when all his icons either change or vanish due to this API. Be careful in how you use it, or you might have people reboot/format/reinstall from scratch if they don't know what's going on.