-2

I'm developing a VCL Form Application

When the application started

I need to prevent the user of the computer to do anything

He can't close the application by ALT+F4 or CTRL+ALT+DEL

He can't change to another window by ALT+Tab

He can't Go to the desktop by clicking Windows + D

This will used in Cyber Cafe and it is a Server/Client application

so before the Admin in the Server giving access to the Client, He can't do anything in the computer .. just a full screen for my form

SystemX
  • 481
  • 4
  • 10

1 Answers1

1

Because it is the login system of Windows that traps the CTRL-ALT-DEL combination (and so it is not accessible to user applications), you will need to change the system's keyboard scancode map to ignore at least one of those keys.

First you have to ensure Autologon on your computer, else you can login. This could also be done in the registry.

Then the tricky part editing the scancode map. In MSDN you'll find an article about how to do: https://msdn.microsoft.com/en-us/library/windows/hardware/jj128267%28v=vs.85%29.aspx?f=255&MSPPError=-2147217396

I've found this reg file that is suppose to disable CTRL + ALT + DELETE but I havent tested it

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout]
"Scancode Map"=hex:00,00,00,00,00,00,00,00,03,00,00,00,00,00,38,00,00,00,38,e0,\
  00,00,00,00

Be aware that this is extremely hirisk. Both using the REG file and changing the scancode map. I suggest you test your stuff in a virtual Machine.

You also need to prevent the user from shuttingdown the computer. Which is also done in registry:

User Key: [HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\
Explorer]
System Key: [HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\
Explorer]
Value Name: NoClose
Data Type: REG_DWORD (DWORD Value)
Value Data: (0 = shutdown enabled, 1 = shutdown disabled)

So inorder for shuttingdown the computer your probram must make a call to ShutdownwindowsEx

function ExitWindows(iFlags: Integer): Boolean;
var
  osVerInfo: TOSVersionInfo;

  function SetPrivilege(sPrivilegeName: string; bEnabled: Boolean): Boolean;
  var
    TPPrev, TP: TTokenPrivileges;
    Token: THandle;
    dwRetLen: DWord;
  begin
    Result := False;
    OpenProcessToken(GetCurrentProcess, TOKEN_ADJUST_PRIVILEGES or TOKEN_QUERY, Token);
    TP.PrivilegeCount := 1;
    if (LookupPrivilegeValue(nil, PChar(sPrivilegeName), TP.Privileges[0].LUID)) then
    begin
      if (bEnabled) then
        TP.Privileges[0].Attributes := SE_PRIVILEGE_ENABLED
      else
        TP.Privileges[0].Attributes := 0;
      dwRetLen := 0;
      Result := AdjustTokenPrivileges(Token, False, TP, sizeof(TPPrev), TPPrev, dwRetLen);
    end;
    CloseHandle(Token);
  end;

begin
  Result := True;
  osVerInfo.dwOSVersionInfoSize := sizeof(TOSVersionInfo);
  if GetVersionEx(osVerInfo) then
    case osVerInfo.dwPlatformId of
      VER_PLATFORM_WIN32_WINDOWS:
        if not ExitWindowsEx(iFlags, 0) then
          Result := False; // handle errors...
      VER_PLATFORM_WIN32_NT:
        if SetPrivilege('SeShutdownPrivilege', True) then
        begin
          if not ExitWindowsEx(iFlags, 0) then
            Result := False; // handle errors...
          SetPrivilege('SeShutdownPrivilege', False)
        end
        else
          Result := False; // handle errors...
    else
      Result := False;
    end;
end;
Jens Borrisholt
  • 6,174
  • 1
  • 33
  • 67