API中的禁用管理器和任务栏,写入启动组,还有关机函数 ( 积分: 50 )

  • 主题发起人 主题发起人 兰凌
  • 开始时间 开始时间

兰凌

Unregistered / Unconfirmed
GUEST, unregistred user!
如题.我分不够了,各位帮帮忙<br>我不知道怎么禁用任务管理器,有谁知道的,帮忙把代码贴出来好吗?<br>屏蔽任务栏和写入启动组我是可以通过,但是都不起作用<br>屏蔽任务栏代码:<br>const r:TRect;<br> &nbsp;var<br> &nbsp; Wndclass:array[0..50] of char;<br> &nbsp; WndHandle:THandle;<br>strPCopy(@wndClass[0],'Shell_TrayWnd');<br>ShowWindow(WndHandle,SW_Hide);<br>SetWindowPos(WndHandle,HWND_BOTTOM,r.top,r.botton,r.right,SWP_NOMOVE);<br>写入启动组代码:<br>var<br> &nbsp;Reg:TRegistry;<br>begin<br> &nbsp; Reg:=TRegistry.Create;<br> &nbsp;try<br> &nbsp; &nbsp; Reg.RootKey:=HKEY_CURRENT_USER;<br> &nbsp; &nbsp; if Reg.OpenKey('/SOFTWARE/MICROSOFT/WINDOWS/CURRENTVERSION/RUN',True) then<br> &nbsp; &nbsp; begin<br> &nbsp; &nbsp; &nbsp; Reg.WriteString('路径','启动名');<br> &nbsp; &nbsp; &nbsp;end;<br> &nbsp; finally<br> &nbsp; &nbsp; Reg.CloseKey;<br> &nbsp; &nbsp; Reg.free;<br> &nbsp; end;<br>end;<br><br>我的系统是xp的,我用了关机函数,重启,结果都只是注销,这是为什么?<br>那位帮忙解答下<br>ExitWindowsEx(EWX_POWEROFF,8);关机并关掉电源<br>ExitWindowsEx(EWX_REBOOT,2); 重启<br>结果都是注销,没什么作用
 
如题.我分不够了,各位帮帮忙<br>我不知道怎么禁用任务管理器,有谁知道的,帮忙把代码贴出来好吗?<br>屏蔽任务栏和写入启动组我是可以通过,但是都不起作用<br>屏蔽任务栏代码:<br>const r:TRect;<br> &nbsp;var<br> &nbsp; Wndclass:array[0..50] of char;<br> &nbsp; WndHandle:THandle;<br>strPCopy(@wndClass[0],'Shell_TrayWnd');<br>ShowWindow(WndHandle,SW_Hide);<br>SetWindowPos(WndHandle,HWND_BOTTOM,r.top,r.botton,r.right,SWP_NOMOVE);<br>写入启动组代码:<br>var<br> &nbsp;Reg:TRegistry;<br>begin<br> &nbsp; Reg:=TRegistry.Create;<br> &nbsp;try<br> &nbsp; &nbsp; Reg.RootKey:=HKEY_CURRENT_USER;<br> &nbsp; &nbsp; if Reg.OpenKey('/SOFTWARE/MICROSOFT/WINDOWS/CURRENTVERSION/RUN',True) then<br> &nbsp; &nbsp; begin<br> &nbsp; &nbsp; &nbsp; Reg.WriteString('路径','启动名');<br> &nbsp; &nbsp; &nbsp;end;<br> &nbsp; finally<br> &nbsp; &nbsp; Reg.CloseKey;<br> &nbsp; &nbsp; Reg.free;<br> &nbsp; end;<br>end;<br><br>我的系统是xp的,我用了关机函数,重启,结果都只是注销,这是为什么?<br>那位帮忙解答下<br>ExitWindowsEx(EWX_POWEROFF,8);关机并关掉电源<br>ExitWindowsEx(EWX_REBOOT,2); 重启<br>结果都是注销,没什么作用
 
关机函数我在98下可以实现<br>但是xp不知道为什么不行了
 
有人在没啊?<br><br>帮忙回答下啊
 
你用的关机的方法在NT内核的系统上是不行的<br>要先获得系统关机的权限才可以,否则就只能<br>是注销帐户。自己写的一个过程你可以看看<br>procedure ShutDown(Flag:word);<br>var<br> &nbsp;hToken:THANDLE;<br> &nbsp;tkp:TOKEN_PRIVILEGES;<br> &nbsp;Nothing:Cardinal;<br>begin<br> &nbsp;OpenProcessToken(GetCurrentProcess,TOKEN_ADJUST_PRIVILEGES or TOKEN_QUERY,hToken);<br> &nbsp;LookupPrivilegeValue(nil,'SeShutdownPrivilege',tkp.Privileges[0].Luid);<br> &nbsp;tkp.PrivilegeCount:= 1;<br> &nbsp;tkp.Privileges[0].Attributes:= SE_PRIVILEGE_ENABLED;<br> &nbsp;AdjustTokenPrivileges(hToken, FALSE, tkp, 0,nil, Nothing);<br> &nbsp;Case Flag of<br> &nbsp; &nbsp;1:ExitWindowsEx(EWX_POWEROFF,0);//关闭计算机并断开电源.<br> &nbsp; &nbsp;2:ExitWindowsEx(EWX_REBOOT,0);//重启计算机.<br> &nbsp; &nbsp;3:ExitWindowsEx(EWX_LOGOFF,0); //注销帐户.<br> &nbsp; &nbsp;4:SetSystemPowerState(True,True); &nbsp;//待机.<br> &nbsp; &nbsp;5:LockWorkStation; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//锁定计算机.<br> &nbsp;End;
 
