程序中怎样调用系统屏保API?或在NT中如何锁定屏保.发送Control+Alt+Del 组合消息??(200分)

  • 主题发起人 主题发起人 Zyee
  • 开始时间 开始时间
Z

Zyee

Unregistered / Unconfirmed
GUEST, unregistred user!
请教诸位高手。<br>有谁熟悉系统屏保API调用,以及怎样发送诸如 Control+Alt+Del 组合消息??<br>弹出系统屏保或锁定对话框,等待用户输入密码<br>
 
&lt;marquee&gt;&lt;font color="blue"&gt;&lt;strong&gt;我也想知道!&lt;/strong&gt;&lt;/font&gt;&lt;/marquee&gt;
 
&lt;a href onmouseover="alert('以前好象有讨论?!')"&gt;请把鼠标停在这里,看信息。&lt;/a&gt; &nbsp;<br>
 
我的意思是当一个应用程序在长时间运行时,可能期间系统将弹出屏保,此种情况下,通过<br>发送相应消息,使系统弹出屏保密码输入框. &nbsp;在NT 中,从屏幕锁定到密码输入对话框之间<br>的切换消息 Control+Alt+Del 不知如何生成,发送,请指点。。<br>
 
怎么没有人发言,大家难道没有碰到过类似问题?<br>有何解决方案
 
假如在系统屏保启动时,后台程序再运行启动一个别的屏保程序,那当前系统屏保是否<br>会被覆盖?
 
只知道如何把已运行的屏保k掉<br>msdn中copy过来的<br>How to Force a ScreenSaver to Close Once Started in Windows NT<br>Last reviewed: April 11, 1996<br>Article ID: Q140723 &nbsp;<br>The information in this article applies to: <br>Microsoft Win32 Application Programming Interface (API) included with Microsoft Windows NT versions 3.1, 3.5, 3.51 <br><br><br>SUMMARY<br>Sometimes applications need to terminate a screensaver that is already running. In Windows 3.1 or Windows 95, a screensaver could be terminated easily by posting a WM_CLOSE message to the currently active screensaver window as in this example: <br><br><br>&nbsp; &nbsp; PostMessage (GetActiveWindow(), WM_CLOSE, 0, 0L);<br><br><br>Windows NT, however, introduces the concept of separate desktops, so that applications can run on one, and screen savers can run on another. This makes screensaver termination under Windows NT a bit more difficult. <br><br><br>MORE INFORMATION<br>Under Windows NT, obtaining a handle to the currently active screensaver window is not as straightforward as it is in Windows 3.1 and Windows 95. Calling GetForegroundWindow() returns NULL because the screensaver is running on a different desktop than the calling application. Similarly, calling FindWindow ("WindowsScreenSaverClass", NULL) to determine if the screen saver is currently active won't work either. <br><br>The way to do it is to get a handle to the screen saver's desktop, enumerate that desktop's windows, and then post a WM_CLOSE to the screen saver window. <br><br>The following code demonstrates how to do this. Note that if a screen saver password is set, the following code brings up the password dialog box, prompts the user for a password, and then actually terminating the screen saver application. <br><br><br>&nbsp; &nbsp;BOOL CALLBACK KillScreenSaverFunc(HWND hwnd, LPARAM lParam)<br>&nbsp; &nbsp;{<br>&nbsp; &nbsp; &nbsp; PostMessage(hwnd, WM_CLOSE, 0, 0);<br>&nbsp; &nbsp; &nbsp; return TRUE;<br>&nbsp; &nbsp;}<br><br>&nbsp; &nbsp;HDESK hdesk;<br><br>&nbsp; &nbsp;hdesk = OpenDesktop(TEXT("Screen-saver"),<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;0,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;FALSE,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;DESKTOP_READOBJECTS | DESKTOP_WRITEOBJECTS);<br>&nbsp; &nbsp;if (hdesk)<br>&nbsp; &nbsp;{<br>&nbsp; &nbsp; &nbsp; EnumDesktopWindows(hdesk, KillScreenSaverFunc, 0);<br>&nbsp; &nbsp; &nbsp; CloseDesktop(hdesk);<br>&nbsp; &nbsp;}<br><br><br>Note that terminating a screensaver that is already running as demonstrated above is totally separate from disabling the screen saver altogether, so that no screen saver starts after the designated time period expires. This can be done easily using: <br><br>&nbsp; &nbsp;SystemParametersInfo( SPI_SETSCREENSAVEACTIVE,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;FALSE,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;0,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;SPIF_SENDWININICHANGE<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;);<br><br><br>This method works well for terminating the currently running screen saver. However, one problem that you might encounter is that the system will not restart the screen saver unless the user moves the mouse or presses a key. If you need the screen saver to start up again, you'll need to reinitialize the time-out period. Do this by: <br>Calling SystemParametersInfo( SPI_SETSCREENSAVEACTIVE, TRUE, 0, SPIF_SENDWININICHANGE). <br>-or- <br><br>Using SetCursorPos() to simulate user input. <br><br>Both of these methods will cause the system to restart the time-out counter for the screen saver. <br>&nbsp;<br><br><br>--------------------------------------------------------------------------------<br><br>Additional reference words: 3.10 3.50 deactivate disable stop running<br>turn off<br>KBCategory: kbgraphic kbhowto kbcode<br>KBSubcategory: GdiScrSav<br><br><br>THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY. <br>&nbsp;<br><br>
 
