Solved

Open a file from Powerbuilder using Windows default associated program

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
NetBeans and configurationfiles 2 49
selectallvieditor 6 101
In Notepad++ how to tell if tab files have been changed? 4 61
Best free Visio Editor? 2 141
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. …
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 keystrokes in Netbeans IDE 8.0 for Windows.

863 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now