Click here to Skip to main content

C / C++ / MFC

   

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page  Show 
  Refresh
AnswerRe: Best way to check if a thread is still active c++ win32 Pinmemberjkirkerx15:18 21 Feb '12  
GeneralRe: Best way to check if a thread is still active c++ win32 Pinmember Randor 16:55 21 Feb '12  
GeneralRe: Best way to check if a thread is still active c++ win32 Pinmemberjkirkerx17:05 21 Feb '12  
AnswerRe: Best way to check if a thread is still active c++ win32 PinmemberChuck O'Toole14:29 21 Feb '12  
GeneralRe: Best way to check if a thread is still active c++ win32 Pinmemberjkirkerx15:28 21 Feb '12  
AnswerRe: Best way to check if a thread is still active c++ win32 PinmemberChuck O'Toole16:12 21 Feb '12  
AnswerComplete code for CreateProcess and loop Pinmemberjkirkerx15:26 21 Feb '12  
This is the complete code I wrote.
 
If no one has an objection to the GetExitCodeProcess in the loop, I'll stick with it because it works. I just thought it was completely wrong to use, or perhaps I'm just getting better at this.
 
if (CreateProcess(sz_SQLServer_Install_FileName, szParameters, NULL, NULL, FALSE, CREATE_DEFAULT_ERROR_MODE | NORMAL_PRIORITY_CLASS, 0, sz_SQLServer_Install_FolderPath, &si, &pi) ) {
        while(WAIT_TIMEOUT == WaitForSingleObject(pi.hProcess, 10)) {
            MSG oMSG;
            while(::PeekMessage(&oMSG, NULL, 0,0, PM_NOREMOVE)) {
                if(::GetMessage(&oMSG, NULL, 0,0) ) {
                    ::TranslateMessage(&oMSG);
                    ::DispatchMessage(&oMSG);
                }
                else {
                    break;
                }
 
                // Run the Cosmetics on the MDI Window
                if (ndx != 100) {
                    SendMessage(g_SQLServer_Install_Progress_Bar, PBM_SETPOS, (WPARAM)ndx, 0);
                    UpdateWindow(g_SQLServer_Install_MDIWindow);
                    Sleep(100);
                    ++ndx;
 
                }
                else {
                    if( iMO == 0 ) {
                        SetWindowText(g_SQLServer_Install_Progress_Text, L"Installation may take up to 30 minutes");
                        iMO = 1;
                    }
                    else {
                        SetWindowText(g_SQLServer_Install_Progress_Text, L"Installing Microsoft SQL Server Express 2008");
                        iMO = 0;
                    }
 
                    UpdateWindow(g_SQLServer_Install_MDIWindow);
                    ndx = 0;
                }
 
                // Check the process to see if it's still running
                GetExitCodeProcess(pi.hProcess, (unsigned long *)&exit_status);
                if (exit_status != 259)
                    break;
            }
        }
 
        GetExitCodeProcess(pi.hProcess, (unsigned long *)&exit_status);
        if (exit_status == 0) {
            // The program completed successfully
            SendMessage(g_SQLServer_Install_MDIWindow, WM_COMMAND, (WPARAM)g_SQLServer_Install_IDC_COMMAND, (LPARAM)g_SQLServer_Install_IDM_COMPLETE );
        }
        else {
            // The program was either canceled or failed for some reason
            SendMessage(g_SQLServer_Install_MDIWindow, WM_COMMAND, (WPARAM)g_SQLServer_Install_IDC_COMMAND, (LPARAM)g_SQLServer_Install_IDM_CANCEL );
        }
 
        CloseHandle(pi.hProcess);
        CloseHandle(pi.hThread);
        exitCode = 1;
        bResult = TRUE;

AnswerRe: Complete code for CreateProcess and loop PinmemberChuck O'Toole16:22 21 Feb '12  
AnswerRe: Complete code for CreateProcess and loop PinmemberChuck O'Toole16:34 21 Feb '12  
GeneralRe: Complete code for CreateProcess and loop Pinmemberjkirkerx16:50 21 Feb '12  
GeneralRe: Complete code for CreateProcess and loop Pinmember Randor 17:08 21 Feb '12  
GeneralRe: Complete code for CreateProcess and loop Pinmemberjkirkerx18:18 21 Feb '12  
GeneralRe: Complete code for CreateProcess and loop Pinmemberjkirkerx6:58 22 Feb '12  
QuestionDynamic linking vs dynamic loading Pinmemberelelont24:47 21 Feb '12  
QuestionRe: Dynamic linking vs dynamic loading PinmemberDavidCrow5:41 21 Feb '12  
AnswerRe: Dynamic linking vs dynamic loading PinPopularmemberChris Losinger5:47 21 Feb '12  
QuestionHow to increase concurrent rate of a server application Pingroupyu-jian3:30 21 Feb '12  
AnswerRe: How to increase concurrent rate of a server application PinmvpRichard MacCutchan5:20 21 Feb '12  
AnswerRe: How to increase concurrent rate of a server application [modified] Pinmember Randor 8:32 21 Feb '12  
QuestionWin7 - worker thread freeze on call to WaitForSingleObject PinmemberStan the man0:12 21 Feb '12  
AnswerRe: Win7 - worker thread freeze on call to WaitForSingleObject PinmemberJochen Arndt0:29 21 Feb '12  
GeneralRe: Win7 - worker thread freeze on call to WaitForSingleObject PinmemberStan the man1:31 21 Feb '12  
AnswerRe: Win7 - worker thread freeze on call to WaitForSingleObject Pinmemberbjorn_ht1:16 21 Feb '12  
AnswerRe: Win7 - worker thread freeze on call to WaitForSingleObject PinmemberErudite_Eric2:31 21 Feb '12  
QuestionInitializing base class data PinmemberSunilKrSingh3:46 20 Feb '12  

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

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


Advertise | Privacy | Mobile
Beta | 2.5.120517.1 | Last Updated 22 May 2012
Copyright © CodeProject, 1999-2012
All Rights Reserved. Terms of Use
Layout: fixed | fluid