簡體   English   中英

在C ++中傳遞的參數不完整

[英]Argument Passed is not complete in C++

我只是想使用CreateProcess將參數傳遞給另一個應用程序。 當我在目的地中收到參數時,它不完整,僅傳遞了一部分。 我得到的輸出是"1\\\\Documentation\\\\U3DElements.pdf"

這是傳遞參數的代碼。(這是C ++代碼)

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 );

這是我顯示它的代碼。(AdobePlugin.exe這是VB代碼)

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

我希望MsgBox顯示完整代碼“ C:\\ Users \\ vignesh.d \\ Downloads \\ sdk110_v1_win \\ Adob​​e \\ Acrobat XI SDK \\ Version1 \\ Documentation \\ U3DElements.pdf”

參數/參數由空格字符分隔。

MsgBox(e.Args(1))

會給您論點的前半部分。

如果要傳遞包含空格作為一個參數的內容,則需要將其用引號引起來,例如:

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

引用參數是否包含空格也可以。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM