|
-
May 3rd, 2009, 08:33 PM
#1
Exiting programs
Hello! Just having a little trouble making a program right now
I've made a basic Win32 app so far, and i wan't it to close a program when i push a certain key. I made it a console app at first and tested that and it did work, but transitioning to the Win32 app is causing me trouble. I've put my code in the APIENTRY _tWinMain function which i think is the equivalent to the consoles init main function. Heres my code:
Code:
Torrent = FindWindow(NULL, _T("Vuze"));
if (KEYDOWN(VK_HOME))
{
if( Torrent = NULL )
{
ShellExecute(NULL, L"open", L"C:\\Documents and Settings\\Home\\Desktop\\Vuze\\Azureus.exe", NULL, L"C:\\", SW_SHOWNORMAL);
}
else
{
SendMessage(Torrent, WM_CLOSE, 0, 0);
}
}
and here is my little definition for the keydown if it helps thats in my stdafx.h file
Code:
#define KEYDOWN(vk_code) ((GetAsyncKeyState(vk_code) & 0x8000) ? 1 : 0)
It seems to run and compile fine, but i never see my program close. I used that exact code (except the key part) for my console and it worked. I have my handle at the top if your wondering where that is for the name Torrent. Is there anything i'm doing wrong here?
Lastly if your wondering why i am doing this, i have a phone that runs VOIP and my main PC with Media Center. I'm watching TV, the phone rings, and it takes me 30 seconds to turn off the torrents so i can hear what the people on the phone are saying. So i'm making life easier for myself
Thank you for your help!
-Dakiato
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|