ask about difunction ALT-TAB,CTRL-ALT-DEL,,shutdown, and taskbar(hide)

hi...

i want ask about disfunction ALT-TAB,CTRL-ALT-DEL, and start in taskbar (if i press key windows) ...

and make program about shutting down windows, taskbar hide, and screen saver windows will show if my program run (in form create)...

if i click button1.. screen saver will hide;
if i click button2... windows will shutdown;
if i click button3...taskbar will hide;
Rudy_RaiAsked:
Who is Participating?
 
Mohammed NasmanConnect With a Mentor Software DeveloperCommented:
Hello

  this procedure will show and hide the desktop

procedure ShowDesktop(const YesNo : boolean);
var h : THandle;
begin
 h := FindWindow('ProgMan', nil);
 h := GetWindow(h, GW_CHILD);
 if YesNo = True then
   ShowWindow(h, SW_SHOW)
 else
   ShowWindow(h, SW_HIDE);
end;

ShowDesktop(False);  //hide desktop
ShowDesktop(True);  //Show desktop

Mohammed
0
 
Mohammed NasmanSoftware DeveloperCommented:
Hello

  I don't have all the idea now, but i will give you some of them, and i will post the other soon, cuz i'm at weekend now

this procedure will disable ctrl+alt+del, u can enabled or disabled them by calling it with true or false

procedure SystemKeys(Disable: Boolean);
 var OldVal : LongInt;
begin
 SystemParametersInfo
    (SPI_SCREENSAVERRUNNING,
     Word(Disable),
     @OldVal,
     0);
end;
//==
SystemKeys(True); // to disabled ctrl+alt+del
SystemKeys(false); // to enabled ctrl+alt+del

and this procedure for show and hide taskbar

procedure ShowTaskBar(bShow: Boolean);
begin
if bShow = True then
 ShowWindow(FindWindow
  ('Shell_TrayWnd',nil), SW_SHOWNA)
else
 ShowWindow(FindWindow
  ('Shell_TrayWnd',nil), SW_HIDE);
end;


send me email at nasman@mogaza.org and i will send you the compelete project

Mohammed


0
 
Mohammed NasmanSoftware DeveloperCommented:
Hello

  Forget to include shut down procedure

procedure ShutDown;
begin
  ExitWindowsEx(EWX_SHUTDOWN, 0 );
end;


but if you don't want Windows does not send the  messages WM_QUERYENDSESSION and WM_ENDSESSION to the applications
and let ur applicatoin to forces processes to terminate.
currently running in the system. This can cause the applications to lose data.  Therefore, you should only use this flag in an emergency.    

change the flag to

  ExitWindowsEx(EWX_FORCE or EWX_SHUTDOWN, 0 );

Mohammed

0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
VSFCommented:
Here we go:
I think this can be of great value... take a look!Hope this helps!

VSF
www.enge.cjb.net
www,victory.hpg.com.br
UIN:14016999

OPEN START MENU
procedure TForm1.Button1Click(Sender: TObject);
begin  
  SendMessage(Form1.handle,WM_SYSCOMMAND,SC_TASKLIST,0);
end;
------------------------
TURN MONITOR ON/OFF
{turn monitor off}  

SendMessage(Application.Handle, WM_SYSCOMMAND, SC_MONITORPOWER, 0);  
   
{turn monitor on}  

SendMessage(Application.Handle, WM_SYSCOMMAND, SC_MONITORPOWER, -1);
-----------------------
ENABLE AND DISABLE CD AUTORUN
procedure TForm1.SetCDAutoRun(AAutoRun:Boolean);  
const DoAutoRun : array[Boolean] of Integer = (0,1);  
var Reg:TRegistry;  
begin  
  try Reg := TRegistry.Create;  
  Reg.RootKey := HKEY_LOCAL_MACHINE;  
  if Reg.KeyExists('System\CurrentControlSet\Services\Class\CDROM') then  
  begin  
    if Reg.OpenKey('System\CurrentControlSet\Services\Class\CDROM',FALSE) then  
    Reg.WriteBinaryData('AutoRun',DoAutoRun[AAutoRun],1);  

  finally  
  Reg.Free;  
  end;  
  ShowMessage('Your settings will take effect on the next reboot of    Windows.');  
end;
---------------------------
PREVENT CTRL+ALT+DEL
VAR  
    OldValue:Longbool;  

{on}  

SystemParametersInfo(97,Word(True),@OldValue,0);  
   

{off}  
SystemParametersInfo(97,Word(False),@OldValue,0);
----------------------------
SUSPEND THE PC
SetSystemPowerState(FALSE,FALSE);
----------------------
...shutdown / reboot / logoff WIndows 9x / NT / Me / 2000 ?

program shutdown;
{$APPTYPE CONSOLE}
uses
  SysUtils,
  Windows;

// Shutdown Program
// (c) 2000 NeuralAbyss Software
// www.neuralabyss.com 

var
   logoff: boolean = false;
   reboot: boolean = false;
   warn: boolean = false;
   downQuick: boolean = false;
   cancelShutdown: boolean = false;
   powerOff: boolean = false;
   timeDelay: integer = 0;

function HasParam(Opt: Char): Boolean;
var
   x: integer;
begin
     result := false;
     for x := 1 to paramCount do
         if (paramstr(x) = '-'+opt) or (paramstr(x) = '/'+opt) then result := true;
