Here is what I need to accomplish:
1. Start new process using Process.Start
2. Get it's handle and save to text file.
On next execution I read text file and see if process with same
name/handle still runs. However, I see that handle I obtain after
execution does not match handle that I get from list.
My code like this:
Process myGen = new Process();
myGen.StartInfo .FileName = Environment.Cur rentDirectory +
"\\SampleGenera tor.exe"; myGen.Start();
Thread.Sleep(10 00); // I had to do this in order to avoid "Unable to
enumerate process
//modules" exception. Is there solution to this problem?
GeneratorProces s gp2 = new GeneratorProces s();
gp2.Name = myGen.ProcessNa me;
gp2.Handle = myGen.Handle.To Int32(); //I get handle from process object
that I started
Process runs for over minute. When I execute code to enumerate
processes
Process[] RunningProcesse s = Process.GetProc esses();
I get this process with completely different Handle.
What am I doing wrong?
TIA 4 4378
Hello, Katit!
K1. Start new process using Process.Start
K2. Get it's handle and save to text file.
This doesn't have sense, since on the next process start handle will change.
KOn next execution I read text file and see if process with same
Kname/handle still runs. However, I see that handle I obtain after
Kexecution does not match handle that I get from list.
You observer this because there is no guarantee that OS will reuse process handles.
What are you trying to accomplish?
--
Regards, Vadym Stetsyak
www: http://vadmyst.blogspot.com
K1. Start new process using Process.Start
K2. Get it's handle and save to text file.
This doesn't have sense, since on the next process start handle will change.
I'm executing outside program from my app and want to grab it's handle
which I save.
Then next time my program executes (it run's on a schedule) I read list
of system processes and compare handles to stored ones to see if it was
process executed by me.
It seem to be working now if I use Process.Id..
You observer this because there is no guarantee that OS will reuse process handles.
See above
Also, do you know why I get exception(see in comment in original post)
when try to read Process properties immediately after Process.Start?
Hi Katit
Have you tried to use Process.Id instead of Process.Handle ?
Boaz Ben-Porat
Milestone Systems
"Katit" <id*********@gm ail.comskrev i en meddelelse
news:11******** ************@m7 3g2000cwd.googl egroups.com...
Here is what I need to accomplish:
1. Start new process using Process.Start
2. Get it's handle and save to text file.
On next execution I read text file and see if process with same
name/handle still runs. However, I see that handle I obtain after
execution does not match handle that I get from list.
My code like this:
Process myGen = new Process();
myGen.StartInfo .FileName = Environment.Cur rentDirectory +
"\\SampleGenera tor.exe"; myGen.Start();
Thread.Sleep(10 00); // I had to do this in order to avoid "Unable to
enumerate process
//modules" exception. Is there solution to this problem?
GeneratorProces s gp2 = new GeneratorProces s();
gp2.Name = myGen.ProcessNa me;
gp2.Handle = myGen.Handle.To Int32(); //I get handle from process object
that I started
Process runs for over minute. When I execute code to enumerate
processes
Process[] RunningProcesse s = Process.GetProc esses();
I get this process with completely different Handle.
What am I doing wrong?
TIA
Id works for that purpose.
But I still have annoying problem.
If I try to get Id next line after Process.Start - I get exception
"unable to enumerate process modules"
This is some kind of timing issue. Thread.Sleep(xx x) fixes it, but it's
ugly. And of course it works when you step through code.
Any way to do callback when process started or something like this that
will be more reliable?
Thanks!
Ivan
Boaz Ben-Porat wrote:
Hi Katit
Have you tried to use Process.Id instead of Process.Handle ?
Boaz Ben-Porat
Milestone Systems This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Ross Bennett |
last post by:
Ahoy, Folks!
I've been looking all over for this, but I just can't seem to shake any
documentation out of the MSDN or from Google. I've reviewed every .NET
article on developing Windows Services in the MSDN I've located.
I'm developing a Windows Service application. This service reads its
configuration data from the system registry (HKLM) where it was deposited by
another "manager" application. No problems there.
|
by: David Berman |
last post by:
Hi, I've written an application to do a while bunch of Excel automation.
I open a file, scan through all the worksheets, extract data, and then I
try to close Excel. However, I can see that I'm not doing it
effectively. If I am debugging my app, and I kill the app before my app
exits, but after the call that should close excel, I still have an
excell process sitting around. After about 20 + of those stack up, you
start to feel it.
If I...
|
by: objectref |
last post by:
Hi to all,
is there a way to get the window handle of the main window of an application
or process ?
For example, if someone opens Microsoft Word, he gets a window so he/she can
write text.
Spy++ gives that this window is called _Wwg.
How we can get a handle to this window assuming that we do not know
beforehand the name of the process,
|
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"...
|
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...
| |
by: Manfred Braun |
last post by:
Hi All,
I am writing a proggi, which should monitor some processes. While doing
this, I needed a test-program and wrote one, which does nothing else than to
consume some cpu, sometimes more, sometimes less. As I monitored this
process for a time, I found the handles increasing without end. I assume
this is a bug, but I do not understand, where this could be located in my
simple app. The core is as follows:
private void OnTimer(object...
|
by: Ricky W. Hunt |
last post by:
I have written a close routine to handle an "Exit" button to close the
application properly. How do I make sure this gets executed if the user
closes it another way (by pressing the "X" in the upper right hand for
instance, or Alt+4, etc.) Or is this even necessary?
--
Thanks,
Ricky W. Hunt
freendeed
|
by: Jonah Bishop |
last post by:
I'm developing a photo album web application for use on a web site, and
I'm running into a problem with lengthy operations. My application
allows the user to import a number of images at once into a photo
album. For each image that gets imported, I create two thumbnail images
(small and medium) and insert some data into a database. The thumbnail
generation process takes some time and, for relatively large amount of
photos, the application...
|
by: chuckie_9497 |
last post by:
hello all you gurus. I am struggling with releasing com objects. I
have isolated the problem to the code below. Objects are released and
the process ends until I
use "int k = sheet.Count;" Then the process does not end. So I feel
confident the problem occurrs here. It appears another reference is
created that needs to be closed. Can anyone tell me how to do
this? :)
Thank you
Excel.Workbook workbook =
|
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...
|
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,...
| |
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...
|
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...
|
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...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |