Monday, 26 August 2013

program exits when shellexcute was called

program exits when shellexcute was called

win7 OS, vs2008. My program disappears when shellexcute was called,
It's a WTL project and the code like these: *.h
COMMAND_HANDLER(IDC_BTN_LOGIN, BN_CLICKED, DoLogin)
*.cpp
LRESULT XLoginView::DoLogin(WORD, WORD, HWND, BOOL&)
{
::ShellExecute(NULL, _T("open"), _T("http://mysite.com/login.php"),
NULL,NULL, SW_SHOW);
return 0;
}
when the login button was clicked, then my program was disappeard and the
visual studio exit too.
even the code is such simple as these:
int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
int nRetCode = 0;
// initialize MFC and print and error on failure
if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))
{
// TODO: change error code to suit your needs
_tprintf(_T("Fatal Error: MFC initialization failed\n"));
nRetCode = 1;
}
else
{
// TODO: code your application's behavior here.
ShellExecute(NULL, L"open", L"http://stackoverflow.com", NULL,
NULL, SW_SHOW);
}
return nRetCode;
}
the site(etc:http://stackoverflow.com) was openned only the first running
or debugging, then the second time and over, the visual studio disappears
at the same time.

No comments:

Post a Comment