473,725 Members | 2,007 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to retrieve a handle/ID of a Process launched by Shell with DDEEXEC?

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 ProcessStartInf o() object.
ProcessStartInf o has a property "UseShellExecut e" that can open/print a
file. For example, here's a piece of code that launches an external process
to open a Microsoft Word Document:

Process p = new Process();
ProcessStartInf o s = new ProcessStartInf o();
s.Verb = "Print";
s.FileName = @"C:\twain.doc" ;
p.StartInfo = s;
p.StartInfo.Use ShellExecute = true;
p.Start();

The code executes without a problem, openning the document with Microsoft
Word. However, I cannot grab any handle of the newly launched process.
Accessing p.Handle will throw an exception of "no associated process", and
in fact, most of the fields of p are either null or with the same exception.

If I try the same code above but with FileName either an EXE file or TXT
files, I can grab the new process handle without any problem. My guess is
the file extension association. Grabbing the handle of a launched process
from an executable file is obviously easy. Grabbing the handle of a "TXT"
file might be easy by just looking at the registry key "shell\open\com mand".
However, for Microsoft Word document, it uses something called "DDEEXEC"
server, maybe that's the reason Process.Start() does not return any handle?

I've been stuck on this for a while and what I need to do is to launch an
external application on files and be able to monitor the process of the
external application, if it hangs kill it and restart over again. My
alternatives include attempting to implement the mechanism of calling
DDEEXEC in my own code and thus to grab the handle (if not possible at all),
or just monitor all processes on the computer and detect the newly added
process (which is resource-consuming and inaccurate).

Please try the code I included above, any help or hint will be greatly
appreciated!

Regards,
- Fei -


Nov 16 '05 #1
1 3655
No problem here running Word8 (Office 2003) on XP.

HCLR\word.Docum ent\shell\print \command\defaul t should look like:

REG_SZ "C:\Program Files\Microsoft Office\OFFICE11 \WINWORD.EXE" /x /n
/dde
command\command :
REG_MULTI_SZ "']gAVn-}f(ZXfeAR6.jiWO RDFiles>P`os,1@ SW=P7v6GPl]Xh /x /n
/dde"
Willy.

"Fei Yuan" <fe*@carmelvisi on.com> wrote in message
news:OH******** ******@TK2MSFTN GP14.phx.gbl...
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 ProcessStartInf o() object.
ProcessStartInf o has a property "UseShellExecut e" that can open/print a
file. For example, here's a piece of code that launches an external
process to open a Microsoft Word Document:

Process p = new Process();
ProcessStartInf o s = new ProcessStartInf o();
s.Verb = "Print";
s.FileName = @"C:\twain.doc" ;
p.StartInfo = s;
p.StartInfo.Use ShellExecute = true;
p.Start();

The code executes without a problem, openning the document with Microsoft
Word. However, I cannot grab any handle of the newly launched process.
Accessing p.Handle will throw an exception of "no associated process", and
in fact, most of the fields of p are either null or with the same
exception.

If I try the same code above but with FileName either an EXE file or TXT
files, I can grab the new process handle without any problem. My guess is
the file extension association. Grabbing the handle of a launched process
from an executable file is obviously easy. Grabbing the handle of a "TXT"
file might be easy by just looking at the registry key
"shell\open\com mand". However, for Microsoft Word document, it uses
something called "DDEEXEC" server, maybe that's the reason Process.Start()
does not return any handle?

I've been stuck on this for a while and what I need to do is to launch an
external application on files and be able to monitor the process of the
external application, if it hangs kill it and restart over again. My
alternatives include attempting to implement the mechanism of calling
DDEEXEC in my own code and thus to grab the handle (if not possible at
all), or just monitor all processes on the computer and detect the newly
added process (which is resource-consuming and inaccurate).

Please try the code I included above, any help or hint will be greatly
appreciated!

Regards,
- Fei -

Nov 16 '05 #2

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

Similar topics

3
5287
by: dave | last post by:
Hi, Does anyone know how I could make an .exe launched server side from an aspx file run faster? When I use javascript client side it of couse is much faster. Here's my code This code does work but it's extremely slow. What am I missing? Process Updater = new Process();
3
2526
by: Fei Yuan | last post by:
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"...
2
8599
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 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. Process.Handle throws an...
6
38453
by: James Li | last post by:
I need to run multiple .bat files(in specific order, sychronously) from my C# windows app. I also want to hide the DOS command window so that users don't see them. Basically my program lanches .bat file to do some installation, status of the installation will be displayed on the windows app, but don't want the dos window showed. I look at Microsoft.VisualBasic.Interaction.Shell, that Shell out command is asynchronous, right? If it...
0
975
by: Sam Marrocco | last post by:
I seem to be having a devil of a time killing a process.... If I launch an applicaton such as notepad.exe as a Process, I can kill it with no problem. However, if I launch a particulare application (it's a shell application that does some lengthy math processing) as a Process and attempt to kill it, the Process returns properly with an Exited event, but the shell window continues to be open and processing. My guess is that this math app...
0
894
by: PokerJoker | last post by:
I created a monitor program that checks for certain critera and then launches other executables to perform maintenence tasks. One of these executables uses a DLL, when launched by double clicking, runs flawlessly. However, when this application is run via Process.start, or Shell(), the application dies on the line where the DLL is dimmed. I get the following error,
4
3777
by: Zorpiedoman | last post by:
dim FileName as string = "Test.doc" dim P as Process = Process.Start(FileName) '--P is NOTHING even though document opens!!! dim Q as new process Q.StartInfo.FileName = FileName P = Q.start '--P is nothing here, either WHY????
4
5137
by: Kerem Gümrükcü | last post by:
Hi, i wonder that the Process.Start(...) needs full path to the executable to start it, even the executable is listed in the PATH Variable and can be launched from any console on my system. Is it possible to do the same from Process.Start(...)? How can i set the Process Executon Environment for the Process, so that the call to Start(...) will resolve the path to the Exe from the PATH Env. and run it. Is this possible...? Maybe i miss...
7
6236
by: Samuel A. Falvo II | last post by:
I have a shell script script.sh that launches a Java process in the background using the &-operator, like so: #!/bin/bash java ... arguments here ... & In my Python code, I want to invoke this shell script using the Subprocess module. Here is my code: def resultFromRunning_(command):
0
8886
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8750
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9256
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9168
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8091
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6701
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
3218
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2632
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2154
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.