Solved

HANDLE --> HWND

Posted on 1998-11-12
2
1,594 Views
Last Modified: 2013-11-20
How can I convert a 'HANDLE' (retrieved from CreateProcess) to a 'HWND' or a 'CWnd *' ?

My application has launched an other application (Netmeting) with 'CreateProcess' and I want to minimize or not this application.

Can someone help me ?
0
Comment
Question by:mike_marquet
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 

Accepted Solution

by:
cmihalache earned 10 total points
ID: 1324561
Here is the answer. If you call CreateProcess, then you have a process handle, a thread handle, process id and a thread id(dwThreadId) in the PROCESS_INFORMATION structure. Then you call:

.
HWND hWnd = NULL;
EnumWindows((WNDENUMPROC)EnumWindowsProc, (LPARAM)&hWnd);
if (hWnd)
{
  // The window has been found.
}
.

BOOL CALLBACK EnumWindowsProc(HWND hwnd, LPARAM lParam)
{
  if (dwThreadId == GetWindowThreadProcessId(hwnd, NULL))
  {
    *(HWND*)lParam = hwnd;
    return FALSE; // Do not continue the search.
  }
  return TRUE; // Next window.
}
 



0
 

Author Comment

by:mike_marquet
ID: 1324562
Thanks  for this answer.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Suggested Courses

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question