⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 o18.htm

📁 C++Builder教学大全
💻 HTM
字号:
 

<html>

<head>

<title>Windows95/98下怎样隐藏应用程序不让它出现在CTRL-ALT-DEL对话框中?</title>

<meta http-equiv="目录类型" content="文本/html; 字符集=gb2312">

</head>

<body bgcolor="#FFFFFF">

<table width="100%" border="0" height="285">

  <tr> 

    <td height="35"> 

      <div align="center" class="p14"><font color="#000000">Windows95/98下怎样隐藏应用程序不让它出现在CTRL-ALT-DEL对话框中?</font></div>

    </td>

  </tr>

  <tr valign="top"> 

    <td>

      <p><font color="#000000">把你的应用程序从CTRL-ALT-DEL对话框中隐藏的一个简单办法是去应用程序的标题。如果一个程序的主窗口没以标题,Windows95不把它放到CTRL-ALT-DEL对话框中。清除标题属性的最好地方是在WinMain函数里。</font></p>

      <pre><span style="BACKGROUND-COLOR: silver"><font color="#000000">WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, </font></span><font color="#000000"><span style="BACKGROUND-COLOR: silver"><b>int</b>)</span>

<span style="BACKGROUND-COLOR: silver">{</span>

<span style="BACKGROUND-COLOR: silver">    <b>try</b></span>

<span style="BACKGROUND-COLOR: silver">    {</span>

<span style="BACKGROUND-COLOR: silver">         Application-&gt;Title = &quot;&quot;;</span>

<span style="BACKGROUND-COLOR: silver">         Application-&gt;Initialize();</span>

<span style="BACKGROUND-COLOR: silver">         Application-&gt;CreateForm(<b>__classid</b>(TForm1), &amp;Form1);</span>

<span style="BACKGROUND-COLOR: silver">         Application-&gt;Run();</span>

<span style="BACKGROUND-COLOR: silver">    }</span>

<span style="BACKGROUND-COLOR: silver">    <b>catch</b> (Exception &amp;exception)</span>

<span style="BACKGROUND-COLOR: silver">    {</span>

<span style="BACKGROUND-COLOR: silver">         Application-&gt;ShowException(&amp;exception);</span>

<span style="BACKGROUND-COLOR: silver">    }</span>

<span style="BACKGROUND-COLOR: silver">    <b>return</b> 0;</span>

<span style="BACKGROUND-COLOR: silver">}</span></font></pre>

      <p><font color="#000000">另一种方法是:调用RegisterServiceProcess API 函数将程序注册成为一个服务模式程序。 RegisterServiceProcess是一个在Kernel32.dll里相关但无正式文件的函数。在MS   

        SDK头文件里没有该函数的原型说明,但在Borland import libraries for C++ Builder里能找到。很显然,这个函数的主要目的是创建一个服务模式程序。之所以说<i>很显然</i>,是因为MSDN里实质上对这个函数没有说什么。</font></p>  

      <p><font color="#000000">下面的例子代码演示了在Windows95/98下怎样通过使用RegisterServiceProcess来把你的程序从CTRL-ALT-DEL对话框中隐藏起来。</font></p> 

      <pre><span style="BACKGROUND-COLOR: silver"><font color="#000000">//------------Header file------------------------------</font></span><font color="#000000">

<span style="BACKGROUND-COLOR: silver"><b>typedef</b> DWORD (<b>__stdcall</b> *pRegFunction)(DWORD, DWORD);</span>

&nbsp;

<span style="BACKGROUND-COLOR: silver"><b>class</b> TForm1 : public TForm</span>

