Windows systems dialogs

The windows dialogs that microsoft forgot to document

Most of us have seen these dialogs in windows and most ms programs here is a way to get in touch with most of these:

1) Exit windows Dialog presented when you go to start menu and select shutdown. the handle parameter is unused in windows NT on windows 95 you get a WM_QUIT in the wndproc, however if you assign an event in OnCloseQuery will do.

  procedure ExitWindowsDialog(Handle: THandle); stdcall; external 'shell32.dll' index 60; //API declaration

Sample use:

procedure TForm1.Button1Click(Sender: TObject);




2) Restart windows dialog is presented whenever a system wide change (mostly with drivers), the flags parameter the handle is used to know the owner of the window the reason is a string wich is shown in the dialog (hint: use a carriage return to break text into lines) the flags correspond to any ExitWindowsEx or ExitWindows flag (they start most with EW_XXX or EWX_XXX)

  function RestartWindowsDialog(Handle: THandle; Reason: PChar; Flags: Integer): Integer; stdcall; external 'shell32.dll' index 59;

Sample use:

procedure TForm1.Button2Click(Sender: TObject);


  RestartWindowsDialog(Handle, PCHAR('ME DIO LA GANA'), EW_RESTARTWINDOWS);


3)Picking an icon dialog is the one shown whenever u want to select an icon in the windows environment, filename specifies the filename from where to extract icons, filenamesize is the length of the string (typically Length(Filename) assuming Filename as string), IconIndex is a variable wich receives the iconindex selected in the dialog. the return value of the function is true if the dialog is successful and the ok button is selected, false if the cancel button is pressed

  function PickIconDialog(Handle:THandle; FileName:PChar; FileNameSize:integer;var IconIndex:integer):Boolean; stdcall; external 'shell32.dll' index 62;

Sample use:

procedure TForm1.Button3Click(Sender: TObject);


  IconIndex: Integer;


  if PickIconDialog(Handle, PChar('shell32.dll'), Length('shell32.dll'), IconIndex) then

    ShowMessage('Selecciono ' + IntTOStr(IconIndex));


4) Run file dialog is executed whenever you select start menu execute, and is also seen in windows media player and internet explorer. here is the api that will do the trick

  procedure RunDialog(Handle: THandle; Icon: HIcon; Directory: PChar; Title: PChar; Description: PChar; Flags: Integer); stdcall; external 'shell32.dll' index 61;

Sample use:

procedure TForm1.Button4Click(Sender: TObject);


  RunDialog(Handle, Icon.Handle, PCHAR('C:'), PCHAR('SELECT THAT DAMNED FILE'),



this dialog uses the following constants


  REF_NOBROWSE = 1; //Disable browse button


  REF_CALCDIRECTORY = 4; //calculate the directory based on the owners path

  REF_NOLABEL = 8; //No description label

  REF_NOSEPARATEMEM = $20; //No sepated memory checkbox (NT Only)

in case you use NT replace all pchar by PWChar

This is it by now in my next article I will create object wrappers for these functions, you will find the wrapper for the run dialog very useful


Share this article!

Follow us!

Find more helpful articles: