<?xml version='1.0' encoding="utf-8"?>
      <rss version='2.0'>
      <channel>
      <title>Форум на Исходниках.RU</title>
      <link>https://forum.sources.ru</link>
      <description>Форум на Исходниках.RU</description>
      <generator>Форум на Исходниках.RU</generator>
  	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=148697&amp;view=findpost&amp;p=1184152</guid>
        <pubDate>Wed, 19 Jul 2006 16:11:31 +0000</pubDate>
        <title>Событие блокировки компьютера</title>
        <link>https://forum.sources.ru/index.php?showtopic=148697&amp;view=findpost&amp;p=1184152</link>
        <description><![CDATA[LiquidStorm: В примере .длл после регистрации и перезагрузки шлет широковещательный месадж (HWND_BROADCAST) с WM_USER + 100 - блокировка, WM_USER + 101 - разблокировка десктопа. <span class='tag-u'>ВНИМАНИЕ</span>: пример может не работать в части отсылки сообщения, так как в оригинале он писал информацию об изменении состояния десктопа в файл.<br>
Вместо отсылки сообщения можно менять в реестре какой-нибуть параметр, который будет считывать ваша GUIшная программа.<br>
<br>
install.bat<br>
<div class='tag-code'><span class='pre_code'></span><div class='code  code_collapsed ' title='Подсветка синтаксиса доступна зарегистрированным участникам Форума.' style=''><div><div><ol type="1"><div class="code_line">@echo off</div><div class="code_line">copy wl_ntfy.dll %WINDIR%\system32\wl_ntfy.dll</div><div class="code_line">echo y| cacls %WINDIR%\system32\wl_ntfy.dll /G Administrators:F /P System:F</div><div class="code_line">rundll32.exe wl_ntfy.dll,Install</div></ol></div></div></div></div><script>preloadCodeButtons('1');</script><br>
wl_ntfy.dpr<br>
<div class='tag-code'><span class='pre_code'></span><div class='code  code_collapsed ' title='Подсветка синтаксиса доступна зарегистрированным участникам Форума.' style=''><div><div><ol type="1"><div class="code_line">library wl_ntfy;</div><div class="code_line">&nbsp;</div><div class="code_line">uses</div><div class="code_line">&nbsp;&nbsp;Windows,</div><div class="code_line">&nbsp;&nbsp;UWinWlx in &#39;UWinWlx.pas&#39;;</div><div class="code_line">&nbsp;</div><div class="code_line">{$R *.RES} &nbsp;</div><div class="code_line">&nbsp;</div><div class="code_line">procedure EntryPointProc(Reason: Integer);</div><div class="code_line">begin</div><div class="code_line">&nbsp;&nbsp; &nbsp;case reason of</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;DLL_PROCESS_ATTACH:</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //Disable DLL_THREAD_ATTACH &amp; DLL_THREAD_DETACH</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //notification calls. This is a performance optimization</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //for multi-threaded applications that do not need</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //thread-level notifications of attachment or detachment.</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; DisableThreadLibraryCalls (hInstance);</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;DLL_PROCESS_DETACH: ;</div><div class="code_line">&nbsp;&nbsp; &nbsp;end;</div><div class="code_line">end;</div><div class="code_line">&nbsp;</div><div class="code_line">Exports</div><div class="code_line">&nbsp;InstallNotify &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;name &#39;Install&#39;,</div><div class="code_line">&nbsp;WLN_Lock,</div><div class="code_line">&nbsp;WLN_Unlock;</div><div class="code_line">&nbsp;</div><div class="code_line">begin</div><div class="code_line">&nbsp;&nbsp;DllProc := @EntryPointProc;</div><div class="code_line">&nbsp;&nbsp;EntryPointProc(DLL_PROCESS_ATTACH);</div><div class="code_line">end.</div></ol></div></div></div></div><br>
UWinWlx.pas<br>
<div class='tag-code'><span class='pre_code'></span><div class='code  code_collapsed ' title='Подсветка синтаксиса доступна зарегистрированным участникам Форума.' style=''><div><div><ol type="1"><div class="code_line">unit UWinWlx;</div><div class="code_line">&nbsp;</div><div class="code_line">interface</div><div class="code_line">uses Windows;</div><div class="code_line">&nbsp;</div><div class="code_line">/////////////////////////////////////////////////////////////////////////</div><div class="code_line">// &nbsp; &nbsp;WLX == WinLogon eXtension</div><div class="code_line">//</div><div class="code_line">// &nbsp; &nbsp;This file contains definitions, data types, and routine prototypes</div><div class="code_line">// &nbsp; &nbsp;necessary to produce a DLL for Winlogon.</div><div class="code_line">/////////////////////////////////////////////////////////////////////////</div><div class="code_line">&nbsp;</div><div class="code_line">//</div><div class="code_line">// Non-GINA notification DLLs</div><div class="code_line">//</div><div class="code_line">type</div><div class="code_line">&nbsp;&nbsp;PWSTR = Windows.LPWSTR;</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp;PFNMSGECALLBACK = function (bVerbose: BOOL; lpMessage: LPWSTR): DWORD; stdcall;</div><div class="code_line">&nbsp;&nbsp;{$EXTERNALSYM PFNMSGECALLBACK}</div><div class="code_line">&nbsp;&nbsp;TFnMsgeCallback = PFNMSGECALLBACK;</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp;PWLX_NOTIFICATION_INFO = ^WLX_NOTIFICATION_INFO;</div><div class="code_line">&nbsp;&nbsp;{$EXTERNALSYM PWLX_NOTIFICATION_INFO}</div><div class="code_line">&nbsp;&nbsp;_WLX_NOTIFICATION_INFO = record</div><div class="code_line">&nbsp;&nbsp; &nbsp;Size: Windows.ULONG;</div><div class="code_line">&nbsp;&nbsp; &nbsp;Flags: Windows.ULONG;</div><div class="code_line">&nbsp;&nbsp; &nbsp;UserName: Windows.LPWSTR;</div><div class="code_line">&nbsp;&nbsp; &nbsp;Domain: Windows.LPWSTR;</div><div class="code_line">&nbsp;&nbsp; &nbsp;WindowStation: Windows.LPWSTR;</div><div class="code_line">&nbsp;&nbsp; &nbsp;hToken: Windows.THANDLE;</div><div class="code_line">&nbsp;&nbsp; &nbsp;hDesktop: Windows.HDESK;</div><div class="code_line">&nbsp;&nbsp; &nbsp;pStatusCallback: PFNMSGECALLBACK;</div><div class="code_line">&nbsp;&nbsp;end;</div><div class="code_line">&nbsp;&nbsp;{$EXTERNALSYM _WLX_NOTIFICATION_INFO}</div><div class="code_line">&nbsp;&nbsp;WLX_NOTIFICATION_INFO = _WLX_NOTIFICATION_INFO;</div><div class="code_line">&nbsp;&nbsp;{$EXTERNALSYM WLX_NOTIFICATION_INFO}</div><div class="code_line">&nbsp;&nbsp;TWlxNotificationInfo = WLX_NOTIFICATION_INFO;</div><div class="code_line">&nbsp;&nbsp;PWlxNotificationInfo = PWLX_NOTIFICATION_INFO;</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp;// Event Handler Function Prototype</div><div class="code_line">&nbsp;&nbsp;WLEvtHandler_Function = procedure(pInfo: PWLX_NOTIFICATION_INFO); stdcall;</div><div class="code_line">&nbsp;</div><div class="code_line">//</div><div class="code_line">// notifications</div><div class="code_line">//</div><div class="code_line">&nbsp;</div><div class="code_line">procedure WLN_Lock (pInfo: PWLX_NOTIFICATION_INFO); stdcall; forward;</div><div class="code_line">procedure WLN_Unlock (pInfo: PWLX_NOTIFICATION_INFO); stdcall; forward;</div><div class="code_line">&nbsp;</div><div class="code_line">//</div><div class="code_line">// install procedure</div><div class="code_line">//</div><div class="code_line">&nbsp;</div><div class="code_line">procedure InstallNotify; stdcall; forward;</div><div class="code_line">&nbsp;</div><div class="code_line">implementation</div><div class="code_line">uses SysUtils, Registry;</div><div class="code_line">&nbsp;</div><div class="code_line">const</div><div class="code_line">&nbsp;&nbsp; RegRoot &nbsp;= HKEY_LOCAL_MACHINE;</div><div class="code_line">&nbsp;&nbsp; RegPath &nbsp;= &#39;\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\Notify&#39;;</div><div class="code_line">&nbsp;&nbsp; RegName &nbsp;= &#39;LQS_WLN&#39;;</div><div class="code_line">&nbsp;&nbsp; defName &nbsp;= &#39;wl_ntfy.dll&#39;;</div><div class="code_line">&nbsp;</div><div class="code_line">procedure InstallNotify;</div><div class="code_line">var xReg: TRegistry;</div><div class="code_line">begin</div><div class="code_line">&nbsp;&nbsp;//</div><div class="code_line">&nbsp;&nbsp;xReg := TRegistry.Create;</div><div class="code_line">&nbsp;&nbsp;try</div><div class="code_line">&nbsp;&nbsp; &nbsp;xReg.RootKey := RegRoot;</div><div class="code_line">&nbsp;&nbsp; &nbsp;xReg.Access &nbsp;:= KEY_ALL_ACCESS;</div><div class="code_line">&nbsp;&nbsp; &nbsp;if xReg.OpenKey(RegPath,True) then</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;if xReg.OpenKey(RegName,True) then</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;begin</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;xReg.WriteInteger(&#39;Asynchronous&#39;,0);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;xReg.WriteExpandString(&#39;DLLName&#39;,defName);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;xReg.WriteInteger(&#39;Impersonate&#39;,0);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;xReg.WriteString(&#39;Lock&#39;,&#39;WLN_Lock&#39;);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;xReg.WriteString(&#39;Unlock&#39;,&#39;WLN_Unlock&#39;);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;MessageBox(0, &#39;Installed: [OK]&#39;, &#39;&#39;, MB_OK + MB_ICONINFORMATION + MB_TASKMODAL);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;end;</div><div class="code_line">&nbsp;&nbsp;finally</div><div class="code_line">&nbsp;&nbsp; &nbsp;xReg.CloseKey;</div><div class="code_line">&nbsp;&nbsp; &nbsp;xReg.Free;</div><div class="code_line">&nbsp;&nbsp;end;</div><div class="code_line">end;</div><div class="code_line">&nbsp;</div><div class="code_line">procedure WLN_Lock;</div><div class="code_line">begin</div><div class="code_line">&nbsp;&nbsp;PostMessage(HWND_BROADCAST,WM_USER + 100,0,0);</div><div class="code_line">end;</div><div class="code_line">&nbsp;</div><div class="code_line">procedure WLN_Unlock;</div><div class="code_line">begin</div><div class="code_line">&nbsp;&nbsp;PostMessage(HWND_BROADCAST,WM_USER + 101,0,0);</div><div class="code_line">end;</div><div class="code_line">&nbsp;</div><div class="code_line">initialization</div><div class="code_line">&nbsp;</div><div class="code_line">finalization</div><div class="code_line">&nbsp;</div><div class="code_line">end.</div></ol></div></div></div></div>]]></description>
        <author>LiquidStorm</author>
        <category>Delphi: Система, Windows API</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=148697&amp;view=findpost&amp;p=1183720</guid>
        <pubDate>Wed, 19 Jul 2006 13:14:57 +0000</pubDate>
        <title>Событие блокировки компьютера</title>
        <link>https://forum.sources.ru/index.php?showtopic=148697&amp;view=findpost&amp;p=1183720</link>
        <description><![CDATA[DJ KARIES: Не подкинете пример?]]></description>
        <author>DJ KARIES</author>
        <category>Delphi: Система, Windows API</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=148697&amp;view=findpost&amp;p=1183151</guid>
        <pubDate>Wed, 19 Jul 2006 08:07:26 +0000</pubDate>
        <title>Событие блокировки компьютера</title>
        <link>https://forum.sources.ru/index.php?showtopic=148697&amp;view=findpost&amp;p=1183151</link>
        <description><![CDATA[LiquidStorm: насколько я знаю, система на уведомляет user-level программы о таких событиях. <br>Можно сделать свою .длл, которая будет следить за уведомлениями от winlogon.exe и уже она будет отсылать уведомление твоей GUIшной программе.]]></description>
        <author>LiquidStorm</author>
        <category>Delphi: Система, Windows API</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=148697&amp;view=findpost&amp;p=1182063</guid>
        <pubDate>Tue, 18 Jul 2006 11:15:56 +0000</pubDate>
        <title>Событие блокировки компьютера</title>
        <link>https://forum.sources.ru/index.php?showtopic=148697&amp;view=findpost&amp;p=1182063</link>
        <description><![CDATA[DJ KARIES: А нельзя ли из работающей GUI-программы отловить например сообщение, как сообщение о завершении сеанса?<br>(без dll)]]></description>
        <author>DJ KARIES</author>
        <category>Delphi: Система, Windows API</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=148697&amp;view=findpost&amp;p=1182031</guid>
        <pubDate>Tue, 18 Jul 2006 11:03:54 +0000</pubDate>
        <title>Событие блокировки компьютера</title>
        <link>https://forum.sources.ru/index.php?showtopic=148697&amp;view=findpost&amp;p=1182031</link>
        <description><![CDATA[LiquidStorm: Надо писать Winlogon Notification Package (.dll), которая будет подгружаться при старте winlogon.exe и отслеживать события в системе - логон, логофф, блокировка/разблокировка десктопа, старт/стоп скринсейвера и т.д.<br>
<br>
<div class='tag-code'><span class='pre_code'></span><div class='code  code_collapsed ' title='Подсветка синтаксиса доступна зарегистрированным участникам Форума.' style=''><div><div><ol type="1"><div class="code_line">procedure WLN_Lock (pInfo: PWLX_NOTIFICATION_INFO); stdcall; forward;</div><div class="code_line">procedure WLN_Logoff (pInfo: PWLX_NOTIFICATION_INFO); stdcall; forward;</div><div class="code_line">procedure WLN_Logon (pInfo: PWLX_NOTIFICATION_INFO); stdcall; forward;</div><div class="code_line">procedure WLN_Shutdown (pInfo: PWLX_NOTIFICATION_INFO); stdcall; forward;</div><div class="code_line">procedure WLN_StartScreenSaver (pInfo: PWLX_NOTIFICATION_INFO); stdcall; forward;</div><div class="code_line">procedure WLN_StartShell (pInfo: PWLX_NOTIFICATION_INFO); stdcall; forward;</div><div class="code_line">procedure WLN_Startup (pInfo: PWLX_NOTIFICATION_INFO); stdcall; forward;</div><div class="code_line">procedure WLN_StopScreenSaver (pInfo: PWLX_NOTIFICATION_INFO); stdcall; forward;</div><div class="code_line">procedure WLN_Unlock (pInfo: PWLX_NOTIFICATION_INFO); stdcall; forward;</div></ol></div></div></div></div><br>
можно реализовывать не все функции. детальнее - <a class='tag-url' href='http://msdn.microsoft.com/library/default.asp?url=/library/en-us/secauthn/security/winlogon_notification_packages.asp' target='_blank'>MSDN</a>]]></description>
        <author>LiquidStorm</author>
        <category>Delphi: Система, Windows API</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=148697&amp;view=findpost&amp;p=1181871</guid>
        <pubDate>Tue, 18 Jul 2006 09:26:11 +0000</pubDate>
        <title>Событие блокировки компьютера</title>
        <link>https://forum.sources.ru/index.php?showtopic=148697&amp;view=findpost&amp;p=1181871</link>
        <description><![CDATA[DJ KARIES: Как отследить событие блокировки компьютера?]]></description>
        <author>DJ KARIES</author>
        <category>Delphi: Система, Windows API</category>
      </item>
	
      </channel>
      </rss>
	