-
May 14th, 2012, 08:15 AM
#1
Windows Function
FindWindow(NULL,"Windows Task Manager");
not working in c language any one tell me why here i use title of task manager i know first perameter i can also use but i wanna use second one i use dev c++ compiler and also add user32.a lib in project when i call that function its return NULL thx
-
May 14th, 2012, 08:41 AM
#2
Re: Windows Function
If you are programming in Windows then you must read MSDN documentation about all Windows APIs you are using.
From MSDN:
FindWindow
The FindWindow function retrieves a handle to the top-level window whose class name and window name match the specified strings. This function does not search child windows. This function does not perform a case-sensitive search.
To search child windows, beginning with a specified child window, use the FindWindowEx function.
HWND FindWindow(
LPCTSTR lpClassName, // class name
LPCTSTR lpWindowName // window name
);
...
Return Values
If the function succeeds, the return value is a handle to the window that has the specified class name and window name.
If the function fails, the return value is NULL. To get extended error information, call GetLastError.
So what does GetLastError return?
Victor Nijegorodov
-
May 15th, 2012, 07:37 AM
#3
Re: Windows Function
error = the specified module could not be found
-
May 15th, 2012, 07:53 AM
#4
Re: Windows Function
Well, this code
Code:
HWND hWnd = ::FindWindow(NULL, "Windows Task Manager");
does work for me in a console VC++ application, MBCS build.
If your build is UNICODE then you must pass in the wide char string:
Code:
HWND hWnd = ::FindWindow(NULL, L"Windows Task Manager");
The only requirement for success, however is Task Manager must run.
Victor Nijegorodov
-
May 15th, 2012, 09:27 AM
#5
Re: Windows Function
thx for it ur last line my answer but i have one noob type question this function work when window open at desktop?????
basically findwindow mean find window but i think its requires
-
May 15th, 2012, 10:57 AM
#6
Re: Windows Function
If window is closed then its handle is closed too. Therefore FindWindow cannot find it (how would it possible to find what not exists!?)
If Task Manager is minimized to tray its main window is closed, thus FindWindow cannot find it.
Victor Nijegorodov
-
May 15th, 2012, 12:39 PM
#7
Re: Windows Function
yes u r right i solve my prblem thx
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|