Solved

HANDLE --> HWND

Posted on 1998-11-12
2
1,584 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
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
no14 challenge 14 71
wait notify demo infinite loop 3 124
Line meaning 9 87
mapAB Challlenge 35 156
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…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

860 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