关于如何控制启动的程序不被杀掉(200分)

  • 主题发起人 主题发起人 windmill
  • 开始时间 开始时间
W

windmill

Unregistered / Unconfirmed
GUEST, unregistred user!
我有一个自己编的监测程序,放在了95的启动菜单中<br>但是从开机到执行我的程序,中间有很长时间,往往<br>别人能够用ctrl+alt+del关掉进程,希望能编一个<br>控制键盘输入的小程序,防止程序被杀掉,在95启动时<br>就加载,并且不能被杀掉,望各位指教.
 
将程式加入注册表 HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Windows/CurrentVersion/Run<br>以前曾讨论过在ctrl+Alt+del中屏蔽某程式的方法,try......<br>程式不提供关闭方法<br>比如说exit菜单,右上角的"叉"<br>
 
RegisterServiceProcess(GetCurrentProcessID,1);<br>ctrl+alt+del就看不到了。<br><br>将程式加入注册表 HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Windows/<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CurrentVersion/RunService
 
o*o: 我知道你所说的完全正确,但是我一直以来都没能Register成功过,<br>能否给个成功典范?
 
unit Unit1;<br><br>interface<br><br>uses<br>&nbsp; Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,<br>&nbsp; StdCtrls, shellapi;<br><br><br>&nbsp; &nbsp;function &nbsp;RegisterServiceProcess(dwProcessID:DWORD; dwType:dword):boolean;stdcall;external 'KERNEL32.dll' name<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 'RegisterServiceProcess';<br><br><br>type<br>&nbsp; TForm1 = class(TForm)<br>&nbsp; &nbsp; Button1: TButton;<br>&nbsp; &nbsp; procedure Button1Click(Sender: TObject);<br>&nbsp; &nbsp; procedure FormClose(Sender: TObject; var Action: TCloseAction);<br>&nbsp; private<br>&nbsp; &nbsp; { Private declarations }<br>&nbsp; public<br>&nbsp; &nbsp; { Public declarations }<br>&nbsp; end;<br><br>var<br>&nbsp; Form1: TForm1;<br><br>implementation<br><br>{$R *.DFM}<br><br>procedure TForm1.Button1Click(Sender: TObject);<br>begin<br>&nbsp; registerserviceprocess(0,1);<br>end;<br>procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);<br>begin<br>&nbsp; REGISTERSERVICEPROCESS(0,0);<br>end;<br><br>end.
 
可以在OnCreate函数中声明如下:<br>procedure TForm1.FormCreate(sender:TObject);<br>begin<br>SetWindowLong(Application,Handle,GWL_EXSTYLE,WS_EX_TOOLWINDOW);<br>end;<br>这样别人在任务栏中就看不到你的程序了,也就杀不掉它了。<br><br><br>
 
Thanks Liu JZX:<br>&nbsp; 我知道我错在哪里了,<br>function &nbsp;RegisterServiceProcess(dwProcessID:DWORD; dwType:dword):boolean;<br>stdcall; // 我没有写这一行!<br>external 'KERNEL32.dll' name 'RegisterServiceProcess';<br>
 
除了调用RegisterServiceProcess使之不在任务列表中出现外你还可以在主窗体的onclose事件中调用自身,这样尽管在任务列表中能看到程序,但无法结束它。
 
以上几种方法我已知道了,但是我的程序挺大的,<br>机器的速度又不快<br>导致在程序真正启动之前还有一段时间,在任务栏中还能看到<br>所以我想编一段屏蔽键盘的小程序<br>先加载,同时隐藏自己,<br>但是,我如何在我的主程序启动后,杀死这个隐藏的进程呢?(屏蔽键盘的程序)<br>请教各位大仙.
 
当你不需要让用户按Alt+Enter、Ctrl+Alt+Del、Ctrl+Esc等功能键的时候加入以下<br><br>代码:<br>Var<br>temp:integer;<br>begin<br>SystemParametersInfo(Spi_screensaverrunning,1,@temp,0);<br>end;<br>当你要恢复功能键时用以下代码:<br>Var<br>Temp:integer;<br>begin<br>SystemParametersInfo(spi_screensaverrunning,0,@temp,0);<br>end;<br>
 
