Solved

Open a file from Powerbuilder using Windows default associated program

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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

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: …
Jaspersoft Studio is a plugin for Eclipse that lets you create reports from a datasource.  In this article, we'll go over creating a report from a default template and setting up a datasource that connects to your database.
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.

759 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

20 Experts available now in Live!

Get 1:1 Help Now