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 :) 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 :)
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
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 :)
. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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;
^^^
|
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
|
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
|
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...
|
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
| |
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...
|
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:...
|
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
|
by: HumSupLow69 |
last post by:
Here is my code...
#include <windows.h>
#include <iostream>
int main()
{
DWORD pId; HWND hWnd; HANDLE hMine;
do {
|
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...
|
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...
| |
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...
|
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...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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
| |
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...
| |