[译]InstantOff
By robot-v1.0
本文链接 https://www.kyfws.com/applications/instantoff-zh/
版权声明 本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!
- 4 分钟阅读 - 1672 个词 阅读量 0[译]InstantOff
原文地址:https://www.codeproject.com/Articles/2124/InstantOff
原文作者:Derick Cyril Thomas
译文由本站 robot-v1.0 翻译
前言
A system tray utility that will Shutdown, Restart, LogOff, Hibernate or Standby your system with just a double click.
一个系统任务栏实用程序,只需双击即可关闭,重新启动,注销,休眠或待机.
介绍(Introduction)
这是一个简单的系统任务栏实用程序,可让您单击鼠标即可快速关闭,重新启动,注销,休眠或待机.从屏幕快照中可以看到,它将允许您从上下文菜单中选择任何动作,或者只需双击菜单项即可执行默认菜单动作.与Start-> ShutDown然后选择操作的通常方法相比,这非常方便.(This is a simple system tray utility which allows you to quickly Shutdown, Restart, Log Off, Hibernate or Standby just with a mouse click. As you can see from the screen shot, it will allow you to choose any action from the Context menu or execute the default menu action by just double clicking the menu item. This is very handy compared to the usual way of Start->ShutDown and then choose the action.)
特征(Features)
- 快速紧凑.可执行文件只有35 KB.它包装有UPX.原始文件大小仅为72 KB.(Fast and compact. The executable is only 35 KB. It is packed with UPX. Original file size is only 72 KB.)
- 易于定制.用户可以选择应该显示在上下文菜单和默认菜单项中的菜单项.双击系统任务栏图标,将处理与此默认菜单项关联的操作.(Easy to customize. The user can select the menu items which should appear in the Context menu and the Default menu item. The action associated with this default menu item will be processed upon double clicking the System Tray Icon.)
- 用户还可以决定是否(The user can also decide whether to)**力(force)**系统将执行上下文菜单中显示的操作.在这种情况下,系统将不等待任何程序关闭,并且您将丢失未保存的数据.但是,当您陷入某些程序中时,这很有用.(the system to undergo the actions displayed in the context menu. In this case the system will not wait for any programs to close and you will lose the unsaved data. But this useful when you get stuck with some program.)
- 它可以在任何平台上运行,从Windows 95到Windows XP Pro和Home Edition.(It will work on any platform, from Windows 95 to Windows XP Pro and Home Edition.)
代码详细信息(Code Details)
此版本的应用程序是使用WTL 7.0库编写的.它不使用WTL 7.0的特定功能,并且可以使用WTL 3.1或3.0进行编译.此应用程序的早期版本是使用API编写的.但是我认为在这种情况下使用面向对象方法会更好.(This version of the Application was written using WTL 7.0 library. It uses no WTL 7.0 specific features, and it can be compiled with WTL 3.1 or 3.0. Earlier versions of this Application was written using API. But I think that an Object Orient Approach would be far better in this kind of situations.)
对于系统关机,重新启动和注销(For system Shutdown, Restart and Log Off) ExitWindowsEx
使用API.对于休眠和待机模式(API is used. For Hibernation and Standby modes) SetSystemPowerState
使用API.该程序将其设置存储在文件中(API is used. The program stores its settings in file)**Instant.ini(instant.ini)**而不是使用系统注册表.(instead of using System Registry.)
我使用了树控件,该控件允许用户选择默认菜单操作和要在上下文菜单中显示的项目.我派生了一个新类来实现Internet Explorer(如"选项对话框").您必须至少选择一个要在上下文菜单中显示的菜单项和一个默认菜单项.您还可以指定是否强制系统执行单击的操作.在里面(I have used a Tree Control which allows the user to select the default menu action and Items to be displayed in the context menu. I have derived a new class to achieve Internet Explorer like Options Dialog. You must choose at least one menu item to be displayed in the context menu and one default menu item. You van also specify whether to force the system to undergo the clicked action. In the)设定值(Settings)类别显示是否强制关闭系统,但对所有五个菜单项均有效.(category it is shown whether to force the system shutdown, but it will work for all the five menu items.)
最后的话 …(Last words …)
我已经为此应用程序专门编写了该应用程序所需的所有组件.如果您需要使用任何组件,则必须在现有代码中添加/删除一些代码.该代码未注释.但是函数名称会告诉您我做了什么.我认为这很容易理解.设置保存可以在注册表中完成.我用过MFC的(I have written all the components required for this application specifically for this Application. If you need to use any of thecomponents you have to Add/Remove some code to/from the existing code. The code is not commented. But functions names will tell you what I did. I think it can be easily understood. The settings saving could be done in registry. I have used MFC’s) VERIFY
轻松捕获错误.它对我非常有效,并且使用该Tree Control可以发现一些错误.期待错误…(to catch bugs very easily. And it worked for me very well and I could catch some bugs with that Tree Control. Expect Bugs…)
许可
本文以及所有相关的源代码和文件均已获得The Code Project Open License (CPOL)的许可。
C++ VC6 WinXP Windows Win2K MFC Visual-Studio Dev 新闻 翻译