Редагувати

Поділитися через


Preventing Logoff or Suspend During a Burn

If proper precautions are not made within an application, it is possible for a user to log off during a burn operation. This leads to the interruption of the burn process, which can result in lost data and possibly render the disc unusable.

To avoid this problem, the application should process the WM_QUERYENDSESSION message which is delivered prior to log off. If the application receives this message while performing a burn operation, return FALSE to cancel the logoff procedure. If the application allows the user to decide whether to continue logging off, a warning should be provided indicating that user will lose data.

Power transitions during the burn process can also create potential problems in the success of a burn activity. Preventing these complications during the burn process requires an application to be aware of when power transitions are about to take place. This is accomplished by enabling the application to process the WM_POWERBROADCAST message. Applications developed for Windows XP or Windows Server 2003 can return BROADCAST_QUERY_DENY in response to PBT_APMQUERYSUSPEND, preventing Suspend during the burn process.

Due to changes in the Power Management Model for Windows Vista and Windows Server 2008, the PBT_APMQUERYSUSPEND event is no longer delivered to applications. Instead the PBT_APMSUSPEND event is delivered, providing two seconds for an application to prepare for the transition.

As a result of these changes, it is recommended that applications call the SetThreadExecutionState function to prevent a system idle time-out which ordinarily results in the transition to Suspend. It is important to remember that calling this function with the appropriate flags set will only prevent system idle, not an in-progress Suspend.

Using IMAPI

SetThreadExecutionState