Search code examples
c++wpfvb.netwindow

Argument Passed is not complete in C++


I am just trying to pass an argument to another Application using CreateProcess. When i get the argument in the destination, It not full only a part is passed. The output I am getting is "1\\Documentation\\U3DElements.pdf"

This the Code that passes the Argument.(This is a C++ Code)

STARTUPINFO si;     
PROCESS_INFORMATION pi;

// set the size of the structures
ZeroMemory( &si, sizeof(si) );
si.cb = sizeof(si);
ZeroMemory( &pi, sizeof(pi) );
LPTSTR cmdArgs = "C:\\Users\\vignesh.d\\Downloads\\sdk110_v1_win\\Adobe\\Acrobat XI SDK\\Version1\\Documentation\\U3DElements.pdf";
// start the program up
if (CreateProcess(
        TEXT("C:\\Users\\vignesh.d\\Documents\\Visual Studio  2012\\Projects\\AdobePlugin\\AdobePlugin\\bin\\Debug\\AdobePlugin.exe"),
        cmdArgs,NULL,NULL,FALSE,
        CREATE_NEW_CONSOLE,
        NULL,
        NULL,
        &si,
        &pi))
{
    WaitForSingleObject(pi.hProcess, INFINITE);
}
CloseHandle( pi.hProcess );
CloseHandle( pi.hThread );

This the Code where I display it.(AdobePlugin.exe This is a VB Code)

Private Sub App_Startup(ByVal sender As Object, ByVal e As StartupEventArgs)
    MsgBox(e.Args(2))
End Sub

I want the MsgBox to display The Full Code "C:\Users\vignesh.d\Downloads\sdk110_v1_win\Adobe\Acrobat XI SDK\Version1\Documentation\U3DElements.pdf"


Solution

  • Parameters/Arguments are separated a space character.

    MsgBox(e.Args(1))
    

    Would give you the first half of your argument.

    If you want to pass something containing a space as one parameter, you'll need to put it in quotes, likes this:

    LPTSTR cmdArgs = "\"C:\\Users\\vignesh.d\\Downloads\\sdk110_v1_win\\Adobe\\Acrobat XI SDK\\Version1\\Documentation\\U3DElements.pdf\"";
    

    It can't hurt to quote the parameters whether they contain a space or not.