Try this:<br><br>program project1;<br><br>uses<br>&nbsp; Windows,<br>&nbsp; Forms,<br>&nbsp; main in 'main.pas';<br><br>{$R *.RES}<br>function RegisterServiceProcess(dwProcessId,dwType:dword): Integer;stdcall;external 'kernel32.dll';<br><br>begin<br>&nbsp; RegisterServiceProcess(GetCurrentProcessID,1);<br>&nbsp; Application.Initialize;<br>&nbsp; Application.ShowMainForm:=False;<br>&nbsp; Application.CreateForm(TFormClient, FormClient);<br>&nbsp; Application.Run;<br>end.<br>
 
有无办法让pView95等程序关闭的方法。
 
创建进程<br>CreateProcess(PChar('c:/program files/microsoft office/office/winword.exe'),<br>&nbsp; &nbsp; &nbsp; nil,nil,nil,true,DETACHED_PROCESS,nil,nil,st,pp);<br><br>关闭进程<br>&nbsp; ppp:=OpenProcess(PROCESS_ALL_ACCESS, FALSE,pp.dwProcessId );<br>&nbsp; TerminateProcess(ppp,0);}
 
有无办法不让pView95等程序关闭的方法。<br>
 
可大 家试过没有.在win 的启动画面刚没过时.按下ctrl+alt+del<br>可在进程加载之前把他杀掉
 
去长沙热线看看。202。113。29。119 那有一个软件屏蔽这些键。在软件编程里
 
在delphi中我用SystemParametersInfo(SPI_SCREENSAVERRUNNING, 1, nil, 0);<br>只能在98下保证对键盘的屏蔽<br>但是在95下就不行了,(可能我的是97)<br>我用其他的SystemParametersInfo参数也不行<br>请教各位还有什么办法吗?<br><br>
 
