472,126 Members | 1,445 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

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 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
1 3562
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.

Similar topics

3 posts views Thread by dave | last post: by
reply views Thread by Sam Marrocco | last post: by
4 posts views Thread by Kerem Gümrükcü | last post: by
reply views Thread by leo001 | last post: by

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.