第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機(jī)立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

以編程方式確定鎖定工作站的持續(xù)時間?

以編程方式確定鎖定工作站的持續(xù)時間?

縹緲止盈 2019-08-16 14:40:30
以編程方式確定鎖定工作站的持續(xù)時間?如何在代碼中確定機(jī)器鎖定的時間?C#之外的其他想法也是受歡迎的。我喜歡Windows服務(wù)理念(并已接受它)以簡化和清潔,但遺憾的是我不認(rèn)為它在這種特殊情況下對我有用。我想在我的工作站上運行這個,而不是在家里(或者除了家庭之外,我想),但它被國防部嚴(yán)格控制了。實際上,這就是我自己滾動的部分原因。無論如何我會寫下來看看它是否有效。感謝大家!
查看完整描述

3 回答

?
湖上湖

TA貢獻(xiàn)2003條經(jīng)驗 獲得超2個贊

我之前沒有找到過這個,但是從任何應(yīng)用程序都可以連接SessionSwitchEventHandler。顯然你的應(yīng)用程序需要運行,但只要它是:

Microsoft.Win32.SystemEvents.SessionSwitch += new Microsoft.Win32.SessionSwitchEventHandler(SystemEvents_SessionSwitch);void SystemEvents_SessionSwitch(object sender, Microsoft.Win32.SessionSwitchEventArgs e){
    if (e.Reason == SessionSwitchReason.SessionLock)
    { 
        //I left my desk
    }
    else if (e.Reason == SessionSwitchReason.SessionUnlock)
    { 
        //I returned to my desk
    }}


查看完整回答
反對 回復(fù) 2019-08-16
?
阿波羅的戰(zhàn)車

TA貢獻(xiàn)1862條經(jīng)驗 獲得超6個贊

我將創(chuàng)建一個處理OnSessionChange事件的Windows服務(wù)(visual studio 2005項目類型),如下所示:

protected override void OnSessionChange(SessionChangeDescription changeDescription){
    if (changeDescription.Reason == SessionChangeReason.SessionLock)
    { 
        //I left my desk
    }
    else if (changeDescription.Reason == SessionChangeReason.SessionUnlock)
    { 
        //I returned to my desk
    }}

您在此時記錄活動的內(nèi)容和方式取決于您,但Windows服務(wù)可以快速方便地訪問Windows事件,如啟動,關(guān)閉,登錄/退出以及鎖定和解鎖事件。


查看完整回答
反對 回復(fù) 2019-08-16
?
HUH函數(shù)

TA貢獻(xiàn)1836條經(jīng)驗 獲得超4個贊

下面的解決方案使用Win32 API。在工作站被鎖定時調(diào)用OnSessionLock,并在解鎖時調(diào)用OnSessionUnlock。

[DllImport("wtsapi32.dll")]private static extern bool WTSRegisterSessionNotification(IntPtr hWnd,int dwFlags);[DllImport("wtsapi32.dll")]private static extern bool WTSUnRegisterSessionNotification(IntPtrhWnd);private const int NotifyForThisSession = 0; // This session onlyprivate const int SessionChangeMessage = 0x02B1;private const int SessionLockParam = 0x7;private const int SessionUnlockParam = 0x8;protected override void WndProc(ref Message m){
    // check for session change notifications
    if (m.Msg == SessionChangeMessage)
    {
        if (m.WParam.ToInt32() == SessionLockParam)
            OnSessionLock(); // Do something when locked
        else if (m.WParam.ToInt32() == SessionUnlockParam)
            OnSessionUnlock(); // Do something when unlocked
    }

    base.WndProc(ref m);
    return;}void OnSessionLock() {
    Debug.WriteLine("Locked...");}void OnSessionUnlock() {
    Debug.WriteLine("Unlocked...");}private void Form1Load(object sender, EventArgs e){
    WTSRegisterSessionNotification(this.Handle, NotifyForThisSession);}
    // and then when we are done, we should unregister for the notification
    //  WTSUnRegisterSessionNotification(this.Handle);


查看完整回答
反對 回復(fù) 2019-08-16
  • 3 回答
  • 0 關(guān)注
  • 812 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號