shell32.dll;ShellExecute () не работает в Powerbuilder 11.5 - PullRequest
1 голос
/ 15 сентября 2011

У меня проблемы с исправлением одной ошибки, которая была мне назначена. Предполагается распечатать PDF-файл, указанный в параметре. Он использует функцию ShellExecute () для прямой печати документа. Мой вопрос PDF-файл считается документом? ShellExecute () возвращает 2 w / c Я обнаружил, что это означает неверный путь или имя файла Просто интересно, почему он вернулся 2. Я тоже пробую действие "открыть", но все равно бездействия. Буду очень признателен за вашу помощь.

Ответы [ 2 ]

1 голос
/ 15 сентября 2011

Убедитесь, что используется версия 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" 
0 голосов
/ 19 сентября 2011

Вот ваши коды возврата для ShellExecute, как только вы их обработаете, вы сможете определить причину любой проблемы.Это, вероятно, излишне, но вы можете решить, что вы хотите поймать.

Я работал над аналогичной проблемой в проекте PB, и при запуске PDF через оболочку выполнить это аналогично двойному щелчку файла PDF впроводник Виндоус.Если для PDF-файла настроена ассоциация, PDF-файл будет открыт с помощью программы по умолчанию.Если вы запускаете shell execute для файла .doc, то в большинстве случаев файл будет открыт с помощью 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".
...