?
Solved

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

Posted on 2001-06-15
8
Medium Priority
?
401 Views
Last Modified: 2010-05-18
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;
0
Comment
Question by:Rudy_Rai
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 22

Expert Comment

by:Mohammed Nasman
ID: 6195300
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
 
LVL 22

Expert Comment

by:Mohammed Nasman
ID: 6195349
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
 
LVL 3

Expert Comment

by:VSF
ID: 6195590
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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Author Comment

by:Rudy_Rai
ID: 6196850
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
 

Author Comment

by:Rudy_Rai
ID: 6196870
but if screen saver show, i still call another application
from my program

give me some example about it...
0
 

Author Comment

by:Rudy_Rai
ID: 6196998
can delphi hide icons(like my computer, my documents, recycle bin, etc) in display windows??
and show it again....

give me an example...

0
 
LVL 2

Expert Comment

by:danysz
ID: 6197214
listening......
0
 
LVL 22

Accepted Solution

by:
Mohammed Nasman earned 1000 total points
ID: 6197626
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

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

719 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question