Solved

HANDLE --> HWND

Posted on 1998-11-12
2
1,577 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
Comment Utility
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
Comment Utility
Thanks  for this answer.
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
MFC Dialog 9 47
paragon account problem 9 96
Fibonacci challenge 11 82
Path of Workbook 3 44
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
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…
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 tutorial demonstrates a quick way of adding group price to multiple Magento products.

771 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now