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

  • Home
  • SEARCH
  • 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 6110725
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T14:32:55+00:00 2026-05-23T14:32:55+00:00

I am trying to correct a program that makes to other programs with the

  • 0

I am trying to correct a program that makes to other programs with the createProces call.

The problem is when I pass an object of the Brick class as a parameter of the createProcess call.

I create the object (in the main) this way:

char IpApplicationName[1000];

STARTUPINFO StartInfo;
PROCESS_INFORMATION ProcessInfo;

strcpy(IpApplicationName, "c:\\Documents and Settings\\Eigenaar\\Bureaublad\\BluetoothTestr\\recvProc\\bin\\Debug\\recvProc.exe");

//set up the NXT
Connection *connection = new Bluetooth();
Brick *nxt = new Brick(connection);
char *nxt_ptr = (char *)&nxt;

Then I connect like this (6 is the comm port of the bluetooth dongle):

connection->connect(6);

CreateProcess(IpApplicationName, nxt_ptr, NULL, NULL, FALSE,    CREATE_NEW_CONSOLE, NULL, NULL,     &StartInfo, &ProcessInfo);

This all works fine I think, but the problem is when I cast the char* back to the Brick class in the recvProc.exe process like this:

Brick *nxt = (Brick*)argv[0];

If I comment this, then the program works fine… What is wrong with this line? Or do I need to pass the Connection object in createProcess?

  • 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-23T14:32:55+00:00Added an answer on May 23, 2026 at 2:32 pm

    You are passing, as a command line argument, a pointer to a pointer to a class. This is broken in quite a few ways:

    • CreateProcess’s lpCommandLine argument takes a text string. There cannot be embedded NUL bytes. There must be a NUL byte to mark the end of the string. No such guarentee is present with a pointer-to-a-pointer, or indeed with a pointer or any sort of non-text-data in general.
    • Even if the pointer, by some miracle, was passed properly to the new process, the new process has its own address space. It cannot use pointers from the old process, at all; they are meaningless in a process different from that which they were created. So the argument is meaningless.
    • Even if it could access the old process’s address space, there is nothing stopping the pointed-to brick from being destroyed before the new process completes its work.
    • Even if all these were fixed, you’re passing a pointer-to-a-pointer-to-a-brick, and trying to use it as a regular pointer-to-a-brick.

    In short, you can’t pass objects as command-line arguments. Only text.

    So, what do do here? Here are your options:

    • Have the child process connect to the brick on its own. Don’t try to pass it a connection.
    • Set up a protocol of some sort (over stdin/stdout, or possibly DCOM) to allow the child process to remote control the Brick object in the parent.
    • Make recvProc into a DLL that runs inside the parent process.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to make a program that automatically corrects the perspective of a
I'm trying to find the correct event to listen for that will ensure that
I'm trying to understand what the correct approach for a constructor that accepts a
I have a java program that I am trying to generate 3 outputs for,
I am trying to use a program that uses git as the backing store
I am trying to make a Visual C++ 2008 program that plots some data
I'm trying to write a simple high-low program that will output like this: $
I'm trying to use SCons to compile a program that requires a set of
I an trying to create a program that will detect a face in a
I am trying to make a program that when a usb is plugged into

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.