Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

HANDLE --> HWND

Posted on 1998-11-12
2
Medium Priority
?
1,601 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 40 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
In this post we will learn different types of Android Layout and some basics of an Android App.
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
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.
Suggested Courses

926 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