General information
Category:
Windows API functions
Hi all,
I have a simple routine that uses shellExecute to open a PDF file, but it fails with error code 5. Could someone tell me what could be the reason for this?
BTW this happens only one one computer (XP) logged in as administrator. Same code works well on other machines
Here's the code:
LPARAMETERS pcFilename, pnWindowState, pnhWnd
lcFilename = pcFilename
lcop = 'open'
lcparms = ""
DECLARE INTEGER ShellExecute IN Shell32;
INTEGER hWnd, STRING @lpOperation,;
STRING @lpFile, STRING @lpParameters,;
STRING @lpDirectory, INTEGER nShowCmd
lnresult = ShellExecute(0, @lcop, @lcFilename,;
@lcparms, @lcpath, lnWindowState)
IF lnresult < 33 && Error occurred
IF lnresult = 31 && No file associated
DECLARE INTEGER GetSystemDirectory IN Win32API;
STRING @lpBuffer, INTEGER nSize
lnsize = 260
lcbuffer = SPACE(lnsize)
lnsize = GetSystemDirectory(@lcbuffer, lnsize)
IF lnsize > 0
lcbuffer = LEFT(lcbuffer, lnsize)
lcrundll = "RUNDLL32.EXE"
lcparms = "shell32.dll,OpenAs_RunDLL "
lnresult = ShellExecute(lnhWnd, @lcop, lcrundll,;
lcparms + lcFilename, lcbuffer, lnWindowState)
ENDIF
ENDIF
ENDIF
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only