我无法修复分配给我的一个错误。它应该打印参数上声明的pdf文件。它使用ShellExecute()函数直接打印文档。 我的问题是一个被认为是文件档案的pdf文件? ShellExecute()返回2 w / c我发现它意味着无效的路径或文件名。只是想知道为什么它返回2.我也尝试“开放”的行动,但仍然没有行动。 非常感谢你的帮助。
答案 0 :(得分:1)
确保使用Unicode版本(ShellExecuteW)而不是ANSI版本(ShellExecuteA):
FUNCTION long ShellExecute (uint ihwnd,string lpszOp,string
lpszFile,string lpszParams, string lpszDir,int wShowCmd )
LIBRARY "Shell32.dll" ALIAS FOR "ShellExecuteW"
答案 1 :(得分:0)
以下是ShellExecute的返回代码,一旦处理好这些代码,您就应该能够确定问题的原因。这可能是矫枉过正,但你可以决定要捕捉哪些。
我在PB项目上遇到了类似的问题,当通过shell运行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".