Click here to Skip to main content
15,918,275 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Enter to Select button Pin
Alvaro Mendez24-Feb-03 9:05
Alvaro Mendez24-Feb-03 9:05 
GeneralRe: Enter to Select button Pin
valikac24-Feb-03 9:23
valikac24-Feb-03 9:23 
GeneralRe: Enter to Select button Pin
sstiller26-Feb-03 19:09
sstiller26-Feb-03 19:09 
GeneralDelete a security group in VC 7.0 Pin
Member 13661824-Feb-03 5:49
Member 13661824-Feb-03 5:49 
GeneralRe: Delete a security group in VC 7.0 Pin
Dana Epp24-Feb-03 7:59
Dana Epp24-Feb-03 7:59 
Generallaunching dos programs(gui) Pin
eggman2124-Feb-03 5:39
eggman2124-Feb-03 5:39 
GeneralRe: launching dos programs(gui) Pin
jmkhael24-Feb-03 5:43
jmkhael24-Feb-03 5:43 
GeneralRe: launching dos programs(gui) Pin
eggman2124-Feb-03 7:04
eggman2124-Feb-03 7:04 
Thanks, I did a search for that lot and I found

In CSomeDlg.h<br />
static BOOL CALLBACK EnumWindowsProc(HWND hwnd, LPARAM lParam);<br />
DWORD processPid;<br />
<br />
In CSomeDlg.cpp<br />
void CSomeDlg::startProcess()<br />
{<br />
  BOOL bWorked;<br />
  STARTUPINFO suInfo;<br />
  PROCESS_INFORMATION procInfo;<br />
  CString m_Process = "C:\\wherever\\process\\we\\want\\to\\start.exe";<br />
  char *vip =  "C:\\wherever\\process\\we\\want\\to\\start.exe whatever command line arguments here";<br />
<br />
  memset (&suInfo, 0, sizeof(suInfo));<br />
  suInfo.cb = sizeof(suInfo);<br />
<br />
  bWorked = ::CreateProcess(m_Process,<br />
             vip,      // can also be NULL<br />
             NULL,<br />
             NULL,<br />
             FALSE,<br />
             NORMAL_PRIORITY_CLASS,<br />
             NULL,<br />
             NULL,<br />
             &suInfo,<br />
             &procInfo);<br />
<br />
/*<br />
procInfo has these members<br />
    HANDLE hProcess;   // process handle<br />
    HANDLE hThread;    // primary thread handle<br />
    DWORD dwProcessId; // process PID<br />
    DWORD dwThreadId;  // thread ID<br />
*/<br />
<br />
  if (procInfo.dwThreadId = NULL)<br />
  {<br />
     MessageBox("nope");<br />
  }<br />
<br />
  playerPid = procInfo.dwProcessId;<br />
}<br />
<br />
<br />
<br />
void CSomeDlg::killProcess()<br />
{<br />
  HANDLE ps = OpenProcess( SYNCHRONIZE|PROCESS_TERMINATE, FALSE, processPid);<br />
  // processPid = procInfo.dwProcessId;<br />
<br />
  //  This function enumerates all widows, using the EnumWindowsProc callback<br />
  //  function, passing the PID of the process you started earlier.<br />
  EnumWindows(EnumWindowsProc, processPid);<br />
<br />
  CloseHandle(ps) ;<br />
}<br />
<br />
BOOL CALLBACK CSomeDlg::EnumWindowsProc(HWND hwnd, LPARAM lParam)<br />
{<br />
  DWORD wndPid;<br />
  CString Title;<br />
  // lParam = procInfo.dwProcessId;<br />
<br />
  //  This gets the windows handle and pid of enumerated window.<br />
  GetWindowThreadProcessId(hwnd, &wndPid);<br />
<br />
  //  This gets the windows title text from the window, using the window handle<br />
  CWnd::FromHandle( hwnd )->GetWindowText(Title);<br />
<br />
  //  this makes sure that the PID matches that PID we started, and window<br />
  // text exists, before we kill it . I don't think this is really needed, <br />
  // I included it because some apps have more than one window.<br />
  if ( wndPid == (DWORD)lParam && Title.GetLength() != 0)<br />
  {<br />
    //  Please kindly close this process<br />
    ::PostMessage(hwnd, WM_CLOSE, 0, 0);<br />
    return false;<br />
  }<br />
  else<br />
  {<br />
    // Keep enumerating<br />
    return true;<br />
  }<br />
}<br />
<br />


but I'm quite a newbie can someone help me fill in the blanks (like what other headers I need to include and what to put in the main() or winmain() body).confused:

Anyone?Blush | :O
GeneralRe: launching dos programs(gui) Pin
Dana Epp24-Feb-03 14:46
Dana Epp24-Feb-03 14:46 
GeneralRe: launching dos programs(gui) Pin
eggman2125-Feb-03 5:05
eggman2125-Feb-03 5:05 
Generalsimple C function question Pin
Maximilien24-Feb-03 5:33
Maximilien24-Feb-03 5:33 
GeneralRe: simple C function question Pin
jmkhael24-Feb-03 5:36
jmkhael24-Feb-03 5:36 
GeneralCTime question Pin
Anonymous24-Feb-03 4:53
Anonymous24-Feb-03 4:53 
GeneralRe: CTime question Pin
João Paulo Figueira24-Feb-03 5:09
professionalJoão Paulo Figueira24-Feb-03 5:09 
GeneralRe: CTime question Pin
jhwurmbach24-Feb-03 5:09
jhwurmbach24-Feb-03 5:09 
GeneralRe: CTime question Pin
Alvaro Mendez24-Feb-03 5:25
Alvaro Mendez24-Feb-03 5:25 
GeneralRe: CTime question Pin
Anonymous24-Feb-03 5:27
Anonymous24-Feb-03 5:27 
GeneralRe: CTime question Pin
Dave_24-Feb-03 9:39
Dave_24-Feb-03 9:39 
GeneralCopy constructor Pin
Jerome Conus24-Feb-03 4:27
Jerome Conus24-Feb-03 4:27 
GeneralRe: Copy constructor Pin
João Paulo Figueira24-Feb-03 4:37
professionalJoão Paulo Figueira24-Feb-03 4:37 
GeneralRe: Copy constructor Pin
Jerome Conus24-Feb-03 4:43
Jerome Conus24-Feb-03 4:43 
GeneralRe: Copy constructor Pin
João Paulo Figueira24-Feb-03 4:50
professionalJoão Paulo Figueira24-Feb-03 4:50 
GeneralRe: Copy constructor Pin
Jerome Conus24-Feb-03 4:53
Jerome Conus24-Feb-03 4:53 
GeneralRe: Copy constructor Pin
João Paulo Figueira24-Feb-03 5:02
professionalJoão Paulo Figueira24-Feb-03 5:02 
GeneralRe: Copy constructor Pin
Jerome Conus24-Feb-03 5:06
Jerome Conus24-Feb-03 5:06 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.