PDA

Archiv verlassen und diese Seite im Standarddesign anzeigen : [C/C++]error LNK 2019



matze093
20.06.2010, 17:30
Hii Leute,
Ich habe versucht mittels "EnumProcesses" die IDs aller laufenden Prozesse in einem Array zu speicher.

Leider erhalte ich beim kompilieren folgende Fehlermeldung:
"error LNK2019: Verweis auf nicht aufgelöstes externes Symbol "_EnumProcesses@12" in Funktion ""unsigned long __cdecl GetProcessesIDs(void)" (?GetProcessesIDs@@YAKXZ)"."

Kann mir vllt jemand helfen?

Der Code ist im Spoiler zu sehen.
#include "stdafx.h"
#include <iostream>
#include <windows.h>
#include <stdio.h>
#include <tchar.h>
#include "psapi.h"


using namespace std;
DWORD GetProcessesIDs(void)
{
int i;
DWORD aProcesses[1024], cbNeeded;
i = EnumProcesses( aProcesses, sizeof(aProcesses), &cbNeeded );


return 0;
}
int _tmain(int argc, _TCHAR* argv[])
{
GetProcessesIDs();
UINT dwSessionId = WTSGetActiveConsoleSessionId();
cout << dwSessionId << endl;
system("PAUSE");
return 0;

}

ocz
20.06.2010, 17:35
Da ist diese Funktion wohl - warum auch immer - nicht definiert

inout
20.06.2010, 17:38
Du musst gegen die psapi.lib linken.

trisn
20.06.2010, 17:39
Kann es sein das dir ne Lib fehlt ? slap me if i say shit

edit ; kay scheint ja schon ne antwort gekommen zu sein

ocz
20.06.2010, 17:39
MSDN ist übrigens kostenlos für jeden zugänglich. Da hätteste auch Ansatzpunkte gefunden



Starting with Windows 7 and Windows Server 2008 R2, Psapi.h establishes version numbers for the PSAPI functions. The PSAPI version number affects the name used to call the function and the library that a program must load.
If PSAPI_VERSION is 2 or greater, this function is defined as K32EnumProcesses in Psapi.h and exported in Kernel32.lib and Kernel32.dll. If PSAPI_VERSION is 1, this function is defined as EnumProcesses in Psapi.h and exported in Psapi.lib and Psapi.dll as a wrapper that calls K32EnumProcesses.

jojoomgasd
20.06.2010, 17:40
#pragma comment(lib, "psapi.lib")

und außerdem, heißt es nicht #include <psapi.h>?
btw noch :
#include's gehören lieber in die stdafx.h rein damit man nur #include "stdafx.h" schreiben muss

matze093
20.06.2010, 17:58
Zunächst einmal DANKE für die schnellen Antworten.

Wenn ich die Zeile #pragma comment(lib, "psapi.lib") hinzufüge tritt kein Fehler meher auf.
Könntet ihr mir noch erklären was genau diese Zeile bewirkt.