Link to home
Start Free TrialLog in
Avatar of GenasysTechnologies
GenasysTechnologiesFlag for South Africa

asked on

ShellExecute/File Association/Security under Windows Vista

We use ShellExecute to open PDF files after generation.  This works fine on 2000, XP and most Vista setups.

My problem is that one Vista machine opens the PDF in notepad.  File associations seem correct - the user has Acrobat reader installed and can manually open PDF files.  The user is not a local administrator.

Here is the code that opens the document:  ShellExecute(handle, 'open', Pchar(sPDFFileName) , nil, nil, SW_SHOWNORMAL);
Avatar of lyonst
lyonst
Flag of Ireland image

Try using "runas" instead of open..
Avatar of GenasysTechnologies

ASKER

Hi lyonst,

Thanks for your quick reply.  I tried the 'runas'-verb after initial Googling, but could not get it to open documents on XP nor Vista:

This works: ShellExecute(handle, 'runas', Pchar('c:\windows\notepad.exe') , nil, nil, SW_SHOWNORMAL);
This does not work: ShellExecute(handle, 'runas', Pchar('c:\testfile.pdf') , nil, nil, SW_SHOWNORMAL);

We do not want to hardcode 'runas' against 'C:\Program Files\Adobe\Acrobat 8.0\Acrobat\Acrobat.exe filename' since some people may want to use Foxit Reader.  This would also mean that we need to detect the Adobe Acrobat installation directory.
Ok thanks, I will take another look..
SOLUTION
Avatar of tobjectpascal
tobjectpascal

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi Johnjces,

Your understanding is correct and your theory makes sense.  I will get the user to re-install and let you know if this works.
The user re-installed Windows which resolved the issue...  I guess the exact cause remains an issue :(
The user reinstalled Windows! Ouch! Or did he reinstall Adobe Acrobat reader?

John

and thanks! Glad I could help.