加入启动项的代码,自己用是可以的<br> &nbsp; &nbsp; &nbsp; MyReg := TRegistry.Create;<br> &nbsp; &nbsp; &nbsp; MyReg.RootKey := HKEY_LOCAL_MACHINE;<br> &nbsp; &nbsp; &nbsp; if MyReg.OpenKey('/SOFTWARE/Microsoft/Windows/CurrentVersion/Run/',False) then<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;begin<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;MyReg.WriteString('名称',Application.ExeName);<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;MyReg.CloseKey;<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;MyReg.Free;<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end;
 
以前写过一段可以禁用任务管理器的代码不过只是通过改注册表来禁用,<br>没有本事真正的禁用。哪位大哥会的顺便说一声吧,谢了。<br>1.启用任务管理器<br>procedure Tfrmmain.m_AllowHotKeyClick(Sender: TObject);<br>var<br> reg:tregistry;<br>begin<br> reg:=tregistry.Create;<br> try<br> &nbsp; &nbsp;reg.RootKey:=HKEY_CURRENT_USER;<br> &nbsp; &nbsp;if reg.OpenKey('/software/microsoft/windows/currentversion/policies/system',true) then<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; reg.Writebool('disabletaskmgr',false);<br> &nbsp;except<br> &nbsp; &nbsp;reg.Free;<br> &nbsp;end;<br>end;<br>2.禁用任务管理器<br>procedure Tfrmmain.m_DisableHotKeyClick(Sender: TObject);<br>var<br> reg:tregistry;<br>begin<br> reg:=tregistry.Create;<br> try<br> &nbsp;reg.RootKey:=HKEY_CURRENT_USER;<br> &nbsp;if reg.OpenKey('/software/microsoft/windows/currentversion/policies/system',true) then<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;reg.Writebool('disabletaskmgr',true);<br>except<br> &nbsp;reg.Free;<br>end;<br>end;
 
禁用任务管理器方法<br>一、如楼上所说,修改注册表,不过会有messagebox弹出。<br>二、作一个监控程序,一旦发现任务管理器启动了就发消息关闭。(很不专业)<br>三、禁用ctrl+Alt+Del键,最好的方法,网上有现成的dll文件,拿过来就用。<br><br>关闭&重启计算机<br>unit Unit1;<br><br>interface<br><br>uses<br> &nbsp;Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,<br> &nbsp;Dialogs, StdCtrls;<br><br>type<br> &nbsp;TForm1 = class(TForm)<br> &nbsp; &nbsp;btnOK: TButton;<br> &nbsp; &nbsp;RadioButton1: TRadioButton;<br> &nbsp; &nbsp;RadioButton2: TRadioButton;<br> &nbsp; &nbsp;RadioButton3: TRadioButton;<br> &nbsp; &nbsp;procedure FormCreate(Sender: TObject);<br> &nbsp; &nbsp;procedure btnOKClick(Sender: TObject);<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.FormCreate(Sender: TObject);<br>var<br> &nbsp;hToken : THandle;<br> &nbsp;Tkp : TTokenPrivileges;<br> &nbsp;Zero:DWORD;<br>begin<br> &nbsp;OpenProcessToken(GetCurrentProcess(),TOKEN_ADJUST_PRIVILEGES or TOKEN_QUERY,hToken);<br> &nbsp;LookupPrivilegeValue(nil,'SeShutdownPrivilege',tkp.Privileges[0].Luid);<br> &nbsp;Tkp.PrivilegeCount :=1;<br> &nbsp;Tkp.Privileges[0].Attributes := SE_PRIVILEGE_ENABLED;<br> &nbsp;AdjustTokenPrivileges(hToken,False,Tkp,SizeOf(TTokenPrivileges),nil,Zero);<br>end;<br><br>procedure TForm1.btnOKClick(Sender: TObject);<br>begin<br> &nbsp; &nbsp;if self.RadioButton1.Checked then<br> &nbsp; &nbsp;begin<br> &nbsp; &nbsp; &nbsp; &nbsp;ExitWindowsEx(EWX_LOGOFF,0);<br> &nbsp; &nbsp;end;<br> &nbsp; &nbsp;if self.RadioButton2.Checked then<br> &nbsp; &nbsp;begin<br> &nbsp; &nbsp; &nbsp; &nbsp;ExitWindowsEx(EWX_REBOOT,0);<br> &nbsp; &nbsp;end;<br> &nbsp; &nbsp;if self.RadioButton3.Checked then<br> &nbsp; &nbsp;begin<br> &nbsp; &nbsp; &nbsp; &nbsp;ExitWindowsEx(EWX_SHUTDOWN or EWX_POWEROFF,0);<br> &nbsp; &nbsp;end;<br>end;<br>end.
 
楼上大哥说的是,能否说的清楚一些怎么屏蔽?<br>学习了
 
实在惭愧,我自己做的低级键盘钩子dll可以屏蔽其他所有系统键,但热启键一直没实现。<br>我从网上找到过一个用.net做的dll,实现了对热启键的屏蔽,你可以找找看。
 
多人接受答案了。
 
我现在可以写入启动组了,但是如果要运行的话,还出现数据库的路径错误问题,这个要怎么办?<br>好象注册表那里还写了一些东西.要怎么写才可以完整得运行?
 

Similar threads

后退
顶部