end;

function GetErrorString: String;
var
   lz: Cardinal;
   err: array[0..512] of Char;
begin
     lz := GetLastError;
     FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, nil, lz, 0, @err, 512, nil);
     result := string(err);
end;

procedure DoShutdown;
var
   rl,flgs: Cardinal;
   hToken: Cardinal;
   tkp: TOKEN_PRIVILEGES;
begin
     flgs := 0;
     if downQuick then flgs := flgs or EWX_FORCE;
     if not reboot then flgs := flgs or EWX_SHUTDOWN;
     if reboot then flgs := flgs or EWX_REBOOT;
     if poweroff and (not reboot) then flgs := flgs or EWX_POWEROFF;
     if logoff then flgs := (flgs and (not (EWX_REBOOT or EWX_SHUTDOWN or EWX_POWEROFF))) or EWX_LOGOFF;
     if Win32Platform = VER_PLATFORM_WIN32_NT then begin
        if not OpenProcessToken(GetCurrentProcess, TOKEN_ADJUST_PRIVILEGES or TOKEN_QUERY, hToken) then
           Writeln('Cannot open process token. ['+GetErrorString+']')
        else begin
             if LookupPrivilegeValue(nil, 'SeShutdownPrivilege', tkp.Privileges[0].Luid) then begin
             tkp.Privileges[0].Attributes := SE_PRIVILEGE_ENABLED;
             tkp.PrivilegeCount := 1;
             AdjustTokenPrivileges(hToken, False, tkp, 0, nil, rl);
             if GetLastError <> ERROR_SUCCESS then
                   Writeln('Error adjusting process privileges.');
             end else Writeln('Cannot find privilege value. ['+GetErrorString+']');
        end;
{        if CancelShutdown then
           if AbortSystemShutdown(nil) = False then
              Writeln(\'Cannot abort. [\'+GetErrorString+\']\')
           else
               Writeln(\'Cancelled.\')
        else begin
             if InitiateSystemShutdown(nil, nil, timeDelay, downQuick, Reboot) = False then
                Writeln(\'Cannot go down. [\'+GetErrorString+\']\')
             else
                 Writeln(\'Shutting down!\');
        end;}
     end;
//     else begin
          ExitWindowsEx(flgs, 0);
//     end;
end;

begin
     Writeln('Shutdown v0.3 for Win32 (similar to the Linux version)');
     Writeln('(c) 2000 NeuralAbyss Software. All Rights Reserved.');
     if HasParam('?') or (ParamCount=0) then begin
        Writeln('Usage:    shutdown [-akrhfnc] [-t secs]');
        Writeln('                  -k:      don''t really shutdown, only warn.');
        Writeln('                  -r:      reboot after shutdown.');
        Writeln('                  -h:      halt after shutdown.');
        Writeln('                  -p:      power off after shutdown');
        Writeln('                  -l:      log off only');
        Writeln('                  -n:      kill apps that don''t want to die.');
        Writeln('                  -c:      cancel a running shutdown.');
     end else begin
         if HasParam('k') then warn := true;
         if HasParam('r') then reboot := true;
         if HasParam('h') and reboot then begin
            Writeln('Error: Cannot specify -r and -h parameters together!');
            Exit;
         end;
         if HasParam('h') then reboot := false;
         if HasParam('n') then downQuick := true;
         if HasParam('c') then cancelShutdown := true;
         if HasParam('p') then powerOff := true;
         if HasParam('l') then logoff := true;
         DoShutdown;
     end;
end.
---------------------
...disable / enable / hide / show taskbar ?
 
This is very easy. All that you have to do is obtain the window handle
of the taskbar window and then you can disable or hide it.
The window handle is obtained like this :

var
  HTaskbar : HWND;
begin
  HTaskBar:=FindWindow('Shell_TrayWnd',nil);

Now you have the window handle, you can use it to disable or hide the taskbar :

  EnableWindow(HTaskBar,False); //Disable the taskbar
  EnableWindow(HTaskBar,True); //Enable the taskbar
  ShowWindow(HTaskbar,SW_HIDE); //Hide the taskbar
  ShowWindow(HTaskbar,SW_SHOW); //Show the taskbar
-------------------
 Shutting down
     function ExitWindowsEx(uFlags : integer; dwReserved : word) : boolean;
      external 'user32.dll' name 'ExitWindowsEx';

      procedure Tchau;
      const
        EWX_LOGOFF = 0; // "logoff"
        EWX_SHUTDOWN = 1; // Regular Shutdown
        EWX_REBOOT = 2; // "reboot"                        EWX_FORCE = 4; // finish all process
        EWX_POWEROFF = 8; // turn off/on

      begin
        ExitWindowsEx(EWX_FORCE, 0);
      end;
\
0
 
Rudy_RaiAuthor Commented:
how about ALT_TAB and hide/show screen saver for windows..

or if i run my application, screen saver will show (with color black). if i click button1 display windows will show..(or screen saver will hide)...
0
 
Rudy_RaiAuthor Commented:
but if screen saver show, i still call another application
from my program

give me some example about it...
0
 
Rudy_RaiAuthor Commented:
can delphi hide icons(like my computer, my documents, recycle bin, etc) in display windows??
and show it again....

give me an example...

0
 
danyszCommented:
listening......
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.