Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Open a file from Powerbuilder using Windows default associated program

Posted on 2013-06-26
2
Medium Priority
?
3,081 Views
Last Modified: 2013-06-27
Hi,
I have a list of files with their paths in a data window and I would like to add functionality where the user could click the file and it will open using it's default Windows associated application.

Basically I would like to emulate the same process that happens when you go to windows explorer and just double-click a file, if it a word doc it launches word, if an excel doc it launches excel, etc. Windows opens it with it's associated application. I have the file name and path to pass to the Windows API call I just need to figure out how to make that call.

IDE: Powerbuilder 12.5.2 (Classic)
OS: Windows 7 64 bit

Thanks!
0
Comment
Question by:byteboy11
2 Comments
 
LVL 8

Accepted Solution

by:
virtuadept earned 2000 total points
ID: 39281335
In your appliation object declare a global external function:

FUNCTION long ShellExecuteW( ulong hWnd, string Operation, string lpFile, string  lpParameters, string lpDirectory, int nShowCmd ) LIBRARY "shell32.dll"

Open in new window


And when you want to open a file do this:

string ls_filename, ls_null
SetNull(ls_null)
ls_filename = '"C:\Full\Path\To\File.XYZ"'

ShellExecuteW( handle( THIS ), "open", ls_filename, ls_Null, ls_Null, 1)

Open in new window


We use this method in PB 11.5 app to open PDF files using the default PDF viewer.
1
 

Author Closing Comment

by:byteboy11
ID: 39282455
Thanks!
I actually already discovered this solution but I appreciate the responce.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Programmer's Notepad is, one of the best free text editing tools available, simply because the developers appear to have second-guessed every weird problem or issue a programmer is likely to run into. One of these problems is selecting and deleti…
How to install Selenium IDE and loops for quick automated testing. Get Selenium IDE from http://seleniumhq.org Go to that link and select download selenium in the right hand column That will then direct you to their download page. From that p…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.
Suggested Courses

885 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question