Click here to Skip to main content
15,911,646 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRICHDIT Background Pin
Eric29-May-00 16:20
Eric29-May-00 16:20 
GeneralAccessing Newly creating file Pin
Member 398529-May-00 12:15
Member 398529-May-00 12:15 
GeneralRe: Accessing Newly creating file Pin
Uwe Keim29-May-00 20:51
sitebuilderUwe Keim29-May-00 20:51 
GeneralRe: Accessing Newly creating file Pin
Member 398530-May-00 12:39
Member 398530-May-00 12:39 
GeneralSound programming related question Pin
bwhoney29-May-00 12:10
sussbwhoney29-May-00 12:10 
GeneralClosing a program Launched with ShellExecute Pin
Alfadhly29-May-00 10:31
sussAlfadhly29-May-00 10:31 
GeneralRe: Closing a program Launched with ShellExecute Pin
Uwe Keim29-May-00 20:47
sitebuilderUwe Keim29-May-00 20:47 
GeneralRe: Closing a program Launched with ShellExecute Pin
Paolo Messina30-May-00 10:50
professionalPaolo Messina30-May-00 10:50 
Try with this code:
(then you may post a WM_QUIT message to that window)

// start an application given its full path
// and gets the main window, which is initially hidden

// NULL if some errors occurred or
// main window could not be determined

HWND StartApp(LPCTSTR path);

#define TIMEOUT 20*1000

struct ProcessWindow
{
DWORD processID;
DWORD threadID;
HWND hwnd;
};

static BOOL CALLBACK EnumWindowsProc(
HWND hwnd, // handle to the window
ProcessWindow *lParam // application-defined value
)
{
DWORD processID = NULL;
DWORD threadID = GetWindowThreadProcessId(hwnd, &processID);

if (processID == lParam->processID && threadID == lParam->threadID)
{
lParam->hwnd = hwnd;
return FALSE; // stop enum
}

return TRUE;
}

HWND StartApp(LPCTSTR path)
{
STARTUPINFO si;
ZeroMemory(&si, sizeof(STARTUPINFO));

si.cb = sizeof(STARTUPINFO);
si.dwFlags = STARTF_USESHOWWINDOW | STARTF_USESTDHANDLES;
si.wShowWindow = SW_HIDE;

PROCESS_INFORMATION pi;

TCHAR buf[MAX_PATH];
lstrcpyn(buf, path, MAX_PATH);

if (!CreateProcess(NULL, buf, NULL, NULL, FALSE, CREATE_DEFAULT_ERROR_MODE |
NORMAL_PRIORITY_CLASS, NULL, NULL, &si, &pi))
return NULL;

if(WaitForInputIdle(pi.hProcess, TIMEOUT) != 0)
return NULL;

// get the main window

ProcessWindow pw;
pw.hwnd = NULL;
pw.processID = pi.dwProcessId;
pw.threadID = pi.dwThreadId;

if (EnumWindows((WNDENUMPROC)EnumWindowsProc, (LPARAM)(LPVOID)&pw))
return NULL;

return pw.hwnd;
}

GeneralRe: Closing a program Launched with ShellExecute Pin
Dennis Little1-Jun-00 10:08
sussDennis Little1-Jun-00 10:08 
GeneralDialog On Top Pin
Member 434829-May-00 7:02
Member 434829-May-00 7:02 
GeneralRe: Dialog On Top Pin
Mike Dunn29-May-00 18:38
Mike Dunn29-May-00 18:38 
QuestionHow To : center a CFormView in a SDI app ??? Pin
Luc Bergeron29-May-00 6:57
Luc Bergeron29-May-00 6:57 
AnswerRe: How To : center a CFormView in a SDI app ??? Pin
Cristi Posea30-May-00 21:02
Cristi Posea30-May-00 21:02 
AnswerRe: How To : center a CFormView in a SDI app ??? Pin
Kurt2-Jun-00 2:38
Kurt2-Jun-00 2:38 
GeneralRe: How To : center a CFormView in a SDI app ??? Pin
Member 7505-Jun-00 18:18
Member 7505-Jun-00 18:18 
GeneralEncrypt/Decrypting Files (CR & LF chars not correct in .exes) Pin
daniel madden28-May-00 23:34
daniel madden28-May-00 23:34 
GeneralRe: Encrypt/Decrypting Files (CR & LF chars not correct in .exes) Pin
Chris Meech29-May-00 3:35
Chris Meech29-May-00 3:35 
GeneralRe: Encrypt/Decrypting Files (CR & LF chars not correct in .exes) Pin
Member 7505-Jun-00 18:22
Member 7505-Jun-00 18:22 
GeneralADO. Could not update recordset Pin
bbw28-May-00 17:13
bbw28-May-00 17:13 
QuestionHow can I print an adobe pdf as a boilerplate? Pin
Erich J. Ruth28-May-00 9:55
sussErich J. Ruth28-May-00 9:55 
AnswerRe: How can I print an adobe pdf as a boilerplate? Pin
Mike Dunn28-May-00 16:43
Mike Dunn28-May-00 16:43 
GeneralRe: How can I print an adobe pdf as a boilerplate? Pin
Erich J. Ruth29-May-00 11:52
sussErich J. Ruth29-May-00 11:52 
GeneralRe: How can I print an adobe pdf as a boilerplate? Pin
Mike Dunn29-May-00 18:29
Mike Dunn29-May-00 18:29 
AnswerRe: How can I print an adobe pdf as a boilerplate? Pin
Member 120896530-May-00 14:08
Member 120896530-May-00 14:08 
AnswerRe: How can I print an adobe pdf as a boilerplate? Pin
Cristi Posea30-May-00 21:34
Cristi Posea30-May-00 21:34 

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.