Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9121665
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T05:54:50+00:00 2026-06-17T05:54:50+00:00

I want to launching a sub application from the main application using CreateProcess function

  • 0

I want to launching a sub application from the main application using CreateProcess function with the following steps:

  1. launched a sub .exe program from the main without window for the sub program
  2. wait for rand Sleep
  3. then terminate the sub application first then the main.

In the following my example code for the above but the sub program running with window(in this case NotePad) and i can’t terminate the sub program.

#include "stdafx.h"
#include <windows.h>
#include <conio.h>
#include <strsafe.h>
#include <direct.h>
#include <string.h>

int main(int argc, char* argv[])
{   

HWND                hWnd;
STARTUPINFO         sInfo;
PROCESS_INFORMATION pInfo;

ZeroMemory(&sInfo, sizeof(sInfo));
sInfo.cb = sizeof(sInfo);
ZeroMemory(&pInfo, sizeof(pInfo));

if (CreateProcess("C:\\WINDOWS\\System32\\notepad.exe", NULL, NULL, NULL, false, CREATE_NO_WINDOW, NULL, NULL, &sInfo, &pInfo))
{
    printf("Sleeping 100ms...\n");
    Sleep(100);

    DWORD dwExitCode;
    GetExitCodeProcess(pInfo.hProcess, &dwExitCode);

    CloseHandle(pInfo.hThread);
    CloseHandle(pInfo.hProcess);

    }

system("pause");

return 0;

 }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T05:54:51+00:00Added an answer on June 17, 2026 at 5:54 am

    The reason the notepad window shows is because it’s not a console application. MSDN says this about CREATE_NO_WINDOW:

    The process is a console application that is being run without a console window. Therefore, the console handle for the application is not set.
    This flag is ignored if the application is not a console application, or if it is used with either CREATE_NEW_CONSOLE or DETACHED_PROCESS.

    Instead, use the STARTUPINFO you pass in:

    sInfo.dwFlags = STARTF_USESHOWWINDOW;
    sInfo.wShowWindow = SW_HIDE;
    

    I believe that will affect the last argument to WinMain in Notepad’s main function, but I’m not sure.

    As for why notepad doesn’t close, GetExitCodeProcess doesn’t actually end the process, it just retrieves the state. You can use TerminateProcess instead:

    TerminateProcess(pInfo.hProcess, 0);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am launching a process from my application using CreateProcess API and I want
I'm launching a Java process (java.exe) from .Net. using Process.Start() . In addition to
I want to write an application that can prevent some application from launching. My
I want to capture output from a C program I'm launching like this: p
I'm launching a form from another form. I want the parent form to be
Want to run javascript function from parent window in child window Example I have
I want to implement Facebook login using dialog, not by automatic launching of the
I want to know if it's possible in android to start application using QR
I want to display the launching image(640x960) of my app on my main view
After launching an application using the Process class I'd like to make that window

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.