473,399 Members | 4,177 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

How to retrieve a handle to the Process from ShellExecute()?

Starting an external process needs to pass it a ProcessStartInfo() object.
ProcessStartInfo has a property "UseShellExecute" that can open/print a
file. However, I'm having a hard time getting the handle to the application
after calling Process.Start(). Basically, I need the handle to monitor the
application launched.

Anybody knows where I can retrieve this handle or process ID? I also looked
into Windows API's "shell32.dll" "Execute()" function, it however returns a
handle that's only good to check if any error occurred, not the actual
Process handle.

Any help or hint will be appreciated!

Regards,
- Fei -
Nov 16 '05 #1
3 2512
"Fei Yuan" <fe*@carmelvision.com> wrote:
I'm having a hard time getting the handle to the
application after calling Process.Start().


Is this what you want?

Process p = new Process( ... );
IntPtr h = p.Handle;

P.
Nov 16 '05 #2
No, accessing that field will throw an exception "No associated process".
The key is that the process is not started directly, but through the Shell,
with Shell commands.
"Paul E Collins" <fi******************@CL4.org> wrote in message
news:cj**********@hercules.btinternet.com...
"Fei Yuan" <fe*@carmelvision.com> wrote:
I'm having a hard time getting the handle to the
application after calling Process.Start().


Is this what you want?

Process p = new Process( ... );
IntPtr h = p.Handle;

P.

Nov 16 '05 #3
Why do you need to set the UseShellExecute flag?

--
cody

Freeware Tools, Games and Humour
http://www.deutronium.de.vu || http://www.deutronium.tk
"Fei Yuan" <fe*@carmelvision.com> schrieb im Newsbeitrag
news:eH**************@TK2MSFTNGP10.phx.gbl...
Starting an external process needs to pass it a ProcessStartInfo() object.
ProcessStartInfo has a property "UseShellExecute" that can open/print a
file. However, I'm having a hard time getting the handle to the application after calling Process.Start(). Basically, I need the handle to monitor the application launched.

Anybody knows where I can retrieve this handle or process ID? I also looked into Windows API's "shell32.dll" "Execute()" function, it however returns a handle that's only good to check if any error occurred, not the actual
Process handle.

Any help or hint will be appreciated!

Regards,
- Fei -

Nov 16 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Phil B Brubaker | last post by:
I'm trying to create my own shellexecute program named shell4OD and am having problems with handles. Here is my code ... ===== Private Declare Function ShellExecute Lib _ "shell32.dll" Alias...
0
by: Bruno | last post by:
I have created a VB5 program that opens documents by calling the shellexecute API. This works great. I am looking for a corresponding API or other procedure that would allow me to close the...
16
by: Daniel Tonks | last post by:
First, please excuse the fact that I'm a complete MySQL newbie. My site used forum software that I wrote myself (in Perl) which, up until now, has used flat files. This worked fine, however...
2
by: Fei Yuan | last post by:
Please forgive me re-posting this question since I wasn't clear in my original post. ---- Starting an external process needs to pass it a ProcessStartInfo() object. ProcessStartInfo has a...
1
by: Fei Yuan | last post by:
Please forgive me re-posting this question since I wasn't clear in my original post. --------> Starting an external process needs to pass it a ProcessStartInfo() object. ProcessStartInfo has a...
1
by: | last post by:
Hello Guys, I am trying to execute a .exe file from a web application using shell command. But somehow I am not able to make it work. The strange thing is when I use the same code and...
0
by: Mac | last post by:
Hi there, can someone please tell me how to get the handle of a process wich is currently locking a file? Example: Create a word-document using word, save and reopen it, then try to delete...
13
by: kev | last post by:
Hi all, I have created a database for equipments. I have a form to register the equipment meaning filling in all the particulars (ID, serial, type, location etc). I have two buttons at the end...
11
by: kudruu | last post by:
Hi, I am trying to find a way to populate a list of active Com ports on a computer. There may be around 30 on one computer and all connected to different Buses but I am looking for one in...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.