|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| ||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Typing "tasklist /m" in cmd window
Hello, when you type tasklist /m in the command window, it gives a list of all processes and the DLLs that are loaded for them.
I was wondering how they did this (WMI maybe?) and how I could potentially do the same thing programmatically. Thank you |
|
#2
|
||||
|
||||
|
Yours is not a C/C++/C# question. You want a Windows SDK forum.
And yes, I am pretty sure that subsystem has a WMI interface. It's just not within the scope of this forum.
__________________
My worst nightmare was a pointless infinite loop. Work in progress; don't poke the curmudgeon! http://www.odonahue.com/ |
|
#3
|
|||
|
|||
|
oh sorry. can you move it, or should I just create a new topic there?
|
|
#4
|
||||
|
||||
|
You're going to have to create a new thread there. It's not part of Devshed.
|
|
#5
|
||||
|
||||
|
Actually I think this is a very pertinent C or C++ question. He's asking how to do that programmatically. We do help with API calls here.
__________________
Up the Irons What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home. "Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest Down with Sharon Osbourne Puzzle of the Month solved by Fishmonger, superior perl programmer of the month |
|
#6
|
||||
|
||||
|
Quote:
Oh? I thought we didn't go into non-standard library support here. You're the mod. |
|
#7
|
|||
|
|||
|
You can get the source (C) of Tasklist on Advanced Win32 group (http://tinyurl.com/yjy3ajr)
|
|
#8
|
|||
|
|||
|
Hi, sorry but tinyurl is blocked for me. Could you perhaps post the full link? Thanks!
|
|
#10
|
|||
|
|||
|
Thanks guys. That page is very helpful and it has a link to this page where MS gives a nice example of how to enumerate all modules for a process:
Code:
#include <windows.h>
#include <tchar.h>
#include <stdio.h>
#include <psapi.h>
void PrintModules( DWORD processID )
{
HMODULE hMods[1024];
HANDLE hProcess;
DWORD cbNeeded;
unsigned int i;
// Print the process identifier.
printf( "\nProcess ID: %u\n", processID );
// Get a list of all the modules in this process.
hProcess = OpenProcess( PROCESS_QUERY_INFORMATION |
PROCESS_VM_READ,
FALSE, processID );
if (NULL == hProcess)
return;
if( EnumProcessModules(hProcess, hMods, sizeof(hMods), &cbNeeded))
{
for ( i = 0; i < (cbNeeded / sizeof(HMODULE)); i++ )
{
TCHAR szModName[MAX_PATH];
// Get the full path to the module's file.
if ( GetModuleFileNameEx( hProcess, hMods[i], szModName,
sizeof(szModName) / sizeof(TCHAR)))
{
// Print the module name and handle value.
_tprintf( TEXT("\t%s (0x%08X)\n"), szModName, hMods[i] );
}
}
}
CloseHandle( hProcess );
}
void main( )
{
// Get the list of process identifiers.
DWORD aProcesses[1024], cbNeeded, cProcesses;
unsigned int i;
if ( !EnumProcesses( aProcesses, sizeof(aProcesses), &cbNeeded ) )
return;
// Calculate how many process identifiers were returned.
cProcesses = cbNeeded / sizeof(DWORD);
// Print the name of the modules for each process.
for ( i = 0; i < cProcesses; i++ )
PrintModules( aProcesses[i] );
}
|
|
#11
|
||||
|
||||
|
Quote:
The key is in the Keywords. |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > C Programming > Typing "tasklist /m" in cmd window |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|