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 7406685
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T05:35:44+00:00 2026-05-29T05:35:44+00:00

i have the following test code: #define CMDLINE .\\dummyFolder\\dummyProc.exe op1 op2 op3 int main(int

  • 0

i have the following test code:

#define CMDLINE ".\\dummyFolder\\dummyProc.exe op1 op2 op3"

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

STARTUPINFO info;
info.cb = sizeof(STARTUPINFO);
info.lpReserved = NULL;
info.cbReserved2 = 0;
info.lpReserved2 = NULL;

PROCESS_INFORMATION processInfo;

SECURITY_ATTRIBUTES procAttr;
procAttr.nLength = sizeof(SECURITY_ATTRIBUTES);
procAttr.lpSecurityDescriptor = NULL;
procAttr.bInheritHandle = false;

SECURITY_ATTRIBUTES threadAttr;
procAttr.nLength = sizeof(SECURITY_ATTRIBUTES);
procAttr.lpSecurityDescriptor = NULL;
procAttr.bInheritHandle = false;

bool handlersInheritable = true;

char cmdLine2[sizeof(CMDLINE)];
strcpy(cmdLine2, CMDLINE);

char AppName[sizeof(".\\dummyFolder\\dummyProc.exe")];
strcpy(AppName, ".\\dummyFolder\\dummyProc.exe");


if (CreateProcess(AppName, cmdLine2, &procAttr, &threadAttr,
        handlersInheritable, 0, NULL, NULL, &info, &processInfo)) {

    //::WaitForMultipleObjects(procQty, handlers, waitForAll, waitInterval);
    CloseHandle(processInfo.hProcess);
    CloseHandle(processInfo.hThread);
    CloseHandle(info.hStdError);
    CloseHandle(info.hStdInput);
    CloseHandle(info.hStdOutput);
} else {
    std::cout << "Returned: " << GetLastError() << std::endl;
}

std::cout << "Exiting main process" << std::endl;

return 0;
}

This is just a test code for creating processes in windows. The problem is that when i launch “dummyProc.exe” i get a 0xc0000142 error.

The process dummyProc.exe runs fine from the command line, but not from within the code.

Here’s the dummyProc code if it helps:

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


std::cout << "Working!!!!" << std::endl << "Receivedi: " << std::endl;

for (int i = 0; i < argc; ++i)
    std::cout << argv[i] << std::endl;


return 0;
}

So, any ideas?

  • 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-05-29T05:35:44+00:00Added an answer on May 29, 2026 at 5:35 am

    The most obvious thing that char cmdLine2[sizeof(CMDLINE)]; declares a string of length equal to your machine’s pointer size. You need to use strlen(CMDLINE)+1 instead. Likewise for appName.

    Note that the first parameter to CreateProcess does not need to be writeable. Just pass the string literal directly to it. No need for appName variable.

    As for lpCommandLine which does need to be writeable it’s easiest to do it like this:

    char cmdline[] = "op1 op2 op3";
    

    That gives you a writeable buffer. Note that you do not need to repeat the executable file name.

    Another problem is that you have not initialized all the parameters to CreateProcess. For example the STARTUPINFO struct has 19 fields and you initialize only 3. You should initialize all your structs to 0 and then fill out any fields you need to be non-zero. Like this:

    STARTUPINFO info = { 0 };
    

    Do this for all the structs you pass.

    You can, and should, pass NULL for the lpProcessAttributes and lpThreadAttributes parameters.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following test-code: CREATE TABLE #Foo (Foo int) INSERT INTO #Foo SELECT
I have following code public class TEST { public static void main(String arg[]){ try
I have the following code: public class Test { public static void Main() {
I have the following code: main = do putStr Test input : content <-
I have the following code: int main(void) { struct { int x; } a,
I have the following dumb test code: #lang racket (define vars '('g1 'g2 'g3
I have the following test code use Data::Dumper; my $hash = { foo =>
I have the following code: public class Test extends JFrame implements ActionListener{ private static
I have the following code snippet. $items['A'] = Test; $items['B'] = Test; $items['C'] =
I have the following code <html> <head> <title>Test</title> <style type=text/css> <!-- body,td,th { color:

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.