Click here to Skip to main content
15,918,889 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: System clock loses time and jumps back up Pin
sumeat12-Nov-09 7:57
sumeat12-Nov-09 7:57 
GeneralRe: System clock loses time and jumps back up Pin
Richard MacCutchan12-Nov-09 9:09
mveRichard MacCutchan12-Nov-09 9:09 
QuestionRe: System clock loses time and jumps back up Pin
David Crow12-Nov-09 5:23
David Crow12-Nov-09 5:23 
AnswerRe: System clock loses time and jumps back up Pin
sumeat12-Nov-09 7:52
sumeat12-Nov-09 7:52 
GeneralRe: System clock loses time and jumps back up Pin
Randor 12-Nov-09 12:21
professional Randor 12-Nov-09 12:21 
GeneralRe: System clock loses time and jumps back up Pin
sumeat12-Nov-09 14:23
sumeat12-Nov-09 14:23 
GeneralRe: System clock loses time and jumps back up Pin
Randor 12-Nov-09 15:20
professional Randor 12-Nov-09 15:20 
QuestionHow to hide a dialog box of another application completely ? Pin
hongheo7611-Nov-09 11:52
hongheo7611-Nov-09 11:52 
AnswerRe: How to hide a dialog box of another application completely ? Pin
«_Superman_»11-Nov-09 12:04
professional«_Superman_»11-Nov-09 12:04 
QuestionAdd dual COM interface to non-MFC application [solved] Pin
jmen@moc11-Nov-09 11:16
jmen@moc11-Nov-09 11:16 
AnswerRe: Add dual COM interface to non-MFC application Pin
Stuart Dootson11-Nov-09 11:41
professionalStuart Dootson11-Nov-09 11:41 
GeneralRe: Add dual COM interface to non-MFC application Pin
jmen@moc11-Nov-09 11:55
jmen@moc11-Nov-09 11:55 
AnswerRe: Add dual COM interface to non-MFC application [solved] Pin
«_Superman_»11-Nov-09 11:55
professional«_Superman_»11-Nov-09 11:55 
QuestionProgramatically change paper size during execution of PageSetupDlg Pin
hx200011-Nov-09 11:06
hx200011-Nov-09 11:06 
Question[Message Deleted] Pin
hunter12348311-Nov-09 9:26
hunter12348311-Nov-09 9:26 
AnswerRe: Result search clustering using salient phrase extaction Pin
Richard MacCutchan11-Nov-09 9:50
mveRichard MacCutchan11-Nov-09 9:50 
QuestionHow to get a process name from process ID ? Pin
hongheo7611-Nov-09 9:25
hongheo7611-Nov-09 9:25 
AnswerRe: How to get a process name from process ID ? Pin
Randor 11-Nov-09 9:43
professional Randor 11-Nov-09 9:43 
GeneralRe: How to get a process name from process ID ? Pin
hongheo7611-Nov-09 10:37
hongheo7611-Nov-09 10:37 
GeneralRe: How to get a process name from process ID ? Pin
Randor 11-Nov-09 11:18
professional Randor 11-Nov-09 11:18 
AnswerRe: How to get a process name from process ID ? Pin
wangningyu11-Nov-09 21:37
wangningyu11-Nov-09 21:37 
Here is a Class to use:
// ProcessNametoID.h: interface for the CProcessNametoID class.<br />
//<br />
//////////////////////////////////////////////////////////////////////<br />
<br />
#if !defined(AFX_PROCESSNAMETOID_H__4217BFFA_FB96_4DAF_A665_3EF82774CD57__INCLUDED_)<br />
#define AFX_PROCESSNAMETOID_H__4217BFFA_FB96_4DAF_A665_3EF82774CD57__INCLUDED_<br />
<br />
#if _MSC_VER > 1000<br />
#pragma once<br />
#endif // _MSC_VER > 1000<br />
<br />
class CProcessNametoID  <br />
{<br />
public:<br />
	CProcessNametoID();<br />
	DWORD GetProcessID(char* m_name);<br />
	virtual ~CProcessNametoID();<br />
private:<br />
	HANDLE m_snapshot;<br />
<br />
};<br />
<br />
#endif // !defined(AFX_PROCESSNAMETOID_H__4217BFFA_FB96_4DAF_A665_3EF82774CD57__INCLUDED_)<br />


// ProcessNametoID.cpp: implementation of the CProcessNametoID class.<br />
//<br />
//////////////////////////////////////////////////////////////////////<br />
<br />
#include "stdafx.h"<br />
#include "ProcessID.h"<br />
#include "ProcessNametoID.h"<br />
#include <Tlhelp32.h><br />
<br />
#ifdef _DEBUG<br />
#undef THIS_FILE<br />
static char THIS_FILE[]=__FILE__;<br />
#define new DEBUG_NEW<br />
#endif<br />
<br />
//////////////////////////////////////////////////////////////////////<br />
// Construction/Destruction<br />
//////////////////////////////////////////////////////////////////////<br />
<br />
CProcessNametoID::CProcessNametoID()<br />
{<br />
	this->m_snapshot=NULL;<br />
}<br />
<br />
CProcessNametoID::~CProcessNametoID()<br />
{<br />
	<br />
}<br />
<br />
DWORD CProcessNametoID::GetProcessID (char* m_name)<br />
{<br />
	DWORD m_pid=0;<br />
	bool  m_status=false;<br />
	PROCESSENTRY32 m_ppe;<br />
	::memset(&m_ppe,0,sizeof(PROCESSENTRY32));<br />
	m_ppe.dwSize=sizeof(PROCESSENTRY32);<br />
	__try<br />
	{<br />
		this->m_snapshot=::CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0);<br />
		if(this->m_snapshot==NULL)<br />
		{<br />
			__leave;<br />
		}<br />
		<br />
		m_status=::Process32First(this->m_snapshot ,&m_ppe);	<br />
		int a=::GetLastError();<br />
		while(m_status)<br />
		{<br />
			char *current;<br />
			current=m_ppe.szExeFile;<br />
			if(lstrcmpi(m_name,current))<br />
			{<br />
				m_status=::Process32Next(this->m_snapshot ,&m_ppe);<br />
			}<br />
			else<br />
			{<br />
				m_pid=m_ppe.th32ProcessID;<br />
				m_status=false;<br />
			}<br />
		}<br />
	}<br />
	__finally<br />
	{<br />
		::CloseHandle (this->m_snapshot);<br />
		return m_pid;<br />
	}<br />
}<br />



Best Reguards !
General[OT] Re: How to get a process name from process ID ? Pin
David Crow12-Nov-09 5:26
David Crow12-Nov-09 5:26 
GeneralRe: [OT] Re: How to get a process name from process ID ? Pin
wangningyu12-Nov-09 15:53
wangningyu12-Nov-09 15:53 
Questionconverting string to time [modified] Pin
sugarandcream11-Nov-09 8:46
sugarandcream11-Nov-09 8:46 
AnswerRe: converting string to time Pin
David Crow11-Nov-09 9:05
David Crow11-Nov-09 9:05 

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.