open IFS .bmp using windows default program from RPG/CL
Last Post 17 Feb 2013 11:23 AM by Scott Klement. 3 Replies.
AddThis - Bookmarking and Sharing Button Printer Friendly
  •  
  •  
  •  
  •  
  •  
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
Darlene Dangel
New Member
New Member
Posts:33

--
08 Feb 2013 10:12 AM

Please help me connect the dots.

I have .bmp files stored in the IFS.  I would like to have an RPG "green screen" function to open an associated .bmp file using the user's windows default program for .bmp files.  I'm guessing I need a rundll32 command, but I'm not sure what it looks like?

Also, Public is excluded from the file, but the user has rights.  Do that have to use a mapped drive in order to gain that authority?

Thank you for any help!  

Scott Klement
Editorial Staff Member
Editorial Staff Member
Posts:16272
Avatar

--
10 Feb 2013 06:11 AM

Since you want Windows to open the file, you need to first decide how it'll get to Windows.   A mapped drive is one possibility.   Others might include FTP, HTTP, SSH/SCP/SFTP, e-mail or various 3rd party file transfer packages.   But, somehow the file has to be accessible from Windows to use it.

So let's assume the user has a drive mapped, and has managed to authenticate him/herself to the IBM i partition containing the .BMP.   Now they have the ability to open and view that .BMP file by navigating to it with Windows and double-clicking it.   But, you want the computer program to initiate that for them, so they don't to click anything.  

Assuming you're using an interactive 5250 session for this, you can send a command through the 5250 emulator that will be run on the Windows machine using a tool called STRPCCMD.  You can send any command you like -- but, in this case, what you really want to do is tell Windows to figure out the right program to open up your .BMP file.

So the code would be something like this (this is off the top of my head, and untested)

PGM   PARM(&PATH)

     DCL VAR(&CMD) TYPE(*CHAR) LEN(123)
     DCL VAR(&PATH) TYPE(*CHAR) LEN(114)

     STRPCO PCTA(*NO)
     MONMSG IWS4010

     CHGVAR VAR(&CMD) +
     VALUE('explorer ' *BCAT &PATH)

     STRPCCMD PCCMD(&CMD) PAUSE(*NO)

ENDPGM

 

STRPCO turns on the ability to run commands through the browser.  The MONMSG below it catches the error if that ability has already been turned on.

The command I'm sending will be "explorer" (meaning, Windows Explorer) followed by the path of your BMP, which I figured you'd pass as a parameter to this simple CL program.   Explorer should subsequently try to figure out how to properly open a file like that, and open it on your screen.  (You could use RUNDLL32 instead of explorer if you wanted to -- but I like EXPLORER because it's shorter, so gives you more space for the path name.)

I like to call this simple like CL program something like OPENDOC...  you can use it to open any Windows document (this is not limited to .BMP.. can open word, PDF, excel, or even a URL to a web page).  So it's a handy thing.

Then just code it up from RPG with something like this (again, this code is untested, but should be fairly close)

     D OpenDoc         PR                  ExtPgm('OPENDOC')
     D   URL                        114A   Const

      /free
        
        OpenDoc('I:\HOME\KLEMSCOT\YOURFILE.BMP');


Darlene Dangel
New Member
New Member
Posts:33

--
14 Feb 2013 08:36 AM
Scott - THANK YOU! I really appreciate how you "spoke slowly", that made it much easier for me to understand.

Typical though, it has prompted more questions.
I followed these steps and it worked perfectly-except, it opened the file using Paint. When I use Windows Explorer and double-click on the file it opens with Windows Picture Viewer. When I read about why that was happening it seems clear that I will have to use the RUNDLL32 instead. And of course, the command string will be too long to use STRPCCMD.
To the point, I am very interested in OpenSSH. I have heard your presentation about it. It seems like a tool that will help us do several things we have wanted to do (and fix some things that we could have done better).
Which brings me back to needing dots connected. Can I use the same rundll32 {…}shimgvw.dll,ImageView_Fullscreen path/filename command or would the command be different? Back to file authority, I would prefer to have a solution that does not require a mapped drive, if feasible. If I setup digital keys will that provide me with the file authentication to IFS?

Also, I have read a little about Aaron Bartell’s RPG to Desktop. It seems very similar to OpenSSH except using Java.
Does anyone have experience with both that could compare and advise? SSH by definition seems to be the more secure option, is that a fair assumption? RPG to Desktop requires something to be installed on the PC. But with SSH, the digital key is only thing done on the PC. Am I getting it?

Currently, we are Windows XP users. I am assuming that either of these solutions (unlike RUNRMTCMD) will transition well when we jump to Windows 7 or 8. Right?

Thanks again for any help!
Scott Klement
Editorial Staff Member
Editorial Staff Member
Posts:16272
Avatar

--
17 Feb 2013 11:23 AM
Posted By Darlene Dangel on 14 Feb 2013 09:36 AM I followed these steps and it worked perfectly-except, it opened the file using Paint. When I use Windows Explorer and double-click on the file it opens with Windows Picture Viewer. When I read about why that was happening it seems clear that I will have to use the RUNDLL32 instead. And of course, the command string will be too long to use STRPCCMD.
This is strange... but you're right, it seems to be opening with Paint for me, too. You could try using "start" instead of "explorer" in your STRPCCMD. I don't like this as much, because it uses a DOS prompt and will choke on any characters that have special meaning in DOS. But, it will open with the picture/fax viewer if you use "start". Otherwise, yeah, you can use RUNDLL32 to solve the problem, but as you say, this requires more characters in your command string.
To the point, I am very interested in OpenSSH. I have heard your presentation about it. It seems like a tool that will help us do several things we have wanted to do (and fix some things that we could have done better).
Which brings me back to needing dots connected. Can I use the same rundll32 {…}shimgvw.dll,ImageView_Fullscreen path/filename command or would the command be different? Back to file authority, I would prefer to have a solution that does not require a mapped drive, if feasible. If I setup digital keys will that provide me with the file authentication to IFS?
I must admit, I use SSH on IBM i and Unix systems, but I have not yet set one up on Windows or tried it with Windows commands. I would assume that if you run one designed for Windows, it runs normal windows commands, so RUNDLL32 should work. But, if you run it in Cygwin, then you'd probably have to use the Cygwin/bash command syntax.
Also, I have read a little about Aaron Bartell’s RPG to Desktop. It seems very similar to OpenSSH except using Java.
Does anyone have experience with both that could compare and advise? SSH by definition seems to be the more secure option, is that a fair assumption? RPG to Desktop requires something to be installed on the PC. But with SSH, the digital key is only thing done on the PC. Am I getting it?
I'm not sure how Aaron's tool works, exactly. I believe it uses data queues for communication, but I'm not sure if he provides encryption for security, or whether he uses authentication at all. You'd either need to install Aaron's tool on the PC if you use it, or an SSH server on the PC if you use SSH. So either way, you have to install something.
Currently, we are Windows XP users. I am assuming that either of these solutions (unlike RUNRMTCMD) will transition well when we jump to Windows 7 or 8. Right?
Not sure. I'm not a Windows guy.
You are not authorized to post a reply.

Acceptable Use Policy