Click here to Skip to main content
15,888,341 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: How to access a remote machine from a local machine and perform basic function like execute and close the remote machine's application. Pin
Manas Bhardwaj28-Jul-09 3:25
professionalManas Bhardwaj28-Jul-09 3:25 
GeneralRe: How to access a remote machine from a local machine and perform basic function like execute and close the remote machine's application. Pin
Rajesh R Subramanian28-Jul-09 3:57
professionalRajesh R Subramanian28-Jul-09 3:57 
QuestionConnecting to WMI -using COM [modified] Pin
Member 432083115-Jul-09 22:12
Member 432083115-Jul-09 22:12 
AnswerRe: Connecting to WMI -using COM Pin
Stuart Dootson15-Jul-09 22:24
professionalStuart Dootson15-Jul-09 22:24 
GeneralRe: Connecting to WMI -using COM Pin
Member 432083116-Jul-09 1:59
Member 432083116-Jul-09 1:59 
QuestionIP from socket handle Pin
sunny_vc15-Jul-09 21:17
sunny_vc15-Jul-09 21:17 
AnswerRe: IP from socket handle Pin
CPallini15-Jul-09 21:28
mveCPallini15-Jul-09 21:28 
QuestionCreateProcess doesn’t passes command line arguments [modified] Pin
staticv15-Jul-09 20:56
staticv15-Jul-09 20:56 
Hello I have the following code but it isn't working as expected, can't figure out what the problem is.

Basically, I'm executing a process (a .NET process) and passing it command line arguments, it is executed successfully by CreateProcess() but CreateProcess() isn't passing the command line arguments

What am I doing wrong here??

int main(int argc, char* argv[])
{
    PROCESS_INFORMATION ProcessInfo; //This is what we get as an [out] parameter

    STARTUPINFO StartupInfo; //This is an [in] parameter

    ZeroMemory(&StartupInfo, sizeof(StartupInfo));
    StartupInfo.cb = sizeof StartupInfo ; //Only compulsory field

    LPTSTR cmdArgs = "name@example.com";

    if(CreateProcess("D:\\email\\smtp.exe", cmdArgs, 
        NULL,NULL,FALSE,0,NULL,
        NULL,&StartupInfo,&ProcessInfo))
    { 
        WaitForSingleObject(ProcessInfo.hProcess,INFINITE);
        CloseHandle(ProcessInfo.hThread);
        CloseHandle(ProcessInfo.hProcess);

        printf("Yohoo!");
    }  
    else
    {
        printf("The process could not be started...");
    }

    return 0;
}


Hey one more thing, if I pass my cmdArgs like this:

// a space as the first character
LPTSTR cmdArgs = " manzoor10@gmail.com";

I get the error:
Object reference not set to an instance of an object

then CreateProcess returns TRUE but my target process isn't executed.
Top Web Hosting Providers[^]

Do, or do not. There is no 'try'.
modified on Thursday, June 10, 2010 2:13 AM

AnswerRe: CreateProcess doesn’t passes command line arguments Pin
Franck Paquier15-Jul-09 21:18
Franck Paquier15-Jul-09 21:18 
AnswerRe: CreateProcess doesn’t passes command line arguments Pin
Michael Schubert15-Jul-09 22:17
Michael Schubert15-Jul-09 22:17 
AnswerRe: CreateProcess doesn’t passes command line arguments Pin
Stuart Dootson15-Jul-09 22:20
professionalStuart Dootson15-Jul-09 22:20 
AnswerRe: CreateProcess doesn’t passes command line arguments Pin
tns_ranjith15-Jul-09 22:41
tns_ranjith15-Jul-09 22:41 
GeneralRe: CreateProcess doesn’t passes command line arguments Pin
Michael Schubert15-Jul-09 23:00
Michael Schubert15-Jul-09 23:00 
GeneralRe: CreateProcess doesn’t passes command line arguments Pin
Rajesh R Subramanian15-Jul-09 23:45
professionalRajesh R Subramanian15-Jul-09 23:45 
GeneralRe: CreateProcess doesn’t passes command line arguments Pin
Michael Schubert15-Jul-09 23:48
Michael Schubert15-Jul-09 23:48 
GeneralRe: CreateProcess doesn’t passes command line arguments Pin
tns_ranjith16-Jul-09 0:11
tns_ranjith16-Jul-09 0:11 
QuestionHow to test is the given path is a directory or a file? Pin
Chesnokov Yuriy15-Jul-09 20:56
professionalChesnokov Yuriy15-Jul-09 20:56 
AnswerRe: How to test is the given path is a directory or a file? Pin
Randor 15-Jul-09 21:08
professional Randor 15-Jul-09 21:08 
AnswerRe: How to test is the given path is a directory or a file? Pin
Chesnokov Yuriy15-Jul-09 22:50
professionalChesnokov Yuriy15-Jul-09 22:50 
AnswerRe: How to test is the given path is a directory or a file? [modified] Pin
CPallini15-Jul-09 21:21
mveCPallini15-Jul-09 21:21 
GeneralRe: How to test is the given path is a directory or a file? Pin
Randor 15-Jul-09 21:38
professional Randor 15-Jul-09 21:38 
GeneralRe: How to test is the given path is a directory or a file? Pin
CPallini15-Jul-09 21:43
mveCPallini15-Jul-09 21:43 
GeneralRe: How to test is the given path is a directory or a file? Pin
Michael Schubert15-Jul-09 23:13
Michael Schubert15-Jul-09 23:13 
AnswerRe: How to test is the given path is a directory or a file? Pin
Michael Schubert15-Jul-09 22:29
Michael Schubert15-Jul-09 22:29 
QuestionHelp in writing a program? Pin
jon ray15-Jul-09 20:50
jon ray15-Jul-09 20:50 

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

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