Click here to Skip to main content
15,907,183 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Programme is bad. Pin
Ravi Bhavnani21-Apr-04 4:44
professionalRavi Bhavnani21-Apr-04 4:44 
GeneralRe: Programme is bad. Pin
toxcct21-Apr-04 5:01
toxcct21-Apr-04 5:01 
GeneralRe: Programme is bad. Pin
David Crow21-Apr-04 5:13
David Crow21-Apr-04 5:13 
GeneralRe: Programme is bad. Pin
jmkhael21-Apr-04 5:26
jmkhael21-Apr-04 5:26 
GeneralRe: Programme is bad. Pin
toxcct21-Apr-04 5:32
toxcct21-Apr-04 5:32 
GeneralRe: Programme is bad. Pin
Ravi Bhavnani21-Apr-04 7:06
professionalRavi Bhavnani21-Apr-04 7:06 
GeneralRe: Programme is bad. Pin
Prakash Nadar21-Apr-04 8:25
Prakash Nadar21-Apr-04 8:25 
GeneralTabbed Controls with Tool Bars Pin
cleathley@iinet21-Apr-04 4:42
cleathley@iinet21-Apr-04 4:42 
GeneralCustom Cursor causes cursor to flick when moving the mouse Pin
stelitsisan21-Apr-04 4:41
stelitsisan21-Apr-04 4:41 
GeneralRe: Custom Cursor causes cursor to flick when moving the mouse Pin
Ravi Bhavnani21-Apr-04 4:43
professionalRavi Bhavnani21-Apr-04 4:43 
GeneralRe: Custom Cursor causes cursor to flick when moving the mouse Pin
Iain Clarke, Warrior Programmer21-Apr-04 5:51
Iain Clarke, Warrior Programmer21-Apr-04 5:51 
GeneralCreate Windows Service with C++ Pin
andysmurfen21-Apr-04 4:04
andysmurfen21-Apr-04 4:04 
GeneralRe: Create Windows Service with C++ Pin
Antony M Kancidrowski21-Apr-04 5:06
Antony M Kancidrowski21-Apr-04 5:06 
GeneralRe: Create Windows Service with C++ Pin
tareqsiraj21-Apr-04 5:27
tareqsiraj21-Apr-04 5:27 
GeneralRe: Create Windows Service with C++ Pin
Mike Dimmick21-Apr-04 6:00
Mike Dimmick21-Apr-04 6:00 
QuestionHow do I type a System._ComObject? Pin
mhuslig21-Apr-04 4:03
mhuslig21-Apr-04 4:03 
QuestionHow do I close a running program? Pin
IronMaiden42021-Apr-04 3:53
IronMaiden42021-Apr-04 3:53 
AnswerRe: How do I close a running program? Pin
jmkhael21-Apr-04 3:54
jmkhael21-Apr-04 3:54 
GeneralRe: How do I close a running program? Pin
Shail_Srivastav21-Apr-04 5:14
Shail_Srivastav21-Apr-04 5:14 
you can close program by two method
1. by sending WM_CLOSE, you have to find the window using FindWindow function.
2. using TerminateProcess(hProcess, 0), you need to find the process id (pid)

I find the other method better, if the application have many threads, for example when you exit the visual studio, its running many threads in background. Its hide the window but takes time to clear all the threads. you can see it from task manager.

// Shail [11/11/2002]
const CString ConfigPage::ProcessTerminate(int nApp, bool &bSuccess) const
{
CString msg;
DWORD pid = 0;
HANDLE hProcess;
CCSITimer oTimer;
bSuccess = true;

SetCursor(LoadCursor(NULL, IDC_WAIT));
pid = GetPIDfromAppName(m_strProcessApps[nApp]);
if (pid)
{
// open the process with all access
hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pid);

// bye-bye
if (hProcess)
{
TerminateProcess(hProcess, 0);
oTimer.Start();
while ( ( pid )
&& !oTimer.IsElapsed( PROCESS_TERMINATE_TIMEOUT ) )
{
Pump();
oTimer.Delay(500);
pid = GetPIDfromAppName(m_strProcessApps[nApp]);
}

if ( pid == 0 )
msg.Format("%s Terminated.", m_strApps[nApp]);
else
bSuccess = false;
}
}
return msg;
}

const CString ConfigPage::ProcessDistroy(int nApp, bool &bSuccess) const
{
CString msg;
CWnd * pWnd = NULL;
CCSITimer oTimer;

SetCursor(LoadCursor(NULL, IDC_WAIT));

if (m_strApps[nApp].IsEmpty())
return msg;
pWnd = FindWindow(NULL, m_strApps[nApp]);
if (pWnd )
{
pWnd->PostMessage(WM_CLOSE);

if ( C7StartupConfigPage::nDS == nApp )
{
msg.Format("Close %s Manually.", m_strApps[nApp]);
}
else
{
oTimer.Start();
while ( (NULL != pWnd)
&& !oTimer.IsElapsed( PROCESS_TERMINATE_TIMEOUT ) )
{
Pump();
oTimer.Delay(500);
pWnd = FindWindow(NULL, m_strApps[nApp]);
}

if ( NULL == pWnd )
msg.Format("%s Terminated.", m_strApps[nApp]);
else
bSuccess = false;
}

}
else
{
// Shail [11/11/2002]
// if app window doesn't exists, then just terminate the app. [ most prob. its a crashed app.]
ProcessTerminate(nApp, bSuccess);
}

return msg;
}


Shail Srivastav
shailsrivastav@hotmail.com
QuestionConnectionPoint Interface? Pin
ndalal21-Apr-04 3:42
ndalal21-Apr-04 3:42 
GeneralPorting Mac to Win, WaitMouseMoved Pin
Maarten Kools21-Apr-04 3:27
professionalMaarten Kools21-Apr-04 3:27 
GeneralRe: Porting Mac to Win, WaitMouseMoved Pin
Anonymous21-Apr-04 3:47
Anonymous21-Apr-04 3:47 
GeneralRe: Porting Mac to Win, WaitMouseMoved Pin
Maarten Kools21-Apr-04 4:58
professionalMaarten Kools21-Apr-04 4:58 
GeneralIf anyone from Microsoft is reading this (VC++ 7.1) Pin
Giles21-Apr-04 3:25
Giles21-Apr-04 3:25 
GeneralRe: If anyone from Microsoft is reading this (VC++ 7.1) Pin
David Crow21-Apr-04 5:18
David Crow21-Apr-04 5:18 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.