Solved

Open a file from Powerbuilder using Windows default associated program

Posted on 2013-06-26
2
2,442 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 500 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.
0
 

Author Closing Comment

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

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

In our object-oriented world the class is a minimal unit, a brick for constructing our applications. It is an abstraction and we know well how to use it. In well-designed software we are not usually interested in knowing how objects look in memory. …
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 columnThat will then direct you to their download page.From that page s…
THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.

772 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