Computing.Net > Forums > Programming > help with createprocess win32 api

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

help with createprocess win32 api

Reply to Message Icon

Name: Eric
Date: February 22, 2003 at 10:39:45 Pacific
OS: 98
CPU/Ram: pen3 128ram
Comment:

ok i need some major help with my program. I am trying to create 2 process in main and then have them communicate via a pipe. the problem right now is occuring whenever i create my first process. Within the process I am simply just printing a sentence. For some reason though my program only outputs 8 charcters and then a bunch of garbage. Here is my code. any help is greatly appreciated


#include
#include
#include
#include
#include
#include
#include

HANDLE readpipe,writepipe;
SECURITY_ATTRIBUTES pipeSA;
STARTUPINFO srcStartInfo, sinkStartInfo;
PROCESS_INFORMATION sourceinfo, sinkinfo;

void main()
{


//create pipe
pipeSA.nLength = sizeof(SECURITY_ATTRIBUTES);
pipeSA.bInheritHandle = true;
pipeSA.lpSecurityDescriptor = NULL;

if(!CreatePipe(&readpipe, &writepipe, &pipeSA, 0)){printf("ERROR");ExitProcess(1);}


char * sourcename = "source.exe";
char * sinkname = "sink.exe";

//Create Process source;
ZeroMemory(&srcStartInfo,sizeof(STARTUPINFO));
srcStartInfo.cb = sizeof(srcStartInfo);
srcStartInfo.hStdOutput = writepipe;
srcStartInfo.hStdInput = GetStdHandle(STD_INPUT_HANDLE);
srcStartInfo.hStdError = GetStdHandle(STD_ERROR_HANDLE);
srcStartInfo.dwFlags = STARTF_USESTDHANDLES;
if(!CreateProcess(NULL,sourcename,NULL, NULL, false, NORMAL_PRIORITY_CLASS ,NULL, NULL, &srcStartInfo, &sourceinfo)){printf("error creating source");ExitProcess(1);}


//create process sink
ZeroMemory(&sinkStartInfo,sizeof(STARTUPINFO));
sinkStartInfo.cb = sizeof(STARTUPINFO);
sinkStartInfo.hStdInput = readpipe;
sinkStartInfo.hStdError = GetStdHandle(STD_ERROR_HANDLE);
sinkStartInfo.dwFlags = STARTF_USESTDHANDLES;
if(!CreateProcess(NULL,sinkname,NULL, NULL, false, NORMAL_PRIORITY_CLASS,NULL, NULL, &sinkStartInfo, &sinkinfo)){printf("error creating sink");ExitProcess(1);}




Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: help with createprocess win32 api

RAZOR: help with perfproc www.computing.net/answers/programming/razor-help-with-perfproc/18483.html

Help with problem in C www.computing.net/answers/programming/help-with-problem-in-c/5108.html

Help with debugging C++ code www.computing.net/answers/programming/help-with-debugging-c-code/13083.html