Originally posted by: Dino
Hello im an IT student & currently following OS as a subject... I would like to know how to get da Process ID & process attributes of a running process. Is thereAny methods to be used ?? in windows 2000 ofcourse Thankx in advance !!
ReplyOriginally posted by: Joseph
how to get parent process ID on Winnt 4.0
welcome provide a solution...... wait for Hi cracke
Originally posted by: Robert
pModule32First(snapshot, &module);
The returnvalue from Module32First is ignored, and if the process has no modules (yes this is possible)
Cheers.
The following code:
if ( OnModule(module.hModule, module.szExePath, module.szModule) == FALSE )
{
CloseHandle(snapshot);
return TRUE;
}
we get old or invalid module info sent to OnModule.
/Robert
Originally posted by: woo
There is a lot's of applitcation started when my OS boot. Some of these app open a TCP port on my computer, I wish somebody tell me how can I know a port is opened by which process ?
I wish I Know any answer for this question,too.
Reply
Originally posted by: John Lu
I have a exe file, and I want to know whether it is running, if it is running, I also want to get it's hwnd. How to do it?
ReplyOriginally posted by: Ovais
Thanks in advance.
Your article and code was very helpful. Can I somehow find the status of an application, whether it is running or hanged (Not Responding) as reported by Task Manager in Windows NT.
Originally posted by: Billy
Hi all
There is a lot's of applitcation started when my OS boot. Some of these app open a TCP port on my computer, I wish somebody tell me how can I know a port is opened by which process ?
ReplyOriginally posted by: ThoWa
I'm looking for a solution to end a task under WinNT4.0 like it is possible with the task manager.
Reply
Originally posted by: Sarbendu Paul
So, if your objective is to know whether a particular process is running, you can do 2 things :
1.When searching for the process "beauty.exe",
2.An alternative way is to use the MakeUpper or MakeLower function of CString class and then search for the process name.
In a Windows 2000 machine, the the name of the process found may not contain the total path of the process.The process name found may also not have all letters in caps.
For eg.,
What may appear as "C:\WINDOWS\SYSTEM\BEAUTY.EXE" in other OS, in Win 2000 it may appear as only "beauty.exe".
search for all combinations like "BEAUTY.EXE","Beauty.exe","beauty.exe" in the name of the process.
Originally posted by: tig
Here's a small sample, showing how to enumerate processes on local computer :
/*********************************************/
public:
protected:
protected:
/*********************************************/
CAppsEnum::~CAppsEnum()
bool CAppsEnum::Connect()
BSTR pNamespace = m_namespace.AllocSysString();
if(pIWbemLocator -> ConnectServer(pNamespace, NULL,
SysFreeString(pNamespace);
CoSetProxyBlanket(m_pIWbemServices,
bool CAppsEnum::Enum()
HRESULT hRes = m_pIWbemServices -> CreateInstanceEnum(
return SUCCEEDED(hRes);
bool CAppsEnum::Next()
if(m_pStorageProc)
HRESULT hRes = m_pEnumStorageProcesses -> Next(
return SUCCEEDED(hRes) && uReturned;
void CAppsEnum::Free_IEnum()
if(m_pEnumStorageProcesses)
bool CAppsEnum::GetProperty(OLECHAR* popertyname, VARIANT *pVal)
HRESULT hRes = m_pStorageProc -> Get(
return SUCCEEDED(hRes);
Now one can enumerate processes on Win9x, WinNT or Win2000 machines using new Microsoft technology WMI.
It's a set of COM interfaces that are very easy to use and give full information about working processes on local or remote computer.
With minor chages you can easely get information on anything on computer (threads, hard disks, heat pipe cooling devices... etc.).
//CApssEnum definition
/*********************************************/
class CAppsEnum
{
public:
CAppsEnum();
virtual ~CAppsEnum();
bool Enum();
bool Next();
bool GetProperty(IN OLECHAR*, OUT VARIANT*);
bool Connect();
void Free_IEnum();
IWbemServices *m_pIWbemServices;
IEnumWbemClassObject *m_pEnumStorageProcesses;
IWbemClassObject* m_pStorageProc;
CString m_namespace;
};
//CApssEnum implementation
/*********************************************/
CAppsEnum::CAppsEnum()
{
m_pStorageProc = NULL;
m_pIWbemServices = NULL;
m_pEnumStorageProcesses = NULL;
m_namespace = _T("\\\\.\\root\\cimv2");
Connect();
}
{
Free_IEnum();
if(m_pIWbemServices)
m_pIWbemServices -> Release();
}
{
bool bRet = true;
IWbemLocator *pIWbemLocator = NULL;
if(CoCreateInstance(CLSID_WbemLocator,
NULL,
CLSCTX_INPROC_SERVER,
IID_IWbemLocator,
(LPVOID*)&pIWbemLocator) == S_OK)
{
if(m_pIWbemServices)
m_pIWbemServices -> Release();
NULL, 0L, 0L, NULL, NULL, &m_pIWbemServices) != S_OK)
{
bRet = false;
AfxMessageBox(_T("Bad namespace"));
}
pIWbemLocator -> Release();
RPC_C_AUTHN_WINNT, RPC_C_AUTHZ_NONE, NULL,
RPC_C_AUTHN_LEVEL_CALL,
RPC_C_IMP_LEVEL_IMPERSONATE, NULL, EOAC_NONE);
}
else
{
bRet = false;
AfxMessageBox(_T("Failed to create IWbemLocator
object"));
}
return bRet;
}
{
Free_IEnum();
BSTR className = SysAllocString(L"Win32_Process");
className, 0, NULL, &m_pEnumStorageProcesses);
}
{
ULONG uReturned = 1;
{
m_pStorageProc -> Release();
m_pStorageProc = NULL;
}
2000, 1, &m_pStorageProc, &uReturned);
}
{
if(m_pStorageProc)
{
m_pStorageProc -> Release();
m_pStorageProc = NULL;
}
{
m_pEnumStorageProcesses -> Release();
m_pEnumStorageProcesses = NULL;
}
}
{
VariantClear(pVal);
BSTR propName = SysAllocString(popertyname);
propName, 0L, pVal, NULL, NULL);
}
Reply