473,385 Members | 1,409 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Error Using OpenProcessToken()

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:
--------------------------------
OpenProcessToken(hCurrentProcess,
TOKEN_ADJUST_PRIVILEGES|TOKEN_QUERY,
phProcessToken))
--------------------------------
When I debugged this code, the variable
phProcessToken is always shows "<undefined value>".

Please help me, and thanks a lot :)

Nov 17 '05 #1
1 4882
HANDLE hProcessToken=NULL;
if(!OpenProcessToken(GetCurrentProcess(),TOKEN_ALL _ACCESS,&hProcessToken))
printf("\nOpen Current Process Token failed:%d",GetLastError());

"Liang Yitao" <li*********@hotmail.com> wrote in message
news:01****************************@phx.gbl...
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:
--------------------------------
OpenProcessToken(hCurrentProcess,
TOKEN_ADJUST_PRIVILEGES|TOKEN_QUERY,
phProcessToken))
--------------------------------
When I debugged this code, the variable
phProcessToken is always shows "<undefined value>".

Please help me, and thanks a lot :)

Nov 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Enos Meroka | last post by:
Hallo, I am a student doing my project in the university.. I have been trying to compile the program using HP -UX aCC compiler, however I keep on getting the following errors. ...
4
by: Mohammed Abdel-Razzak | last post by:
Dear sirs I want to know how can I shutdown or restart my computer using C# Also I want to know how can I open any windows program using C# (EX: opening the windows calculator from my...
3
by: Liang Yitao | last post by:
I used DllImport() to load the function LookupPrivilegeValue() 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...
2
by: Brian Worth | last post by:
I have just upgraded from VB 4.0 to VB .NET 2002. One program under VB 4.0 was able to shut down or restart the (windows XP) machine using a series of API calls. (Getlasterror, GetCurrentProcess,...
2
by: Niclas | last post by:
Hi, I am trying to get a usertoken from a particular process running on the computer, from a Windows Service to do a Windows group membership of the user running that process. I was planning to...
1
by: asnowfall | last post by:
I want to get the list of privilages set on process token using C#. Please let me know. Thanks Ramesh
0
by: =?Utf-8?B?c2po?= | last post by:
Writing an app in VB.NET 2005 which needs to load a registry hive. As far as I can determine, there isn't any managed code to do this (sigh), so I need to revert to APIs. Additional privileges...
0
by: remya1000 | last post by:
i'm using VB.NET. i wrote a Auto Reboot program. and here is the codes i tried... Code: Private Enum ShutDown1 LogOff = 0 Shutdown = 1 Reboot = 2 ...
4
by: HumSupLow69 | last post by:
Here is my code... #include <windows.h> #include <iostream> int main() { DWORD pId; HWND hWnd; HANDLE hMine; do {
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.