<span style="BACKGROUND-COLOR: silver">{</span>

<span style="BACKGROUND-COLOR: silver"><b>__published:</b></span>

<span style="BACKGROUND-COLOR: silver">    TButton *Button1;</span>

<span style="BACKGROUND-COLOR: silver"><b>private</b>:</span>

<span style="BACKGROUND-COLOR: silver">    HINSTANCE hKernelLib;</span>

<span style="BACKGROUND-COLOR: silver">    pRegFunction RegisterServiceProcess;</span>

<span style="BACKGROUND-COLOR: silver"><b>public</b>:</span>

<span style="BACKGROUND-COLOR: silver">    <b>__fastcall</b> TForm1(TComponent* Owner);</span>

<span style="BACKGROUND-COLOR: silver">    <b>__fastcall</b> ~TForm1();</span>

<span style="BACKGROUND-COLOR: silver">};</span>

&nbsp;

&nbsp;

<span style="BACKGROUND-COLOR: silver">//-----------CPP file------------------------------</span>

<span style="BACKGROUND-COLOR: silver">#include &quot;Unit1.h&quot;</span>

&nbsp;

<span style="BACKGROUND-COLOR: silver">#define RSP_SIMPLE_SERVICE     1</span>

<span style="BACKGROUND-COLOR: silver">#define RSP_UNREGISTER_SERVICE 0</span>

&nbsp;

<span style="BACKGROUND-COLOR: silver"><b>__fastcall</b> TForm1::TForm1(TComponent* Owner)</span>

<span style="BACKGROUND-COLOR: silver">    : TForm(Owner)</span>

<span style="BACKGROUND-COLOR: silver">{</span>

<span style="BACKGROUND-COLOR: silver">    hKernelLib = LoadLibrary(&quot;kernel32.dll&quot;);</span>

<span style="BACKGROUND-COLOR: silver">    <b>if</b>(hKernelLib)</span>

<span style="BACKGROUND-COLOR: silver">    {</span>

<span style="BACKGROUND-COLOR: silver">        RegisterServiceProcess =</span>

<span style="BACKGROUND-COLOR: silver">                  (pRegFunction)GetProcAddress(hKernelLib,</span>

<span style="BACKGROUND-COLOR: silver">                                               &quot;RegisterServiceProcess&quot;);</span>

&nbsp;

<span style="BACKGROUND-COLOR: silver">        <b>if</b>(RegisterServiceProcess)</span>

<span style="BACKGROUND-COLOR: silver">            RegisterServiceProcess(GetCurrentProcessId(),</span>

<span style="BACKGROUND-COLOR: silver">                                   RSP_SIMPLE_SERVICE);</span>

<span style="BACKGROUND-COLOR: silver">    }</span>

<span style="BACKGROUND-COLOR: silver">}</span>

&nbsp;

<span style="BACKGROUND-COLOR: silver"><b>__fastcall</b> TForm1::~TForm1()</span>

<span style="BACKGROUND-COLOR: silver">{</span>

<span style="BACKGROUND-COLOR: silver">    <b>if</b>(hKernelLib)</span>

<span style="BACKGROUND-COLOR: silver">    {</span>

<span style="BACKGROUND-COLOR: silver">        <b>if</b>(RegisterServiceProcess)</span>

<span style="BACKGROUND-COLOR: silver">            RegisterServiceProcess(GetCurrentProcessId(),</span>

<span style="BACKGROUND-COLOR: silver">                                   RSP_UNREGISTER_SERVICE);</span>

&nbsp;

<span style="BACKGROUND-COLOR: silver">        FreeLibrary(hKernelLib);</span>

<span style="BACKGROUND-COLOR: silver">    }</span>

<span style="BACKGROUND-COLOR: silver">}</span>

<span style="BACKGROUND-COLOR: silver">//-------------------------------------------------</span></font></pre> 

      <p><b><font color="#000000">注:</font></b> <font color="#000000"> windows NT下没有<tt>RegisterServiceProcess函数。</tt></font></p>  

      <div id=content>   

        <p><font color="#000000">&nbsp;</font></p> 

      </div> 

      </td> 

  </tr> 

</table> 

<br> 

</body> 

</html> 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -