當程式執行時,如何讓程式也不出現在工作管理員內 |
尚未結案
|
uj
一般會員 發表:14 回覆:25 積分:7 註冊:2003-03-06 發送簡訊給我 |
這問題我有在 Win32 API 使用討論區(Delphi) 中看到
請問有人可以教我 BCB 怎寫? Question: How can I hide my application from the task manager ? Answer: 1.DEFINE IT: function RegisterServiceProcess(dwProcessID: DWORD; dwType: DWORD) : DWORD; stdcall; external 'KERNEL32.DLL'; 2.THEN... RegisterServiceProcess(GetCurrentProcessId(), 1); Yup, you guessed it... Changing the 0 to 1 will make it
magically re-appear.
|
axsoft
版主 發表:681 回覆:1056 積分:969 註冊:2002-03-13 發送簡訊給我 |
參考這篇試試
http://bcbget.myrice.com/w/o18.htm
Windows95/98下怎樣隱藏應用程序不讓它出現在CTRL-ALT-DEL對話框中?把你的應用程序從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對話框中隱藏起來。 //------------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(); }; //-----------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); } } //------------------------------------------------- 注: windows NT下沒有RegisterServiceProcess函數。網路志工聯盟----Visita網站http://www.vista.org.tw ---[ 發問前請先找找舊文章 ]--- |
uj
一般會員 發表:14 回覆:25 積分:7 註冊:2003-03-06 發送簡訊給我 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |