By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,454 Members | 1,804 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,454 IT Pros & Developers. It's quick & easy.

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

P: n/a
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. For example, here's a piece of code that launches an external process
to open a Microsoft Word Document:

Process p = new Process();
ProcessStartInfo s = new ProcessStartInfo();
s.Verb = "Print";
s.FileName = @"C:\twain.doc";
p.StartInfo = s;
p.StartInfo.UseShellExecute = 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\command".
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
Share this Question
Share on Google+
1 Reply


P: n/a
No problem here running Word8 (Office 2003) on XP.

HCLR\word.Document\shell\print\command\default should look like:

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

"Fei Yuan" <fe*@carmelvision.com> wrote in message
news:OH**************@TK2MSFTNGP14.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 ProcessStartInfo() object.
ProcessStartInfo has a property "UseShellExecute" 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();
ProcessStartInfo s = new ProcessStartInfo();
s.Verb = "Print";
s.FileName = @"C:\twain.doc";
p.StartInfo = s;
p.StartInfo.UseShellExecute = 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\command". 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 discussion thread is closed

Replies have been disabled for this discussion.