Delphi 如何禁用启动某些应用程序?
是否有办法阻止启动某些应用程序 1) 我不想让用户启动记事本。exe:可能吗 2) 是否可以禁止除“notepad.exe”之外的所有应用程序启动 谢谢一种方法可能是Delphi 如何禁用启动某些应用程序?,delphi,delphi-xe2,delphi-2010,Delphi,Delphi Xe2,Delphi 2010,是否有办法阻止启动某些应用程序 1) 我不想让用户启动记事本。exe:可能吗 2) 是否可以禁止除“notepad.exe”之外的所有应用程序启动 谢谢一种方法可能是 procedure KillProcess(hWindowHandle: HWND); var hprocessID: INTEGER; processHandle: THandle; DWResult: DWORD; begin SendMessageTimeout(hWindowHandle, WM_CLOSE
procedure KillProcess(hWindowHandle: HWND);
var
hprocessID: INTEGER;
processHandle: THandle;
DWResult: DWORD;
begin
SendMessageTimeout(hWindowHandle, WM_CLOSE, 0, 0,
SMTO_ABORTIFHUNG or SMTO_NORMAL, 5000, DWResult);
if isWindow(hWindowHandle) then
begin
// PostMessage(hWindowHandle, WM_QUIT, 0, 0);
{ Get the process identifier for the window}
GetWindowThreadProcessID(hWindowHandle, @hprocessID);
if hprocessID <> 0 then
begin
{ Get the process handle }
processHandle := OpenProcess(PROCESS_TERMINATE or PROCESS_QUERY_INFORMATION,
False, hprocessID);
if processHandle <> 0 then
begin
{ Terminate the process }
TerminateProcess(processHandle, 0);
CloseHandle(ProcessHandle);
end;
end;
end;
end;
午餐与Launch不一样这与Delphi或一般编程没有什么关系。这似乎与Windows中的用户权限有关,可能与kiosk模式有关。如果不允许任何人启动记事本,请删除它。是的,域策略允许。与[delphi]无关,您可以尝试使用
KillProcess(FindWindow('notepad',nil));