473,545 Members | 2,772 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Error Using LookupPrivilege Value(...)

I used DllImport() to load the function
LookupPrivilege Value() 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 "997" which
means, in the system error code in MSDN, "Overlapped I/O
operation is in progress." I don't know what's wrong with
it. The calling code is as below:
--------------------------------
OpenProcessToke n(NULL,
SE_SHUTDOWN_NAM E,
&Luid))
--------------------------------
Here SE_SHUTDOWN_NAM E is "SeShutdownPriv ilege", and the
type of Luid is long.

Please help me, and thanks a lot :)

Nov 17 '05 #1
3 4543
Liang,

Are you using the SetLastError property of the DllImport attribute, and
the System::Runtime ::InteropServic es::Marshall::G etLastWin32Erro r
method? Do not use GetLastError with P/Invoke.

Also: I assume you meant to write LookupPrivilege Value instead of
OpenProcessToke n?

Bart Jacobs

Liang Yitao wrote:
I used DllImport() to load the function
LookupPrivilege Value() 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 "997" which
means, in the system error code in MSDN, "Overlapped I/O
operation is in progress." I don't know what's wrong with
it. The calling code is as below:
--------------------------------
OpenProcessToke n(NULL,
SE_SHUTDOWN_NAM E,
&Luid))
--------------------------------
Here SE_SHUTDOWN_NAM E is "SeShutdownPriv ilege", and the
type of Luid is long.

Please help me, and thanks a lot :)


Nov 17 '05 #2
Liang,
I used DllImport() to load the function
LookupPrivilege Value() 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 "997" which
means, in the system error code in MSDN, "Overlapped I/O
operation is in progress." I don't know what's wrong with
it. The calling code is as below:
--------------------------------
OpenProcessToke n(NULL,
SE_SHUTDOWN_NAM E,
&Luid))
--------------------------------
Here SE_SHUTDOWN_NAM E is "SeShutdownPriv ilege", and the
type of Luid is long.

If you're using DllImport instead of using IJW, then make sure you set the
SetLastError property of the DllImport attribute to true. You'd probably be
better off then calling Marshal.GetLast Win32Error() instead of
GetLastError().

--
Tomas Restrepo
to****@mvps.org
Nov 17 '05 #3
Oh, yes. I made a mistake ^_^
Thank you for your reply, and I'll try to do it in your
way.
-----Original Message-----
Liang,

Are you using the SetLastError property of the DllImport attribute, andthe System::Runtime ::InteropServic es::Marshall::G etLastWin32Er
rormethod? Do not use GetLastError with P/Invoke.

Also: I assume you meant to write LookupPrivilege Value instead ofOpenProcessTok en?

Bart Jacobs

Liang Yitao wrote:
I used DllImport() to load the function
LookupPrivilege Value() 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 "997" which
means, in the system error code in MSDN, "Overlapped I/O operation is in progress." I don't know what's wrong with it. The calling code is as below:
--------------------------------
OpenProcessToke n(NULL,
SE_SHUTDOWN_NAM E,
&Luid))
--------------------------------
Here SE_SHUTDOWN_NAM E is "SeShutdownPriv ilege", and the type of Luid is long.

Please help me, and thanks a lot :)


.

Nov 17 '05 #4

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

Similar topics

5
5693
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. ================================================================= Error 19: "CORBAManagerMessages.h", line 4 # Unexpected 'std'. using std::string; ^^^
6
4721
by: Peter Frost | last post by:
Please help I don't know if this is possible but what I would really like to do is to use On Error Goto to capture the code that is being executed when an error occurs. Any help would be much appreciated. Thanks in advance
4
42206
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 application) thanks Mohammed
2
11391
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, OpenProcessToken, LookupPrivilegeValue, AdjustTokenPrivilegese, ExitWindowsEx. I am trying to avoid using any API calls if possible and to use...
1
3331
by: plmanikandan | last post by:
Hi, I am using LookupPrivilegeValue to check whether SE_TCB_NAME privilege exists for the user or not in windows 2000 .The value returned from LookupPrivilegeValue function is always true.i checked in administartive tools for the right act as part of operating system is disabled .my code is below //declarations
2
5302
by: f rom | last post by:
----- Forwarded Message ---- From: Josiah Carlson <jcarlson@uci.edu> To: f rom <etaoinbe@yahoo.com>; wxpython-users@lists.wxwidgets.org Sent: Monday, December 4, 2006 10:03:28 PM Subject: Re: 1>make_buildinfo.obj : error LNK2019: unresolved external symbol __imp__RegQueryValueExA@24 referenced in function _make_buildinfo2 Ask on...
0
2058
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 need to be added to the current process token before RegLoadKey can be used successfully. This exception is thrown when I call AdjustTokenPrivileges:...
0
1434
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 ForcedLogOff = 4
4
8563
by: HumSupLow69 | last post by:
Here is my code... #include <windows.h> #include <iostream> int main() { DWORD pId; HWND hWnd; HANDLE hMine; do {
0
7946
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7457
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7791
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6026
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5360
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5078
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3470
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1921
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
744
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.