473,386 Members | 1,702 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Getting main window from launched process

Hi All,

I am launching a IE using following code.
================================================== =====================
m_IeProcess = new Process();
m_IeProcess.StartInfo.WindowStyle = ProcessWindowStyle.Minimized;
m_IeProcess = Process.Start("IExplore.exe","www.ABC.com");
================================================== =====================

how do i get refrence to the InternetExplorer from the process.

only way i could do it is by iterating over the all windows as follows

================================================== =============

m_Windows = new ShellWindows();
foreach(InternetExplorer ie in m_Windows)
{
if(ie != null && (IntPtr)ie.HWND ==
m_IeProcess.MainWindowHandle)
{
return ie;
}
}
================================================== =====================

Qustion :
is there a way to get refrence to the internet explorer without using
shell window.

Process class has properties that return Mainwindow handle and caption
etc...but i do not see anything that returns the reference to the main
window itself.

I need the refrence to IE because i want to iterate through the window
object model.
I will be running this code as windows service and shell window does
not work in windows service that why i am looking at other ways to do
this.

SO is there a way to get the refrence to IE from the lauched process
or may be using a windows API that will work in windows service as
well?

Thanks
Siddharth
Dec 7 '07 #1
2 1897
On Dec 7, 2:51 pm, siddharthkh...@hotmail.com wrote:
Hi All,

I am launching a IE using following code.
================================================== =====================
m_IeProcess = new Process();
m_IeProcess.StartInfo.WindowStyle = ProcessWindowStyle.Minimized;
m_IeProcess = Process.Start("IExplore.exe","www.ABC.com");
================================================== =====================

how do i get refrence to the InternetExplorer from the process.

only way i could do it is by iterating over the all windows as follows

================================================== =============

m_Windows = new ShellWindows();
foreach(InternetExplorer ie in m_Windows)
{
if(ie != null && (IntPtr)ie.HWND ==
m_IeProcess.MainWindowHandle)
{
return ie;
}
}

================================================== =====================

Qustion :
is there a way to get refrence to the internet explorer without using
shell window.

Process class has properties that return Mainwindow handle and caption
etc...but i do not see anything that returns the reference to the main
window itself.

I need the refrence to IE because i want to iterate through the window
object model.
I will be running this code as windows service and shell window does
not work in windows service that why i am looking at other ways to do
this.

SO is there a way to get the refrence to IE from the lauched process
or may be using a windows API that will work in windows service as
well?

Thanks
Siddharth
Well, your not going to get a .net reference from the process
class... All your gong to get is the MainWindow handle (you could
probably wrap it in an instance of NativeWindow). What exactly are
you trying to accomplish? I have a feeling there is a much better
way...

--
Tom Shelton
Dec 8 '07 #2
Use CLSID_INTERNETEXPLORER to create a com object. You can all its methods
using late binding, or create an early binding class.
--
Sheng Jiang
Microsoft MVP in VC++
<si************@hotmail.comwrote in message
news:22**********************************@d21g2000 prf.googlegroups.com...
Hi All,

I am launching a IE using following code.
================================================== =====================
m_IeProcess = new Process();
m_IeProcess.StartInfo.WindowStyle = ProcessWindowStyle.Minimized;
m_IeProcess = Process.Start("IExplore.exe","www.ABC.com");
================================================== =====================

how do i get refrence to the InternetExplorer from the process.

only way i could do it is by iterating over the all windows as follows

================================================== =============

m_Windows = new ShellWindows();
foreach(InternetExplorer ie in m_Windows)
{
if(ie != null && (IntPtr)ie.HWND ==
m_IeProcess.MainWindowHandle)
{
return ie;
}
}
================================================== =====================

Qustion :
is there a way to get refrence to the internet explorer without using
shell window.

Process class has properties that return Mainwindow handle and caption
etc...but i do not see anything that returns the reference to the main
window itself.

I need the refrence to IE because i want to iterate through the window
object model.
I will be running this code as windows service and shell window does
not work in windows service that why i am looking at other ways to do
this.

SO is there a way to get the refrence to IE from the lauched process
or may be using a windows API that will work in windows service as
well?

Thanks
Siddharth

Dec 8 '07 #3

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

Similar topics

13
by: BlackHawke | last post by:
Our program, game program Andromeda Online (www.andromedaonline.net) uses two programs- one to play the game, another to patch the game as updates come out. Players actually launch the updater...
10
by: Scott | last post by:
I'm new to ASP, but I've been programming in VB for several years, and I'm having a few issues with this ASP enhancement I'm working on. I've found ASP to be a lot different than what I'm use to...
11
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....
6
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...
1
by: tma | last post by:
First, I'm following instructions without truly understanding them, so go easy on me... :) I am exporting a report to .PDF. Below is a code snippet. What I would like is for a new IE instance to...
1
by: spamproof2005 | last post by:
I have the following code: Dim BrowserLauncher As New ProcessStartInfo BrowserLauncher.FileName = URL BrowserLauncher.CreateNoWindow = False BrowserLauncher.UseShellExecute = True...
12
by: Dilip | last post by:
Hi All I have a server based C# console application. This application must hide its console window when its launched out on the field. So I dutifully P/Invoke'd FindWindow/ShowWindow...
2
by: siddharthkhare | last post by:
Hi All, I am launching a IE using following code. ======================================================================= m_IeProcess = new Process(); m_IeProcess.StartInfo.WindowStyle =...
1
by: KakaICE | last post by:
Hi, I am using Visual Studio 2005 The problem is: The parent.exe launches a child.exe executible. In the child.exe process I want to know the commandline with which parent.exe was originally...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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...
0
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...

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.