473,769 Members | 7,058 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 3657
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
5290
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
2527
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
8601
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
976
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
895
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
3778
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
5139
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
6237
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
9589
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
9423
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
10216
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9997
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
9865
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8873
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
7413
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...
0
5309
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3565
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.