Solved

HANDLE --> HWND

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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Login Script to Copy Folders 12 35
Expand to include initial dialog with two choices. 9 77
sum13 challenge 24 106
Increment column based of a FK 8 20
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
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…

805 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