パスにスペースが含まれる画像ファイルで 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