共用方式為


set_terminate (CRT)

安裝您自己的終止程序以被 terminate呼叫。

terminate_function set_terminate(
   terminate_function termFunction
);

參數

  • termFunction
    您剛撰寫的終止函式的指標。

傳回值

讓指標回到 set_terminate 註冊的前一個函式,讓先前函式可以還原。 如果先前函式未設定,則傳回值可用來還原預設行為;此值可能為 null。

備註

set_terminate 函式安裝 termFunction 做為 terminate呼叫的函式。 在擲回例外狀況前,set_terminate和C++例外狀況一起使用,並且有可能隨時被呼叫。 terminate calls abort by default. You can change this default by writing your own termination function and calling set_terminate with the name of your function as its argument. terminate calls the last function given as an argument to set_terminate. After performing any desired cleanup tasks, termFunction should exit the program. If it does not exit (if it returns to its caller), abort is called.

In a multithreaded environment, terminate functions are maintained separately for each thread. Each new thread needs to install its own terminate function. Thus, each thread is in charge of its own termination handling.

The terminate_function type is defined in EH.H as a pointer to a user-defined termination function, termFunction that returns void. Your custom function termFunction can take no arguments and should not return to its caller. If it does, abort is called. An exception may not be thrown from within termFunction.

typedef void ( *terminate_function )( );
注意事項注意事項

The set_terminate function only works outside the debugger.

There is a single set_terminate handler for all dynamically linked DLLs or EXEs; even if you call set_terminate your handler may be replaced by another, or you may be replacing a handler set by another DLL or EXE.

This function is not supported under /clr:pure.

需求

常式

必要的標頭

set_terminate

<eh.h>

如需其他相容性資訊,請參閱<簡介>中的相容性

範例

See the example for terminate.

.NET Framework 對等用法

不適用。若要呼叫標準 C 函式,請使用 PInvoke。如需詳細資訊,請參閱平台叫用範例

請參閱

參考

例外狀況處理常式

abort

_get_terminate

set_unexpected (CRT)

terminate (CRT)

unexpected (CRT)