📄 faq82.htm
字号:
<HTML>
<HEAD>
<TITLE>Hide an application from the CTRL-ALT-DEL dialog in Windows 95/98</TITLE>
<META NAME="Author" CONTENT="Harold Howe">
</HEAD>
<BODY BGCOLOR="WHITE">
<CENTER>
<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH="640">
<TR>
<TD>
<H3>
Hide an application from the CTRL-ALT-DEL dialog in Windows 95/98
</H3>
<P>
One simple way to hide your program from the CTRL-ALT-DEL dialog is to clear the <TT>Application</TT> object's
<TT>Title</TT>. If a program's main window does not have a title, Windows 95 does not put the program in the
CTRL-ALT-DEL dialog. The best place to clear the <TT>Title</TT> property is inside the <TT>WinMain</TT> function.
</P>
<pre>
WINAPI WinMain<b>(</b>HINSTANCE<b>,</b> HINSTANCE<b>,</b> LPSTR<b>,</b> <b>int</b><b>)</b>
<b>{</b>
<b>try</b>
<b>{</b>
Application<b>-></b>Title <b>=</b> <font color="blue">""</font><b>;</b>
Application<b>-></b>Initialize<b>(</b><b>)</b><b>;</b>
Application<b>-></b>CreateForm<b>(</b><b>__classid</b><b>(</b>TForm1<b>)</b><b>,</b> <b>&</b>Form1<b>)</b><b>;</b>
Application<b>-></b>Run<b>(</b><b>)</b><b>;</b>
<b>}</b>
<b>catch</b> <b>(</b>Exception <b>&</b>exception<b>)</b>
<b>{</b>
Application<b>-></b>ShowException<b>(</b><b>&</b>exception<b>)</b><b>;</b>
<b>}</b>
<b>return</b> <font color="blue">0</font><b>;</b>
<b>}</b>
</pre>
<P>
Another way to hide the program is to register it as a service mode program by calling the
<TT>RegisterServiceProcess</TT> API function. <TT>RegisterServiceProcess</TT> is a relatively undocumented
function in <TT>KERNEL32.DLL</TT>. The function is not prototyped in the MS SDK header files, but it can be found
in the Borland import libraries for C++Builder. Apparently, the function's main purpose is to create service-mode
programs. I say <I>apparently</I> because the MSDN says virtually nothing about this function.
</P>
<P>
The code example below demonstrates how to use <TT>RegisterServiceProcess</TT> to hide your program from the
CTRL-ALT-DEL dialog in Windows 95/98.
</P>
<pre>
<font color="navy">//------------Header file------------------------------</font>
<b>typedef</b> DWORD <b>(</b><b>__stdcall</b> <b>*</b>pRegFunction<b>)</b><b>(</b>DWORD<b>,</b> DWORD<b>)</b><b>;</b>
<b>class</b> TForm1 <b>:</b> <b>public</b> TForm
<b>{</b>
<b>__published</b><b>:</b>
TButton <b>*</b>Button1<b>;</b>
<b>private</b><b>:</b>
HINSTANCE hKernelLib<b>;</b>
pRegFunction RegisterServiceProcess<b>;</b>
<b>public</b><b>:</b>
<b>__fastcall</b> TForm1<b>(</b>TComponent<b>*</b> Owner<b>)</b><b>;</b>
<b>__fastcall</b> <b>~</b>TForm1<b>(</b><b>)</b><b>;</b>
<b>}</b><b>;</b>
<font color="navy">//-----------CPP file------------------------------</font>
<font color="green">#include "Unit1.h"</font>
<font color="green">#define RSP_SIMPLE_SERVICE 1</font>
<font color="green">#define RSP_UNREGISTER_SERVICE 0</font>
<b>__fastcall</b> TForm1<b>:</b><b>:</b>TForm1<b>(</b>TComponent<b>*</b> Owner<b>)</b>
<b>:</b> TForm<b>(</b>Owner<b>)</b>
<b>{</b>
hKernelLib <b>=</b> LoadLibrary<b>(</b><font color="blue">"kernel32.dll"</font><b>)</b><b>;</b>
<b>if</b><b>(</b>hKernelLib<b>)</b>
<b>{</b>
RegisterServiceProcess <b>=</b>
<b>(</b>pRegFunction<b>)</b>GetProcAddress<b>(</b>hKernelLib<b>,</b>
<font color="blue">"RegisterServiceProcess"</font><b>)</b><b>;</b>
<b>if</b><b>(</b>RegisterServiceProcess<b>)</b>
RegisterServiceProcess<b>(</b>GetCurrentProcessId<b>(</b><b>)</b><b>,</b>
RSP_SIMPLE_SERVICE<b>)</b><b>;</b>
<b>}</b>
<b>}</b>
<b>__fastcall</b> TForm1<b>:</b><b>:</b><b>~</b>TForm1<b>(</b><b>)</b>
<b>{</b>
<b>if</b><b>(</b>hKernelLib<b>)</b>
<b>{</b>
<b>if</b><b>(</b>RegisterServiceProcess<b>)</b>
RegisterServiceProcess<b>(</b>GetCurrentProcessId<b>(</b><b>)</b><b>,</b>
RSP_UNREGISTER_SERVICE<b>)</b><b>;</b>
FreeLibrary<b>(</b>hKernelLib<b>)</b><b>;</b>
<b>}</b>
<b>}</b>
<font color="navy">//-------------------------------------------------</font>
</pre>
<P>
<B>Note:</B> <TT>RegisterServiceProcess</TT> does not exist on Windows NT.
</P>
</TD> </TR>
</TABLE>
</CENTER>
</BODY>
</HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -