Click here to Skip to main content
15,903,362 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: try to stump me on C++ Pin
marcio k6-Jul-08 20:23
marcio k6-Jul-08 20:23 
JokeRe: try to stump me on C++ Pin
enhzflep7-Jul-08 17:40
enhzflep7-Jul-08 17:40 
AnswerRe: try to stump me on C++ Pin
andersod28-Jul-08 10:53
andersod28-Jul-08 10:53 
QuestionCFileStatus [modified] Pin
baloneyman5-Jul-08 7:39
baloneyman5-Jul-08 7:39 
AnswerRe: CFileStatus Pin
Mark Salsbery5-Jul-08 8:50
Mark Salsbery5-Jul-08 8:50 
GeneralRe: CFileStatus Pin
baloneyman5-Jul-08 12:56
baloneyman5-Jul-08 12:56 
QuestionHow to put my toolbar visible by default? Pin
DillerXX5-Jul-08 7:20
DillerXX5-Jul-08 7:20 
QuestionError Code 87 Pin
Saksida Bojan5-Jul-08 6:35
Saksida Bojan5-Jul-08 6:35 
Hello.
I Know this isnt quite right forum to ask. The App is C#, however i am using Native WinAPI.
I am trying to list all process, and get full path. PROCESSENTRY32 in 95/98 used full path for exe. But not on newer system. MODULEENTRY32 Have szExePath. I wanted to use this to get full path.

I Used CreateToolhelp32Snapshot method to emurate process. (The only method that gave me good results). But to use Module32First() i need to open process, but i get error 87. On MSDN i found it is ERROR_INVALID_PARAMETER.

Is there a whay to fix this problem, or a diffrent method of getting full path. And no, no searching files through HDD.(I am intrested in the first solution)

Thanks in advance.

int hWnd = CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS, 0);
PROCESSENTRY32 pe = new PROCESSENTRY32();
pe.dwSize = (uint)System.Runtime.InteropServices.Marshal.SizeOf(typeof(PROCESSENTRY32));

int first = Process32First(hWnd, ref pe);
int error = GetLastError();
if (first == 0)
   throw new ProcessListException("Can not get process list");

do 
{
   ProcessInfo pi = new ProcessInfo();
   pi.iProcessID = (int)pe.th32ProcessID;
   pi.sFileName = pe.szExeFile;
   SetLastError(0); // To Reset any Error Codes
   int handle = OpenProcess(PROCESS_ALL_ACCESS, true, pi.iProcessID);
   // 87 = GetLastError();
   MODULEENTRY32 me = new MODULEENTRY32();
   me.dwSize = (uint)System.Runtime.InteropServices.Marshal.SizeOf(typeof(MODULEENTRY32));
   bool t = Module32First(handle, ref me);
} while (Process32Next(hWnd, ref pe) != 0);
CloseHandle(hWnd);


Edit: Styling
AnswerRe: Error Code 87 Pin
User 24844375-Jul-08 7:32
User 24844375-Jul-08 7:32 
AnswerRe: Error Code 87 Pin
Mark Salsbery5-Jul-08 9:04
Mark Salsbery5-Jul-08 9:04 
GeneralRe: Error Code 87 Pin
Saksida Bojan5-Jul-08 21:28
Saksida Bojan5-Jul-08 21:28 
Questioncompressing audio with g711 makes lots of noise Pin
doudou-shen5-Jul-08 6:09
doudou-shen5-Jul-08 6:09 
AnswerRe: compressing audio with g711 makes lots of noise Pin
Varghese Paul M7-Jul-08 0:01
Varghese Paul M7-Jul-08 0:01 
Question"The ultimate grid" - adding new rows to a grid Pin
Sternocera5-Jul-08 5:58
Sternocera5-Jul-08 5:58 
AnswerRe: "The ultimate grid" - adding new rows to a grid Pin
followait5-Jul-08 14:49
followait5-Jul-08 14:49 
QuestionRe: "The ultimate grid" - adding new rows to a grid Pin
Sternocera6-Jul-08 0:05
Sternocera6-Jul-08 0:05 
AnswerRe: "The ultimate grid" - adding new rows to a grid Pin
followait6-Jul-08 2:04
followait6-Jul-08 2:04 
AnswerRe: "The ultimate grid" - adding new rows to a grid Pin
Graham Shanks6-Jul-08 10:44
Graham Shanks6-Jul-08 10:44 
QuestionHow could this be? Pin
followait5-Jul-08 4:16
followait5-Jul-08 4:16 
AnswerRe: How could this be? Pin
David Crow5-Jul-08 4:48
David Crow5-Jul-08 4:48 
Answerthe thread could be finished [modified] Pin
followait5-Jul-08 13:57
followait5-Jul-08 13:57 
QuestionLarge File problem Pin
Ubik K5-Jul-08 2:45
Ubik K5-Jul-08 2:45 
QuestionRe: Large File problem Pin
David Crow5-Jul-08 4:55
David Crow5-Jul-08 4:55 
AnswerRe: Large File problem Pin
Joe Woodbury5-Jul-08 11:24
professionalJoe Woodbury5-Jul-08 11:24 
GeneralRe: Large File problem Pin
Ubik K5-Jul-08 15:44
Ubik K5-Jul-08 15:44 

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.