在 Service application 如何得知 Server 正在關機 |
尚未結案
|
xBaby
一般會員 發表:1 回覆:15 積分:8 註冊:2002-08-14 發送簡訊給我 |
|
RaynorPao
版主 發表:139 回覆:3622 積分:7025 註冊:2002-08-12 發送簡訊給我 |
引言: 我寫了一個 Service 的程式,可以正常的啟動及停止; 但當該Service 於啟動狀態下將 Server 關機時,就無法關機成功, Service 停止便可以關機。 請問,我要該如何做才能在啟動狀態下關機呢?xBaby 你好: 請參考以下連結文章(BCB 版本的 Service Application)
------
-- 若您已經得到滿意的答覆,請適時結案!! -- -- 欲知前世因,今生受者是;欲知來世果,今生做者是 -- -- 一切有為法,如夢幻泡影,如露亦如電,應作如是觀 -- |
xBaby
一般會員 發表:1 回覆:15 積分:8 註冊:2002-08-14 發送簡訊給我 |
|
pgdennis
資深會員 發表:41 回覆:526 積分:443 註冊:2002-05-23 發送簡訊給我 |
不知這是不是你要的
Detecting Windows Shutdown To detect Windows Shutdown, you must trap WM_EndSession message. These steps should be taken: Declare a message handling procedure in your Form's Private section: procedure WMEndSession(var Msg : TWMEndSession); message WM_ENDSESSION; Add the procedure to the implementation section of your Unit: procedure TForm1.WMEndSession(var Msg : TWMEndSession); begin if Msg.EndSession = TRUE then ShowMessage('Windows is shutting down ' #13 'at ' FormatDateTime('c', Now)); inherited; end; Tip submitted by Steve Harman Detecting Windows shutdown When Windows is shutting down, it sends a WM_QueryEndSession to all open applications. To detect (and prevent shutdown), you must define a message handler to this message. Put this definition on the private section of the main form: procedure WMQueryEndSession(var Msg : TWMQueryEndSession); message WM_QueryEndSession; And put this method in the implementation section of the unit: procedure TForm1.WMQueryEndSession(var Msg : TWMQueryEndSession); begin if MessageDlg('Close Windows ?', mtConfirmation, [mbYes,mbNo], 0) = mrNo then Msg.Result := 0 else Msg.Result := 1; end; http://www.geocities.com/SiliconValley/8055/tips.htm#tip19永遠追不上技術更新的速度~~ 發表人 - pgdennis 於 2003/06/07 17:08:46
------
星期一,二...無窮迴圈@@ |
xBaby
一般會員 發表:1 回覆:15 積分:8 註冊:2002-08-14 發送簡訊給我 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |