PC Review


Reply
Thread Tools Rate Thread

How do I find the main window handle?

 
 
Mike
Guest
Posts: n/a
 
      26th Nov 2007
In a DLL written in C#, how can you get the handle of the main window
of the app that called you?

Thanks,
Mike
 
Reply With Quote
 
 
 
 
Nicholas Paldino [.NET/C# MVP]
Guest
Posts: n/a
 
      26th Nov 2007
Mike,

AFAIK, there is no API that will do this for you.

Rather, the easiest way I can think of is to call the static
GetCurrentProcess method on the Process class and then access the
MainWindowHandle property on the Process instance returned.


--
- Nicholas Paldino [.NET/C# MVP]
- (E-Mail Removed)

"Mike" <(E-Mail Removed)> wrote in message
news:a9ae5000-49c8-47a7-9fb9-(E-Mail Removed)...
> In a DLL written in C#, how can you get the handle of the main window
> of the app that called you?
>
> Thanks,
> Mike



 
Reply With Quote
 
Mike
Guest
Posts: n/a
 
      26th Nov 2007
That seems to work. Thanks!

On Nov 26, 3:21 pm, "Nicholas Paldino [.NET/C# MVP]"
<m...@spam.guard.caspershouse.com> wrote:
> Mike,
>
> AFAIK, there is no API that will do this for you.
>
> Rather, the easiest way I can think of is to call the static
> GetCurrentProcess method on the Process class and then access the
> MainWindowHandle property on the Process instance returned.
>
> --
> - Nicholas Paldino [.NET/C# MVP]
> - m...@spam.guard.caspershouse.com
>
> "Mike" <MLM...@hotmail.com> wrote in message
>
> news:a9ae5000-49c8-47a7-9fb9-(E-Mail Removed)...
>
>
>
> > In a DLL written in C#, how can you get the handle of the main window
> > of the app that called you?

>
> > Thanks,
> > Mike- Hide quoted text -

>
> - Show quoted text -


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Retrieving main window handle fdmaxey Microsoft Dot NET Framework Forms 2 2nd May 2006 02:13 PM
Main window handle (processes) Per Rollvang Microsoft C# .NET 2 21st Dec 2004 08:35 AM
Handle to main window. objectref Microsoft C# .NET 11 26th Sep 2004 02:13 AM
Process class and main window handle property Microsoft Dot NET Framework 4 15th Jan 2004 12:46 PM
Process class and main window handle property Microsoft C# .NET 4 15th Jan 2004 12:46 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:36 PM.