hi Robert,
On 7/8/2011 8:52 AM, Robert Ostrowski wrote:
Is there an equivalent of ShellExecuteA that can be run from an
RPGIV program to open a file on the user's PC?
You seem to be oversimplifying the situation a bit.
ShellExecuteA is part of the Microsoft Windows operating system. To
call an API that's running on Windows, you need a PROGRAM THAT'S RUNNING
ON WINDOWS. (Hopefully that's already obvious to you.)
So in order to do what you're asking, you're going to need a lot more
than the ability to call a ShellExecute API (or the older, legacy,
version, ShellExecuteA)
You're going to need:
1) A program on Windows to call the API
2) A means of communication between the RPG IV program and the Windows
program
3) Something to keep it secure (so only authorized programs can run
commands on the PC. Obviously, letting anyone/everyone in the world run
any arbitrary command on the PC would be a bad idea.)
One way that already exists is to use the 5250 emulator. If you have an
interactive user who's already connected from the PC to IBM i using a
5250 emulator, then the communication is already in place, and the
security has already occurred. You can use the 5250 emulator's support
for the STRPCCMD CL command to run a command on that PC. If you want to
force it to use ShellExecute(), you can do this:
STRPCCMD PCCMD('rundll32 shell32,ShellExec_RunDLL command-here')
This does not run ShellExecuteA, but another API named ShellExec_RunDLL.
There are options in ShellExecuteA that ShellExec_RunDLL doesn't have
in order to keep ShellExec_RunDLL compatible with the rundll32.exe
program in Windows. But, they serve the same basic function.
Another disadvantage to this method is that it's really hard to
trap/handle errors.
The other alternative, of course, is to write a Windows program and use
some other communications method. Then you can make it work exactly the
way you want to -- but you'll need to write Windows software,
communications software, and make that software available to run on all
of the PCs. (That might be very easy, or very hard, depending on your
environment -- which I know nothing about.)
As an Amazon Associate we earn from qualifying purchases.