私に割り当てられた 1 つのバグを修正するのに苦労しています。パラメータに記載されているpdfファイルを印刷することになっていました。ShellExecute() 関数を使用して、ドキュメントを直接印刷します。私の質問は、ドキュメント ファイルと見なされる PDF ファイルですか? ShellExecute() が 2 w/c を返しています。無効なパスまたはファイル名を意味することがわかりました。なぜ返されたのか疑問に思っています 2.「開く」アクションも試しましたが、まだアクションはありません。あなたのすべての助けに本当に感謝します。
4810 次
2 に答える
1
ANSI バージョン (ShellExecuteA) ではなく、必ず Unicode バージョン (ShellExecuteW) を使用してください。
FUNCTION long ShellExecute (uint ihwnd,string lpszOp,string
lpszFile,string lpszParams, string lpszDir,int wShowCmd )
LIBRARY "Shell32.dll" ALIAS FOR "ShellExecuteW"
于 2011-09-15T11:30:33.510 に答える
0
ShellExecute のリターン コードを次に示します。これらを処理すると、問題の原因を特定できるはずです。これはおそらくやり過ぎですが、どちらをキャッチするかを決めることができます。
私は PB プロジェクトで同様の問題に取り組みました。シェル実行で PDF を実行すると、Windows エクスプローラーで PDF ファイルをダブルクリックするのと同じになります。PDF にファイルの関連付けが設定されている場合、PDF はデフォルトのプログラムを使用して開かれます。.doc ファイルに対して shell execute を実行すると、ほとんどの場合、ファイルは Word で開かれます。関連付けが利用できない場合は、例外 31 (ファイルの関連付けなし) が発生します。
WHEN 0 THEN txt = "The operating system is out of memory or resources.".
WHEN 2 THEN txt = "The specified file was not found".
WHEN 3 THEN txt = "The specified path was not found.".
WHEN 5 THEN txt = "Windows 95 only: The operating system denied "
+ "access to the specified file".
WHEN 8 THEN txt = "Windows 95 only: There was not enough memory to "
+ "complete the operation.".
WHEN 10 THEN txt = "Wrong Windows version".
WHEN 11 THEN txt = "The .EXE file is invalid (non-Win32 .EXE or "
+ "error in .EXE image).".
WHEN 12 THEN txt = "Application was designed for a different operating system".
WHEN 13 THEN txt = "Application was designed for MS-DOS 4.0".
WHEN 15 THEN txt = "Attempt to load a real-mode program".
WHEN 16 THEN txt = "Attempt to load a second instance of "
+ "an application with non-readonly data segments".
WHEN 19 THEN txt = "Attempt to load a compressed application file".
WHEN 20 THEN txt = "Dynamic-link library (DLL) file failure".
WHEN 26 THEN txt = "A sharing violation occurred.".
WHEN 27 THEN txt = "The filename association is incomplete or invalid.".
WHEN 28 THEN txt = "The DDE transaction could not be completed "
+ "because the request timed out.".
WHEN 29 THEN txt = "The DDE transaction failed.".
WHEN 30 THEN txt = "The DDE transaction could not be completed because "
+ "other DDE transactions were being processed.".
WHEN 31 THEN txt = "There is no application associated with "
+ "the given filename extension.".
WHEN 32 THEN txt = "Windows 95 only: The specified dynamic-link "
+ "library was not found.".
OTHERWISE txt = "undocumented".
于 2011-09-19T11:06:45.957 に答える