Error Using OpenProcessToken()

  • Thread starter Thread starter Liang Yitao
  • Start date Start date
L

Liang Yitao

I used DllImport() to load the function OpenProcessToken
() in advapi32.dll, and then called it in my button click
event. But the function always returns false. I got the
error code it left through GetLastError() function and
the result is "998" which means, in the system error code
in MSDN, "Invalid access to memory location." I don't
know what's wrong with it.
The calling code is as below:
 
HANDLE hProcessToken=NULL;
if(!OpenProcessToken(GetCurrentProcess(),TOKEN_ALL_ACCESS,&hProcessToken))
printf("\nOpen Current Process Token failed:%d",GetLastError());
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top