i have made a screensaver and what i want is to disable alt-tab, ctrl-esc, the windows button (the one between ctrl and alt i mean)

ive tryed using many different versions of

SystemParametersInfo( SPI_SCREENSAVERRUNNING, integer(true), @i, 0);
SystemParametersInfo( SPI_SETFASTTASKSWITCH, 1, @i, 0);

but its not working on xp and vista...

i would appreiciate the help if any now how to make a screensaver run in xp and vista.

best regards,
Darkyere

Dani AI

Generated

— the short answer: run the screensaver as a real screensaver process and handle the key blocking inside that process with a low‑level keyboard hook. The OS will not honor the old SystemParametersInfo tricks on NT‑based systems; Ctrl+Alt+Del is the Secure Attention Sequence and cannot be caught by a user process. See the Windows screensaver guidance and the desktop/Winlogon behavior for background. (Screensaver sample) (Initializing Winlogon / SAS).

Why the simple tricks failed

  • On XP/Vista you cannot reliably disable system task switching by flipping a SystemParametersInfo flag — that was a Win9x-era trick. On NT family OSes the supported way to intercept Alt+Tab, Ctrl+Esc and the Windows key is a low‑level keyboard hook (WH_KEYBOARD_LL). That is what people use for kiosk/shell-replacement scenarios. (MSDN Magazine / low‑level hook discussion) (LowLevelKeyboardProc docs).

Delphi 2009 sketch (install in the screensaver process)

const
  WH_KEYBOARD_LL = 13;
  LLKHF_ALTDOWN  = $20;

var
  gHook: HHOOK = 0;

function LowLevelKeyboardProc(nCode: Integer; wParam: WPARAM; lParam: LPARAM): LRESULT; stdcall;
var
  p: PKBDLLHOOKSTRUCT;
begin
  if (nCode = HC_ACTION) then
  begin
    p := PKBDLLHOOKSTRUCT(lParam);
    // Alt+Tab
    if (p^.vkCode = VK_TAB) and ((p^.flags and LLKHF_ALTDOWN) <> 0) then Exit(1);
    // Ctrl+Esc
    if (p^.vkCode = VK_ESCAPE) and ((GetAsyncKeyState(VK_CONTROL) and $8000) <> 0) then Exit(1);
    // Windows key
    if (p^.vkCode = VK_LWIN) or (p^.vkCode = VK_RWIN) then Exit(1);
  end;
  Result := CallNextHookEx(gHook, nCode, wParam, lParam);
end;

procedure InstallHook;
begin
  if gHook = 0 then
    gHook := SetWindowsHookEx(WH_KEYBOARD_LL, @LowLevelKeyboardProc, HInstance, 0);
end;

procedure UninstallHook;
begin
  if gHook <> 0 then UnhookWindowsHookEx(gHook);
end;

Troubleshooting and cautions

  • Install the hook from the screensaver process (the active desktop matters — secure screensavers may run on the ScreenSaver desktop). (Desktops / WinSta0)
  • Do minimal work inside the hook; the system drops slow hooks.
  • Ctrl+Alt+Del cannot be suppressed by a user app (it is handled by Winlogon/kernel). (Initializing Winlogon)
  • Vista changed login/GINA behavior, so solutions that target GINA work on XP but not on Vista+. (See the Winlogon/GINA notes in MS docs.)
  • If this is for a kiosk, consider a supported kiosk/shell replacement or Group Policy rather than fighting system hotkeys.

References: Microsoft screensaver sample and docs on desktops, low‑level keyboard hooks, and Winlogon cited above. For context on the posts in this thread: pointed out the installer/name issue, and / were right — a proper screensaver needs to follow Windows expectations rather than rely on one-liners.

Recommended Answers

All 5 Replies

rename your .exe to be .scr and it should simply just work

rename your .exe to be .scr and it should simply just work

sry. but ive allredy doing that when im puplishing ht e product and that doesnt work.

there most be some way to make my program run as a screensaver... i know there must be whit all these screensavers out there some must be made in delphi.

well hope someone know the answer

best regards,
darkyere

There are plenty, however, ive not tried running them under vista.

Try posting on the embarcadero forums - if anyones going to know people there will.

Yep, screen savers have specific functions in such as the config screen etc. I know Ive written a few following various googled tutorials in the past, so have a google.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.