即使屏保已经去除,一般的话在 NT 中机器也已经被锁定,那又如何发送Ctrl+Alt+Del消息,<br>弹出"解除计算机锁定“安全对话框呢? 等待用户输入密码。
 
等也是要用户输入密码的呀, 还不如让用户自己输入ctrl+alt+del呢 ^_^
 
可以在程序中模拟用户键盘输入呀
 
这是我在Ex-Ex看到的一段代码 &nbsp;<br><br>var <br>HDesk_WL: HDESK; <br>begin <br>HDesk_WL := OpenDesktop ('Winlogon', 0, False, DESKTOP_JOURNALPLAYBACK); <br>if (HDesk_WL &lt;&gt; 0) then <br>begin <br>{we have open the Winlogon Desktop so assign it to our thread} <br>if (SetThreadDesktop (HDesk_WL) = True) then <br>begin <br>// Winlogon uses hotkeys to trap Ctrl-Alt-Del... <br>PostMessage(HWND_BROADCAST, WM_HOTKEY, 0, MAKELONG (MOD_ALT or MOD_CONTROL, VK_DELETE)); <br>
 
//可以在程序中模拟用户键盘输入呀<br>可以模拟输入,不过好象没有反应,有人试过
 
&lt;p&gt;&lt;font size="2" color="#FF0000"&gt;可以用html呀&lt;/font&gt;&lt;/p&gt;<br>
 
是的,光在应用程序中模拟输入按键 Alt-Ctrl-Del 是没有反应的。<br>请问VoodoBoy: '可以用html呀'怎么个说法?<br>不过我倒有个想法,编写一个带密码保护的ScreenSaver, 不用管令人讨厌<br>Alt-Ctr-Del的处理。<br>
 
Zyee:如果你还要继续讨论请定期提前你的帖子,如果不想继续讨论请结束帖子。<br>请认真阅读大富翁论坛规则说明 &nbsp;http://www.delphibbs.com/delphibbs/rules.htm
 
没人会吗?
 
我有完整的屏源码,要的话mailto:yabo18@sina.com
 
Procedure ScreenSaveKey(PaScreen:Boolean=True);<br>Var PrTemp:Integer;<br>begin<br>&nbsp; if PaScreen then<br>&nbsp; &nbsp; &nbsp;SystemParametersInfo( SPI_SCREENSAVERRUNNING, 1, @PrTemp, 0)//屏蔽Alt+Tab、Ctrl+Alt+Del、Ctrl+Esc等系统功能键<br>&nbsp; else SystemParametersInfo( SPI_SCREENSAVERRUNNING, 0, @PrTemp, 0);<br><br>end;<br>
 
来自:沈前卫, 时间:2001-2-3 1:10:09, ID:447186 的办法似乎不错,<br>可是Hdesk_WL老是为0. why ?<br><br>
 
后退
顶部