473,771 Members | 2,392 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Why MainWindowHandl e is zero?

Question: why Process.MainWin dowHandle is zero?

--------------------------------------------------------------------------
From document of Process.MainWin dowHandle Property:

Property Value
The system-generated window handle of the main window of the associated
process.
Exceptions
Exception TypeCondition
InvalidOperatio nExceptionThe MainWindowHandl e is not defined because the
process has exited.
NotSupportedExc eptionYou are attempting to retrieve the MainWindowHandl e for
a process that is running on a remote computer.

Remarks
You can get the MainWindowHandl e property only for processes that are
running on the local computer. The MainWindowHandl e property is a value that
uniquely identifies the window that is associated with the process.
A process has a main window associated with it only if the process has a
graphical interface. If the associated process does not have a main window,
the MainWindowHandl e value is zero. If you have just started a process and
want to use its main window handle, consider using the WaitForInputIdl e
method to allow the process to finish starting, ensuring that the main
window handle has been created. Otherwise, an exception will be thrown.
--------------------------------------------------------------------------

I am trying to use GetProcessesByN ame("xxxx.exe") and then get the main
window's handle via Process.MainWin dowHandle; however, the return value is
zero.
1) the process is not in a remote computer;
2) the code works well if I change the process name to another one; e.g.
winmine.exe (the small game: mine sweeper :) )
3) the process xxxx.exe has finished starting. It is a kind of media player
and starts very fast. In fact, to testify that it has a main window handle,
I have tried to use Spy++ to find it and get its main window's handle and
title normally. Then I call SendMessage(hWn d, WM_GETTEXT, xxx, xxx) and get
its title.

1) Why I can NOT get the main window's handle via Process.MainWin dowHandle?
2) What you will do to accomplish this? I am trying EnumWindows()

Any response is highly appreciated. Thanks
Jul 21 '05 #1
0 3179

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

Similar topics

53
8217
by: Zhiqiang Ye | last post by:
Hi, All I am reading FAQ of this group. I have a question about this: http://www.eskimo.com/~scs/C-faq/q7.31.html It says: " p = malloc(m * n); memset(p, 0, m * n); The zero fill is all-bits-zero, and does not therefore guarantee useful null pointer values (see section 5 of this list) or floating-point zero values.
25
4433
by: pm940 | last post by:
Hello. I've been reading some past discussions on the NULL vs. zero. References are always made to systems or machienes that use values other than zero to represent the NULL pointer. Although not a practice I follow, there are no doubt millions of lines of open source libraries and applications that do things like: p = malloc(...);
2
4483
by: Moty Michaely | last post by:
Hello all, I am enumerating vb6 process from c# application by name. I need to send message to all processes that has the specified name but for this purpose I need the handle of the main window for each process returned. I once read that vb6 app mainWindowHandle is the handle of the hidden window that runs the application.
0
2623
by: Michiel | last post by:
Hello, When I execute the following code Process* oProc; IntPtr ipMain; HWND hWnd; oProc=Process::GetProcessById(m_IProcId); ipMain=oProc->MainWindowHandle; hWnd=(HWND)ipMain.ToPointer();
0
284
by: Luke | last post by:
Question: why Process.MainWindowHandle is zero? -------------------------------------------------------------------------- From document of Process.MainWindowHandle Property: Property Value The system-generated window handle of the main window of the associated process. Exceptions Exception TypeCondition
1
2529
by: codejunkie | last post by:
Hi, I am running a suite of tests of a WIN 32 application. Every test launches the same application, checks if the Application has a Main Window handle and then proceeds. However i am noticing when i run a reasonably large ( 80-90) number of tests one after the other the Main Window handle API displays inconsistant behavior. About 70% of the time my application returns a valid Main WIndow handle
4
7922
by: H.S. | last post by:
Hello, I am trying out a few methods with which to test of a given number is practically zero. as an example, does the following test correctly if a given number is zero within machine precision? I am trying out this method to check for a practical zero in an algorithm I am implementing in C++. ------------------------- #include <iostream> #include <iomanip>
23
4372
by: Hallvard B Furuseth | last post by:
As far as I can tell, (x & -1) is nonzero if the integer x is negative zero. So for signed types, x == 0 does not guarantee (x & foo) == 0. Is that right? (Not that I expect to ever encounter a non-two's-complement machine. Just wondering.) -- Hallvard
0
2197
by: siddharthkhare | last post by:
Hi all, I am trying to launch an process in .net as follows.I want to wait till mainwindow handle is initialized. fowlloing code works some times i.e i can read the value of mainwindow handle but some times it returns 0. I see the IE launched but still mainwindow handle is 0. I have pasted the code below. Question on waitforinputidle() A.Help on this method says "if process does not have a message queue,
0
9454
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
10103
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...
0
9911
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
8934
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...
0
6713
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();...
0
5482
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4007
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
3609
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2850
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.