For my company, I wrote an application that includes a function called FileExecute, which takes file path parameter lpFile, calls the open command with the ShellExecuteEx function and returns the Process handle:
Ex: ?FileExecute("C:\MyFolder\MyFile.txt")
...opens up the file with the associated program (NOTEPAD.EXE) and returns the Process handle. My program uses this information to terminate the running process when the main program closes.
There is ONE user's machine which has a problem with this program when attempting to open PDF files (not other file types). When the program calls the FileExecute function, his machine returns:
Run-Time Error: 5 - Invalid procedure call or argument
This user's machine was upgraded from Adobe Acrobat Reader to Adobe Acrobat Standard 8.0, and the problem manifests itself on his machine, ONLY on his Windows Network Login. When I or any other User logs onto his machine, it runs just fine.
I suspect the problem lies somewhere in his HKEY_CURRENT_USER registry setting, but am not sure how to address it. Has anyone else encountered this problem, or can anyone recommend a solution?
Below is the code, for reference:
Ex: ?FileExecute("C:\MyFolder\MyFile.txt")
...opens up the file with the associated program (NOTEPAD.EXE) and returns the Process handle. My program uses this information to terminate the running process when the main program closes.
There is ONE user's machine which has a problem with this program when attempting to open PDF files (not other file types). When the program calls the FileExecute function, his machine returns:
Run-Time Error: 5 - Invalid procedure call or argument
This user's machine was upgraded from Adobe Acrobat Reader to Adobe Acrobat Standard 8.0, and the problem manifests itself on his machine, ONLY on his Windows Network Login. When I or any other User logs onto his machine, it runs just fine.
I suspect the problem lies somewhere in his HKEY_CURRENT_USER registry setting, but am not sure how to address it. Has anyone else encountered this problem, or can anyone recommend a solution?
Below is the code, for reference:
Code:
Option Explicit
Private Declare Function ShellExecuteEx Lib "shell32.dll" ( _
lpExecInfo As SHELLEXECUTEINFO) _
As Long
Private Type SHELLEXECUTEINFO
cbSize As Long
fMask As Long
hWnd As Long
lpVerb As String
lpFile As String
lpParameters As String
lpDirectory As String
nShow As Long
hInstApp As Long
lpIDList As Long
lpClass As String
hkeyClass As Long
dwHotKey As Long
hIcon As Long
hProcess As Long
End Type
Private Const SEE_MASK_NOCLOSEPROCESS = &H40
Private Const SEE_MASK_INVOKEIDLIST = &HC
Private Const SEE_MASK_FLAG_NO_UI = &H400
Private Const SW_NORMAL = 1
Public Function FileExecute(ByVal lpFile As String) As Long
Dim lpExecInfo As SHELLEXECUTEINFO
With lpExecInfo
.cbSize = Len(lpExecInfo)
.fMask = SEE_MASK_NOCLOSEPROCESS
.lpFile = lpFile
.lpVerb = "open"
.nShow = SW_NORMAL
.hWnd = Form1.hWnd
End With
ShellExecuteEx lpExecInfo
FileExecute = lpExecInfo.hProcess
End Function