|
Hi guys,
I have an application tool which needs to safely and effectively close down other applications. I have seen a few posts on here about getting the PROCESSENTRY32 structure and then issuing a TerminateProcess command on it, however, this doesn't seem the safest method. Using SendMessage(WM_CLOSE,0,0) appears to be a safer option. Therefore my question is: is it possible to get a window handle to the main window created by a known PROCESSENTRY32 structure?
Thanks in advance,
Simon
|
|
|
|
|
Try using EnumWindows. Look it up on MSDN. EnumWindows will look at every windows handle for you, and then you just need a way of telling which window you want!
You need to write a function that EnumWindows will call. In this function use GetWindowText or GetClassName. Then compare each window with the text or class name you know you're looking for. How do you know what the text or class name for the window is? The text is easy. That's what's displayed in the bar at the very top of the window. The class name is better, if the program you're targeting has a stable class name. To find the class name of the window you want to target use Spy++. Be careful, though, because a program can have several windows and several class names for the windows. You just have to make sure to get the class name of the parent.
This method works great! I've used it myself. You have to be careful, though, because not all programs will let you close them safely. Internet Explorer or Windows Explorer (I think they're virtually the same thing) won't close if you send them the WM_CLOSE message. But hey, if you can find a way to safely close them, I'd like to know too!
Danny
|
|
|
|
|
srev wrote:
herefore my question is: is it possible to get a window handle to the main window created by a known PROCESSENTRY32 structure?
this will help
Is it possible to get info between HWND and Process handle?[^]
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
Any recommendations from those who tried both? I would like to use something simpler like RMI for C++[^], but it's still young and under development, and I need something mature, stable and scalable
My programming blahblahblah blog. If you ever find anything useful here, please let me know to remove it.
|
|
|
|
|
did you have a look at ICE[^]?
|
|
|
|
|
Very interesting. Too bad it is GPL, and at this point I can't purchase a commercial license.
My programming blahblahblah blog. If you ever find anything useful here, please let me know to remove it.
|
|
|
|
|
Nemanja Trifunovic wrote:
Any recommendations from those who tried both? I would like to use something simpler like RMI for C++[^], but it's still young and under development, and I need something mature, stable and scalable
XML-RPC[^] seems to have gained momentum as lightweight alternative for distributed computing (disclaimer: haven't tried it).
|
|
|
|
|
Nah, too much overhead. This needs to be a binary protocol.
BTW, I have already worked with SOAP, and it seemed to me that it was a XML-RPC killer.
My programming blahblahblah blog. If you ever find anything useful here, please let me know to remove it.
|
|
|
|
|
Hello,
I tried CORBA, but I (and every other student) didn't like it. You have incredibly much initialization to do and additional servers to run if you want maximum flexibility and scalability.
If it's no problem for your client to integrate the CORBA infrastructure and you can get passed the initialization, everything works like a charm. As far as I know (D)COM, your code with CORBA will look much more cleaner.
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
Who can help me to add to a title bar a menu( or a dialog ) in a MFC SDI application?
NG
|
|
|
|
|
Hi,
Is it possible to create a macro that would create an instance of a class? I'm trying this but the compiler won't accept it:
#define Logger() (MyLogger tempLogger(__FUNCTION__, __FILE__, __LINE__))
Thanks
Hua-Ying
|
|
|
|
|
|
error C2059: syntax error : ')'
error C2146: syntax error : missing ')' before identifier 'tempLogger'
error C3861: 'tempLogger': identifier not found, even with argument-dependent lookup
|
|
|
|
|
class MyLogger
{
MyLogger( char*, char*, char*)
{
}
};
#define Logger() (MyLogger tempLogger(__FUNCTION__, __FILE__, __LINE__))
no error on visual c++ 6.0...
NG
|
|
|
|
|
The syntax error only occurs when I try to use the macro. The errors are:
error C2059: syntax error : ')'
error C2146: syntax error : missing ')' before identifier 'tempLogger'
error C3861: 'tempLogger': identifier not found, even with argument-dependent lookup
Hua-Ying
|
|
|
|
|
#include <iostream>
using namespace std;
#define Logger() MyLogger tempLogger(__FUNCTION__, __FILE__, __LINE__)
class MyLogger
{
public:
MyLogger(char *pFunction, char *pFile, long Line)
{
cout<
|
|
|
|
|
Thanks that really does work!
I've always though that argument in a #define were separated by spaces so that it would see 3 arguments there. I guess I was wrong!
|
|
|
|
|
How do i find a control's current x,y coordinates on the window??
|
|
|
|
|
looking here[^] i found that code :
CRect ButtonRect;
GetWindowRect(ButtonRect);
pParent->ScreenToClient(ButtonRect)
reading the sample more in details should help you more...
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
|
Use GetClientRect() if you want the coordinates relative to the upper-left of the client area (i.e., left and top are both 0). Use GetWindowRect() if you want the coordinates relative to the upper-left of the screen.
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
Hello All
Can any one suggest free "BMP /ICO collection" downloadable sites for the using in my application.
Thanks for your time
Ravi
|
|
|
|
|
|
I tried and end up with lot of tools to create / modify the images But not really the image collection.
- Ravi
|
|
|
|
|
i cannot do anything for you that way...
there are so many sites... if you can't find at least ont, i give up...
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|