//打开关闭Ctrl+Alt+del<br>var<br>&nbsp; OldVal : LongInt;<br>begin<br>&nbsp; SystemParametersInfo (97, Word (False), @OldVal, 0)<br>end;<br><br>procedure TForm1.Button2Click(Sender: TObject);<br>var<br>&nbsp; OldVal : LongInt;<br>begin<br>&nbsp; SystemParametersInfo (97, Word (True), @OldVal, 0)<br>end;<br><br>//关闭 Windows 的 TaskBar<br>type<br>&nbsp; TForm1 = class(TForm)<br>&nbsp; &nbsp; procedure FormCreate(Sender: TObject);<br>&nbsp; &nbsp; procedure FormDestroy(Sender: TObject);<br>&nbsp; private<br>&nbsp; &nbsp; { Private declarations }<br>&nbsp; &nbsp; hTaskBar: HWND;<br>&nbsp; public<br>&nbsp; &nbsp; { Public declarations }<br>&nbsp; end;<br><br>var<br>&nbsp; Form1: TForm1;<br><br>implementation<br><br>{$R *.DFM}<br><br>procedure TForm1.FormCreate(Sender: TObject);<br>begin<br>&nbsp; &nbsp; &nbsp; hTaskBar := FindWindow('Shell_TrayWnd', nil);<br>&nbsp; &nbsp; &nbsp; ShowWindow(hTaskBar, SW_HIDE);<br>end;<br><br>procedure TForm1.FormDestroy(Sender: TObject);<br>begin<br>&nbsp; &nbsp; ShowWindow(hTaskBar, SW_SHOW);<br>end;<br><br>end.<br><br>//使程序在 Ctrl+Alt+Del时不会出现在列表中,<br>//下面是从D版盘中得到的Source ,是一个控件<br>unit Phantom;<br><br>interface<br><br>uses<br>&nbsp; Windows, wintypes, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,<br>&nbsp; menus, shellapi;<br><br>&nbsp; const<br>&nbsp; TASKBAREVENT: PChar = 'NewTNIMessage_20';<br><br>type<br>&nbsp; TPhantom = class(TComponent)<br>&nbsp; private<br>&nbsp; &nbsp; fIconDatei: Ticon;<br>&nbsp; &nbsp; ftip:string &nbsp;;<br>&nbsp; &nbsp; fSichtbar: Boolean ;<br>&nbsp; &nbsp; fServiceprocess: Boolean ;<br>&nbsp; &nbsp; fLinksKlick: TNotifyEvent;<br>&nbsp; &nbsp; fRechtsKlick: TNotifyEvent;<br>&nbsp; &nbsp; fDoppelKlick: TNotifyEvent;<br>&nbsp; &nbsp; fIconSichtbarkeit: boolean;<br>&nbsp; &nbsp; fPopupRechts: TPopupMenu;<br>&nbsp; &nbsp; fPopupLinks: TPopupMenu;<br>&nbsp; &nbsp; { Private-Deklarationen }<br>&nbsp; &nbsp; procedure PWsichtbarkeit(value:boolean);<br>&nbsp; &nbsp; procedure PWserviceprocess(value:boolean);<br>&nbsp; &nbsp; procedure sichtbarmachen;<br>&nbsp; &nbsp; procedure unsichtbarmachen;<br>&nbsp; &nbsp; procedure WPopRechts;<br>&nbsp; &nbsp; procedure WPopLinks;<br>&nbsp; &nbsp; procedure CreateIcon;<br>&nbsp; &nbsp; procedure ChangeIcon;<br>&nbsp; &nbsp; procedure DeleteIcon;<br>&nbsp; &nbsp; procedure settip(value:string);<br>&nbsp; &nbsp; procedure Wicondatei(value:Ticon);<br>&nbsp; &nbsp; procedure WIconSichtbarkeit(value:boolean);<br>&nbsp; protected<br>&nbsp; &nbsp; { Protected-Deklarationen }<br>&nbsp; &nbsp; procedure serviceprocessEin;<br>&nbsp; &nbsp; procedure serviceprocessAus;<br>&nbsp; &nbsp; procedure WRechtsklick; virtual;<br>&nbsp; &nbsp; procedure WLinksklick; virtual;<br>&nbsp; &nbsp; procedure WDoppelklick; virtual;<br>&nbsp; &nbsp; procedure WndProc(var Msg: TMessage);<br>&nbsp; &nbsp; procedure Notification(Component: TComponent; Operation: TOperation); override;<br>&nbsp; public<br>&nbsp; &nbsp; { Public-Deklarationen }<br>&nbsp; &nbsp; &nbsp; procedure loaded;override;<br>&nbsp; &nbsp; &nbsp; destructor Destroy; override;<br>&nbsp; &nbsp; &nbsp; constructor Create(AOwner: TComponent); override;<br>&nbsp; &nbsp;published<br>&nbsp; &nbsp; { Published-Deklarationen }<br>&nbsp; &nbsp; property Sichtbar: Boolean read fsichtbar write PWsichtbarkeit;{Formular verstecken/anzeigen}<br>&nbsp; &nbsp; property Serviceprocess: Boolean read fserviceprocess write PWserviceprocess;{Als Service-Process registrieren/abmelden (gegen Strg+Alt+Entf)}<br>&nbsp; &nbsp; property IconDatei: Ticon read fIconDatei write Wicondatei;<br>&nbsp; &nbsp; property LinksKlick: TNotifyEvent read fLinksKlick write flinksklick;<br>&nbsp; &nbsp; property RechtsKlick: TNotifyEvent read fRechtsKlick write fRechtsklick;<br>&nbsp; &nbsp; property DoppelKlick: TNotifyEvent read fDoppelKlick write fDoppelklick;<br>&nbsp; &nbsp; property IconSichtbarkeit: boolean read fIconSichtbarkeit write WIconSichtbarkeit;<br>&nbsp; &nbsp; property PopupRechts: TPopupMenu read fPopupRechts write fPopuprechts;<br>&nbsp; &nbsp; property PopupLinks: TPopupMenu read fPopupLinks write fPopuplinks;<br>&nbsp; &nbsp; property Tip: string read FTip write SetTip;<br>&nbsp; end;<br><br>procedure Register;<br>function RegisterServiceProcess(dwProcessId,dwType:dword): Integer;stdcall;external 'kernel32.dll'<br><br>implementation<br><br>var ficonmessage: UINT;<br>&nbsp; &nbsp; FWnd: HWnd;<br>&nbsp; &nbsp; icsichtbar:boolean;<br><br>constructor tphantom.Create(AOwner: TComponent) ;<br>begin<br>inherited Create(AOwner);<br>ficonmessage := RegisterWindowMessage(TASKBAREVENT);<br>FWnd := AllocateHWnd(WndProc);<br>FIcondatei := TIcon.Create;<br>iconsichtbarkeit:=false ;<br>sichtbar:=true;<br>serviceprocess:=false;<br>icsichtbar:=false;<br>end;<br><br>destructor TPhantom.Destroy;<br>begin<br>&nbsp; if (csDesigning in ComponentState) then exit;<br>&nbsp; if Ficonsichtbarkeit and not (csDesigning in ComponentState) then<br>&nbsp; &nbsp; deleteIcon;<br>&nbsp; FIcondatei.Free;<br>&nbsp; DeallocateHWnd(FWnd);<br>&nbsp; inherited destroy;<br>end;<br><br>procedure TPhantom.WndProc(var Msg: TMessage);<br>begin<br>&nbsp; if (csDesigning in ComponentState) then exit;<br>&nbsp; with Msg do begin<br>&nbsp; &nbsp; if Msg = ficonmessage then<br>&nbsp; &nbsp; &nbsp; case LParamLo of<br>&nbsp; &nbsp; &nbsp; &nbsp; WM_LBUTTONDOWN: &nbsp; WLinksKlick;<br>&nbsp; &nbsp; &nbsp; &nbsp; WM_RBUTTONDOWN: &nbsp; WRechtsKlick;<br>&nbsp; &nbsp; &nbsp; &nbsp; WM_LBUTTONDBLCLK: WDoppelKlick;<br>&nbsp; &nbsp; &nbsp; end<br>&nbsp; &nbsp; else<br>&nbsp; &nbsp; &nbsp; Result := DefWindowProc(FWnd, Msg, wParam, lParam);<br>&nbsp; end;<br>end;<br><br>procedure TPhantom.Notification(Component: TComponent; Operation: TOperation);<br>begin<br>&nbsp; if (csDesigning in ComponentState) then exit;<br>&nbsp; inherited Notification(Component, Operation);<br>&nbsp; if Operation = opRemove then begin<br>&nbsp; &nbsp; if Component = FPopuprechts then FPopuprechts := nil;<br>&nbsp; &nbsp; if Component = FPopuplinks then FPopuplinks := nil;<br>&nbsp; end;<br>end;<br><br>procedure TPhantom.PWsichtbarkeit(value:boolean);<br>begin<br>fsichtbar:=value;<br>if (csDesigning in ComponentState) then exit;<br>if sichtbar=true then sichtbarmachen;<br>if sichtbar=false then unsichtbarmachen;<br>end;<br><br>procedure TPhantom.PWserviceprocess(value:boolean);<br>begin<br>fserviceprocess:=value;<br>if (csDesigning in ComponentState) then exit;<br>if serviceprocess=true then serviceprocessEin;<br>if serviceprocess=false then serviceprocessAus;<br>end;<br><br>procedure TPhantom.serviceprocessEin;<br>begin<br>RegisterServiceProcess(GetCurrentProcessID,1)<br>end;<br><br>procedure TPhantom.serviceprocessAus;<br>begin<br>RegisterServiceProcess(GetCurrentProcessID,0)<br>end;<br><br>procedure TPhantom.sichtbarmachen;<br>begin<br>showwindow(FindWindow(nil, @Application.Title[1]),SW_RESTORE)<br>end;<br><br>procedure TPhantom.unsichtbarmachen;<br>begin<br>showwindow(FindWindow(nil, @Application.Title[1]),SW_MINIMIZE);<br>showwindow(FindWindow(nil, @Application.Title[1]),SW_HIDE) ;<br>end;<br><br>procedure TPhantom.WRechtsklick;<br>begin<br>if (csDesigning in ComponentState) then exit;<br>if Assigned(FPopuprechts) then WPoprechts<br>&nbsp; else if Assigned(FRechtsKlick) then<br>&nbsp; &nbsp; FRechtsKlick(Self);<br>end;<br><br>procedure TPhantom.WLinksklick;<br>begin<br>if (csDesigning in ComponentState) then exit;<br>if Assigned(FPopuplinks) then WPoplinks<br>&nbsp; else if Assigned(FLinksKlick) then<br>&nbsp; &nbsp; FLinksKlick(Self);<br>end;<br><br>procedure TPhantom.WDoppelklick;<br>begin<br>if (csDesigning in ComponentState) then exit;<br>if Assigned(Fdoppelklick)then FDoppelKlick(Self);<br>end;<br><br>procedure TPhantom.WPopRechts;<br>var punkt:Tpoint;<br>begin<br>if (csDesigning in ComponentState) then exit;<br>GetCursorPos(Punkt);<br>SetForeGroundWindow(FWnd);<br>FPopuprechts.Popup(Punkt.X, Punkt.Y);<br>end;<br><br>procedure TPhantom.WPopLinks;<br>var punkt:Tpoint;<br>begin<br>if (csDesigning in ComponentState) then exit;<br>GetCursorPos(Punkt);<br>SetForeGroundWindow(FWnd);<br>FPopuplinks.Popup(Punkt.X, Punkt.Y);<br>end;<br><br>procedure TPhantom.CreateIcon;<br>var icon: TNOTIFYICONDATA;<br>begin<br>if (csDesigning in ComponentState) then exit;<br>with icon do begin<br>&nbsp; &nbsp; cbSize := SizeOf(TNOTIFYICONDATA);<br>&nbsp; &nbsp; Wnd := FWnd;<br>&nbsp; &nbsp; uID := 1;<br>&nbsp; &nbsp; uFlags := NIF_MESSAGE or NIF_ICON or NIF_TIP;<br>&nbsp; &nbsp; uCallbackMessage :=ficonMessage;<br>&nbsp; &nbsp; hIcon := FIcondatei.Handle;<br>&nbsp; &nbsp; StrCopy(szTip, PChar(FTip));<br>&nbsp; &nbsp; Shell_NotifyIcon(NIM_ADD, @icon);<br>&nbsp; end;<br>&nbsp; icsichtbar := true;<br>end;<br><br>procedure TPhantom.ChangeIcon;<br>var icon: TNOTIFYICONDATA;<br>begin<br>if (csDesigning in ComponentState) then exit;<br>with icon do begin<br>&nbsp; &nbsp; cbSize := SizeOf(TNOTIFYICONDATA);<br>&nbsp; &nbsp; Wnd := FWnd;<br>&nbsp; &nbsp; uID := 1;<br>&nbsp; &nbsp; uFlags := NIF_MESSAGE or NIF_ICON or NIF_TIP;<br>&nbsp; &nbsp; uCallbackMessage := ficonMessage;<br>&nbsp; &nbsp; hIcon := FIcondatei.Handle;<br>&nbsp; &nbsp; StrCopy(szTip, PChar(FTip));<br>&nbsp; &nbsp; Shell_NotifyIcon(NIM_MODIFY, @icon);<br>&nbsp; end;<br>end;<br><br>procedure TPhantom.DeleteIcon;<br>var icon: TNOTIFYICONDATA;<br>begin<br>if (csDesigning in ComponentState) then exit;<br>with icon do begin<br>&nbsp; &nbsp; cbSize := SizeOf(TNOTIFYICONDATA);<br>&nbsp; &nbsp; Wnd := FWnd;<br>&nbsp; &nbsp; uID := 1;<br>&nbsp; &nbsp; uFlags := NIF_MESSAGE or NIF_ICON or NIF_TIP;<br>&nbsp; &nbsp; uCallbackMessage := ficonmessage;<br>&nbsp; &nbsp; hIcon := FIcondatei.Handle;<br>&nbsp; &nbsp; StrCopy(szTip, PChar(FTip));<br>&nbsp; &nbsp; Shell_NotifyIcon(NIM_DELETE, @icon);<br>&nbsp; end;<br>&nbsp; icsichtbar := false;<br>end;<br><br>procedure TPhantom.settip(value:string);<br>begin<br>if FTip &lt;&gt; value then begin<br>&nbsp; &nbsp; FTip := value;<br>&nbsp; &nbsp; if not (csDesigning in ComponentState) then changeicon;<br>&nbsp; end;<br>end;<br><br>procedure TPhantom.Wicondatei(value:Ticon);<br>begin<br>if ficondatei&lt;&gt;value then begin<br>&nbsp; &nbsp; ficondatei.assign(value);<br>&nbsp; &nbsp; &nbsp; if (csDesigning in ComponentState) then exit;<br>&nbsp; &nbsp; &nbsp; if icsichtbar then changeicon else createicon;<br>&nbsp; &nbsp; &nbsp; if ficondatei.empty then deleteicon;<br>&nbsp; end;<br>end;<br><br>procedure TPhantom.WIconSichtbarkeit(value:boolean);<br>begin<br>ficonsichtbarkeit:=value;<br>if csDesigning in ComponentState then Exit;<br>if ficonsichtbarkeit=true and icsichtbar=false then createicon;<br>if ficonsichtbarkeit=false and icsichtbar=true then deleteicon;<br>end;<br><br>procedure TPhantom.Loaded;<br>begin<br>&nbsp; inherited Loaded;<br>&nbsp; if Ficonsichtbarkeit and not (csDesigning in ComponentState) and not FIcondatei.Empty then begin<br>&nbsp; &nbsp; createIcon;<br>&nbsp; end;<br>end;<br><br>procedure Register;<br>begin<br>&nbsp; RegisterComponents('Hacker', [TPhantom]);<br>end;<br><br>end.<br><br><br><br>&nbsp;<br><br><br>
 
后退
顶部