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

本文介绍两种方法让Windows95/98的应用程序不在CTRL-ALT-DEL对话框中显示:一是通过清空程序标题;二是利用RegisterServiceProcess函数将程序注册为服务模式。
Windows95/98下怎样隐藏应用程序不让它出现在CTRL-ALT-DEL对话框中? (转)[@more@]

 把你的应用程序从CTRL-ALT-DEL对话框中隐藏的一个简单办法是去应用程序的标题。如果一个程序的主窗口没以标题,windows95不把它放到CTRL-ALT-DEL对话框中。清除标题属性的最好地方是在WinMain函数里。
WINapi WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
{
  try
  {
  Application->Title = "";
  Application->Initialize();
  Application->CreateForm(__classid(TForm1), &Form1);
  Application->Run();
  }
  catch (Exception &exception)
  {
  Application->ShowException(&exception);
  }
  return 0;
}

  另一种方法是:调用RegisterServiceProcess API 函数将程序注册成为一个服务模式程序。
RegisterServiceProcess是一个在Kernel32.dll里相关但无正式文件的函数。在MS SDK头文件里没有该函数的原型说明,但在Borland
import libraries for C++ Builder里能找到。很显然,这个函数的主要目的是创建一个服务模式程序。之所以说很显然,是因为MSDN里实质上对这个函数没有说什么。

  下面的例子代码演示了在Windows95/98下怎样通过使用RegisterServiceProcess来把你的程序从CTRL-ALT-DEL对话框中隐藏起来。
file://------------Header file------------------------------
typedef Dword (__stdcall *pRegFunction)(DWORD, DWORD);
 
class TForm1 : public TForm
{
__published:
  TButton *Button1;
private:
  HINSTANCE hKernelLib;
  pRegFunction RegisterServiceProcess;
public:
  __fastcall TForm1(TComponent* Owner);
  __fastcall ~TForm1();
};
 
 
file://-----------CPP file------------------------------
#include "Unit1.h"
 
#define RSP_SIMPLE_SERVICE  1
#define RSP_UNREGISTER_SERVICE 0
 
__fastcall TForm1::TForm1(TComponent* Owner)
  : TForm(Owner)
{
  hKernelLib = LoadLibrary("kernel32.dll");
  if(hKernelLib)
  {
  RegisterServiceProcess =
  (pRegFunction)GetProcAddress(hKernelLib,
  "RegisterServiceProcess");
 
  if(RegisterServiceProcess)
  RegisterServiceProcess(GetCurrentProcessId(),
  RSP_SIMPLE_SERVICE);
  }
}
 
__fastcall TForm1::~TForm1()
{
  if(hKernelLib)
  {
  if(RegisterServiceProcess)
  RegisterServiceProcess(GetCurrentProcessId(),
  RSP_UNREGISTER_SERVICE);
 
  FreeLibrary(hKernelLib);
  }
}
file://-------------------------------------------------

  注: windows NT下没有RegisterServiceProcess函数。

 


来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/10752043/viewspace-995554/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/10752043/viewspace-995554/

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符  | 博主筛选后可见
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值