Solved

Open a file from Powerbuilder using Windows default associated program

Posted on 2013-06-26
2
2,496 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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Update (December 2011): Since this article was published, the things have changed for good for Android native developers. The Sequoyah Project (http://www.eclipse.org/sequoyah/) automates most of the tasks discussed in this article. You can even fin…
Here is a helpful source code for C++ Builder programmers that allows you to manage and manipulate HTML content from C++ code, while also handling HTML events like onclick, onmouseover, ... Some objects defined and used in this source include: …
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.

821 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