partitionist
Erfahrenes Mitglied
Hab folgendes:
Hier wird die PID und der Prozess ausgegeben.
Ich möchte aber das ich die Ausgabe in ein Array oder String speichern kann und zurückgeben nur wie lässt sich das in der do-Schleife realisieren?
z.B.
return proc.szExeFile;
Code:
void getPID()
{
HANDLE hSysSnapshot = NULL;
PROCESSENTRY32 proc;
proc.dwSize = sizeof(proc);
hSysSnapshot = CreateToolhelp32Snapshot ( TH32CS_SNAPPROCESS, 0 );
if ( hSysSnapshot == (HANDLE)-1 )
system("exit");
if ( Process32First ( hSysSnapshot, &proc ) )
{
proc.dwSize = sizeof(proc);
cout << endl << "PID Process";
cout << endl << "------------------" << endl;
do
{
printf ("%lu - %s\n", proc.th32ProcessID, proc.szExeFile );
}
while ( Process32Next ( hSysSnapshot, &proc ) );
}
CloseHandle ( hSysSnapshot );
cout << endl;
}
Hier wird die PID und der Prozess ausgegeben.
Ich möchte aber das ich die Ausgabe in ein Array oder String speichern kann und zurückgeben nur wie lässt sich das in der do-Schleife realisieren?
z.B.
return proc.szExeFile;