Mic*_*Sim 13 vb6 registry winapi file shellexecute
我有一个VB6应用程序,使用以下命令打开文件及其关联的应用程序
ShellExecute(0, "open", filename, params, vbNullString, vbNormalFocus)
Run Code Online (Sandbox Code Playgroud)
这非常有效.
现在我有一个客户(使用Adobe Reader运行XP)无法使用上述命令打开任何PDF文件.但是从Windows资源管理器中双击它时,同一个文件正在打开而没有任何问题.我还测试了我的机器上的文件名/路径组合,以排除这些问题.
我正在寻找任何有关我可以检查以确保ShellExecute工作的提示.或者是什么导致ShellExecute以这种方式失败?
Tho*_*erg 10
ShellExecute的返回值是多少?如果它是0x0000001f(== 31,含义SE_ERR_NOASSOC),则根据shellapi.h "没有与给定文件扩展名关联的应用程序." ,这意味着.pdf文件扩展名的注册以某种方式丢失了.重新安装Adobe Reader可能会有所帮助.
继Thomas的答案之后,这里有一些关于ShellExecute可能返回值的VB6常量,可能有解释(我想我最初是从MSDN 页面获取这些,返回值部分).返回值为32或更小意味着呼叫失败.返回的具体值表明出了什么问题.
Const ERROR_BAD_FORMAT = 11&
Const ERROR_FILE_NOT_FOUND = 2&
Const ERROR_PATH_NOT_FOUND = 3& ' The specified path was not found. '
Const SE_ERR_ACCESSDENIED = 5 ' The operating system denied access to the specified file. '
Const SE_ERR_ASSOCINCOMPLETE = 27 ' The file name association is incomplete or invalid. '
Const SE_ERR_DDEBUSY = 30 ' The Dynamic Data Exchange (DDE) transaction could not be completed because other DDE transactions were being processed. '
Const SE_ERR_DDEFAIL = 29 ' The DDE transaction failed. '
Const SE_ERR_DDETIMEOUT = 28 ' The DDE transaction could not be completed because the request timed out. '
Const SE_ERR_DLLNOTFOUND = 32 ' The specified dynamic-link library (DLL) was not found. '
Const SE_ERR_FNF = 2 ' The specified file was not found. '
Const SE_ERR_NOASSOC = 31 ' There is no application associated with the given file name extension. '
Const SE_ERR_OOM = 8 ' out of memory '
Const SE_ERR_PNF = 3 ' path not found '
Const SE_ERR_SHARE = 26 ' A sharing violation occurred. '
Run Code Online (Sandbox Code Playgroud)
您将“ open”用作动词,请不要使用vbNullString作为动词(“ Open”表示开放动词,NULL表示默认动词(如果用户未设置特定的默认值,则默认为open,如果该文件类型没有打开动词,则ShellExecute使用它找到的第一个动词))
| 归档时间: |
|
| 查看次数: |
19815 次 |
| 最近记录: |