473,547 Members | 2,290 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Arrrrgh - Problems using OpenProcessToke n

283 Contributor
I have been trying to convert some C# code to VB but am getting stuck i've Tried everyting and spent ages on google but keep on getting Error 998 which I checked and is ERROR_NOACCESS when I check the last dll error although the c# code works fine, can anybody help please

Expand|Select|Wrap|Line Numbers
  1. Public Declare Function OpenProcessToken Lib "advapi32.dll" _ (ByVal ProcessHandle As Long, ByVal DesiredAccess As Long, _ ByVal TokenHandle As Long) As Long
  2.  
  3.     Private Const TOKEN_ADJUST_PRIVLEGES = &H20
  4.     Private Const TOKEN_QUERY = &H8
  5.     Private Const SE_PRIVILEGE_ENABLED = &H2
  6.  
  7. MyToken = 0
  8. Retval = OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVLEGES Or TOKEN_QUERY, MyToken)
  9.  
  10.    MsgBox("OpenProcess: " & Err.LastDllError)
  11.  
Apr 6 '08 #1
0 1749

Sign in to post your reply or Sign up for a free account.

Similar topics

0
2080
by: Jerome Lefebvre | last post by:
Hello, Hope this will interest a few. I been working with a friend on the problems given out during the "International Collegiate Programming Contest" (ICPC) http://icpc.baylor.edu/icpc/ . Started out just trying to find the solutions and then moving on, to "aggressively" trying to find the best solution for each problems. First started to...
4
6390
by: Pete Fong | last post by:
Dear all, I am a beginner with Python. I want to write a program as "runas" in Windows XP. But I have got the following error: File "C:\Python23\Lib\site-packages\Pythonwin\pywin\framework\scriptutils.py", line 310, in RunScript exec codeObject in __main__.__dict__ File "C:\python\Script1.py", line 30, in ? File "C:\python\Script1.py",...
7
29314
by: Vincent Nguyen | last post by:
Hi, Does anyone know how call Win32 native API GetTokenInformation() by using C#? Any sample code would be helpful. Thanks! Vincent
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
1
4908
by: Liang Yitao | last post by:
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...
3
4544
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 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...
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...
2
24971
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 use a API call to OpenProcessToken and use the Tokenhandle retrieved to build a WindowsIdentity object and do a access check on. Has anyone done...
1
2177
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
7507
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
1
7461
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
7794
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...
1
5361
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
3492
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3472
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1922
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
1
1046
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
747
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.