0

パスにスペースが含まれる画像ファイルで PhotoViewer を実行すると問題が発生します。

C++ 関数 CreateProcess を使用して、引数としてコマンド ラインを指定しています。そのためのコマンド ライン テンプレートは次のとおりです。

"rundll32 <path to PhotoViewer.dll> ImageView_Fullscreen <path to image> "
e.g.
"rundll32 \"C:\\Program Files\\Windows Photo Viewer\\PhotoViewer.dll\" ImageView_Fullscreen Z:\\Documents\\Projects\\ScreenCapture1\\ScreenCapture\\ScreenCapture\\sample.bmp"

ここでの問題は、二重引用符なしである必要があり、スペースを含めることができないという事実です。

私のコードは多かれ少なかれこのようなものです

_tcscpy_s( str, 200, _T("rundll32 \"C:\\Program Files\\Windows Photo Viewer\\PhotoViewer.dll\" ImageView_Fullscreen Z:\\Documents\\Projects\\ScreenCapture1\\ScreenCapture\\ScreenCapture\\sample.bmp") );
CreateProcess( NULL,            // No module name (use command line). 
        str,            // Command line. 
        NULL,           // Process handle not inheritable. 
        NULL,           // Thread handle not inheritable. 
        FALSE,          // Set handle inheritance to FALSE. 
        0,              // No creation flags. 
        NULL,           // Use parent's environment block. 
        NULL,           // Use parent's starting directory. 
        &si,            // Pointer to STARTUPINFO structure.
        &pi );          // Pointer to PROCESS_INFORMATION structure.

HANDLE hProcess = pi.hProcess;
CloseHandle(hProcess);

たとえば、パスにスペースが含まれる画像ファイルで PhotoViewer を実行したい

C:\the folder\has spaces\the image file.bmp
4

1 に答える 1

1

パスにチルダ付きのスペースがある場合は、古い Windows スタイルのパスを使用してください。

例えば、

c:\thefol~1\hasspa~1\theima~1.bmp
于 2013-06-17T03:42:22.730 に答える