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());
 
Back
Top