Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Shellexecute error
Message
From
12/11/2007 18:33:05
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Title:
Shellexecute error
Environment versions
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP SP2
Network:
Windows XP
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01268567
Message ID:
01268567
Views:
60
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
Map
View

Click here to load this message in the networking platform