Hi Every Budy.....
I am very much biginer with C#.....
Now a have to make a small program in C# using windows API, Findwindow
I just want to get handel or any window, Could any of you please tell me the code how can i use the required APi in C#.........
Thanx and Regards
Vishwa
Vishwa SharmaPosted Mar 13, 2008, 1:05 AM
Thanx a lot.....
Regards
AlanPosted Mar 12, 2008, 12:52 PM
First place the following line amongst your using directives:
using System.Runtime.InteropServices;
Now place the following method declaration in the class from which you want to call FindWindow:
[DllImport("user32.dll")]
static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
Notice that the method has no body because this is supplied by the API function itself within the user32 dll.
Now just call the function as you would if it were a C# method. For example to get the handle of an empty Notepad window:
IntPtr hWnd = FindWindow("Notepad", "Untitled - Notepad");