Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

ShellExecute WinAPI function

1,155 views
Skip to first unread message

Javier Español

unread,
Apr 5, 2000, 3:00:00 AM4/5/00
to
Hi!,

I want to use the WinAPI ShellExecute function from within a PB program but
don't know how.
This function receives as a parameter (and some other parameters) the path
and name of a file and makes Windows execute the file in the application
that is registered to open that file type.
For example, if you pass C:\windows\myLetter.doc, the function will attempt
to open that file in WinWord.

TIA,

Javier Español

Roy Kiesler [TeamSybase]

unread,
Apr 5, 2000, 3:00:00 AM4/5/00
to
Here's a code sample:

// external function declaration
FUNCTION long ShellExecuteA( ulong hWnd, string Operation, string lpFile,
string lpParameters, string lpDirectory, int nShowCmd ) LIBRARY
"shell32.dll"

// PowerScript
Long ll_rc
String ls_null

SetNull( ls_null )
ll_rc = ShellExecuteA ( Handle( w_frame ), &
"open", &
"c:\windows\myLetter.doc" + Char(0), &
ls_null, ls_null, SW_NORMAL )

IF ll_rc > 32 THEN // 0-32 are OS error codes
// Word should be opened now
ELSE
// handle error
END IF

--
pbm_hopethishelps,
Roy Kiesler [TeamSybase]
Sybase Developers Network (SDN) - http:///www.sybase.com/sdn

"Javier Español" <jesp...@ibersis.com.uy> wrote in message
news:a1QPtGzn$GA....@forums.sybase.com...

Steve Finck

unread,
Apr 5, 2000, 3:00:00 AM4/5/00
to
Javier,

Have you tried the PowerBuilder Run() command? In your PowerScript, place
the following line:

Run("C:\windows\myLetter.doc")

This should start word and open myLetter.doc. If this doesn't work and you
still want to use ShellExecute, you need to declare an external function.
In the PowerBuilder Help, look up "external functions". This should give
you the info. you desire.

--
Steve Finck
Corporate Technology Partners
www.ctpartners.com

Sybase J2EE Whistle Stop Tour
April 11 - Boston
April 13 - Denver

0 new messages