RtAttachShutdownHandler

RtAttachShutdownHandler registers a stop/shutdown notification handler function with RTSS. The handler function is called in its own thread when one of the system stop events occurs.

Syntax

Copy
HANDLE RtAttachShutdownHandler(
    [ignored]  PSECURITY_ATTRIBUTES pThreadAttributes,
    [in]       ULONG Stacksize,
    [in]       VOID (RTFCNDCL *Routine) (PVOID Context, LONG reason),
    [in]       PVOID Context,
    [in]       ULONG Priority
);

Parameters

[ignored] pThreadAttributes

Ignored.

[in] StackSize

The number of bytes to allocate for the handler thread's stack. See CreateThread

[in] Routine

The handler function to call when RTSS delivers the stop notification.

[in] Context

The argument to the handler routine.

[in] Priority

The priority for the created thread.

Return Value

If the function succeeds, it returns a valid handle when a stop handler object has been correctly instantiated. If the function fails, it returns a NULL handle. Call GetLastError to obtain an error code.

Remarks

The function pointed to by Routine is called when Windows shuts down. The source of the stop notification is presented to this function in the reason argument. The reason argument may have one of the following values according to the reason for the notification:

Notification Reason

SHTDN_REASON_WINDOWS_SYSTEM_SHUTDOWN

The system is starting a normal shutdown. Shortly after all shutdown handlers have been executed, Windows will stop.

SHTDN_REASON_WINDOWS_STOP

Windows has stopped (e.g., the blue screen or stop screen). RTSS will continue to operate with service restrictions.

SHTDN_REASON_RTX_SYSTEM_SHUTDOWN

wRTOS Subsystem is going to be stopped (i.e., wRTOS is going to be unloaded). RTSS will continue to operate with service restrictions.

The order in which the shutdown handlers execute dependents on the priority specified when the handler object was created. This priority is simply the RTSS thread priority.

Only one shutdown handler object is permitted per RTSS process. A handler function should not call ExitThread, but should return when finished. When all registered shutdown handlers have returned, the system completes the shutdown sequence.

A shutdown handler object may be destroyed by calling RtReleaseShutdownHandler.

Note: Only those calls that do not interact with the Windows operating system can be made from within the shutdown handler.

Requirements

Minimum supported version Header Library

wRTOS 1.0 SDK

RtssApi.h

Startup.lib

See Also: