Jump to content


This is a ready-only archive of the InstallSite Forum. You cannot post any new content here. / Dies ist ein Archiv des InstallSite Forums. Hier können keine neuen Beiträge veröffentlicht werden.
Photo

How to Get Handle for Command Window


1 reply to this topic

girishkatti123

girishkatti123
  • Full Members
  • 5 posts

Posted 09 July 2009 - 12:57

Hi,
How can I get Handle for a Command Window
I used FindWindow("cmd",""). But it returns 0 always.

Can anyone suggest on this.

Thanks & Regards
Girish Katti

phood

phood
  • Full Members
  • 37 posts

Posted 17 July 2009 - 15:26

Girish,

Here you go:

CODE

#include "ifx.h"
#define CMD "C:\\WINDOWS\\system32\\cmd.exe"

export prototype ExFn_FindWindow();
function ExFn_FindWindow()
   NUMBER nMsg, nwParam, nlParam;
   HWND nHwnd;
begin
   Disable (BACKGROUND);
   if (LaunchApp (CMD, "") < 0 ) then
       MessageBox ("Unable to launch cmd.exe.", SEVERE);
       abort;
   endif;
   Delay (3);

   nHwnd = FindWindow ("", CMD);
   if (nHwnd = NULL) then
       MessageBox ("Unable to find the Notepad window.", SEVERE);
   else
    SendMessage (nHwnd, WM_SYSCOMMAND, SC_MAXIMIZE, 0);
    Delay (3);
    SendMessage (nHwnd, WM_SYSCOMMAND, SC_MINIMIZE, nlParam);
endif;
end;



I converted this from the Notepad example in the help. Note: I moved the CMD argument from the szClassName parameter to the szWinName one.

Good luck.

Pat