Question about Microsoft Windows XP Professional With Servise Pack 2 (e8503040) for PC

1 Answer

What is the program code to shutdown the pc in visual basic

I need a program to shutdown the pc in visual basic

Posted by on

1 Answer

  • Level 1:

    An expert who has achieved level 1.

  • Contributor
  • 1 Answer

I was wondering if someone could help me to convert this vb6 code to be used
in VB.net. It basically allows you to call the subs at the bottom to logoff
shutdown and restart the pc (By force if necessary). Any help is greatly
appreciated.

Private Const EWX_LOGOFF = 0
Private Const EWX_SHUTDOWN = 1
Private Const EWX_REBOOT = 2
Private Const EWX_FORCE = 4
Private Const TOKEN_ADJUST_PRIVILEGES = &H20
Private Const TOKEN_QUERY = &H8
Private Const SE_PRIVILEGE_ENABLED = &H2
Private Const ANYSIZE_ARRAY = 1
Private Const VER_PLATFORM_WIN32_NT = 2

Type OSVERSIONINFO
dwOSVersionInfoSize As Long
dwMajorVersion As Long
dwMinorVersion As Long
dwBuildNumber As Long
dwPlatformId As Long
szCSDVersion As String * 128
End Type

Public Type LUID
LowPart As Long
HighPart As Long
End Type

Public Type LUID_AND_ATTRIBUTES
pLuid As LUID
Attributes As Long
End Type

Public Type TOKEN_PRIVILEGES
PrivilegeCount As Long
Privileges(ANYSIZE_ARRAY) As LUID_AND_ATTRIBUTES
End Type

Private Declare Function GetCurrentProcess Lib "kernel32.dll" () As Long
Private Declare Function OpenProcessToken Lib "advapi32.dll" (ByVal
ProcessHandle As Long, ByVal DesiredAccess As Long, TokenHandle As Long) As
Long
Private Declare Function LookupPrivilegeValue Lib "advapi32.dll" Alias
"LookupPrivilegeValueA" (ByVal lpSystemName As String, ByVal lpName As
String, lpLuid As LUID) As Long
Private Declare Function AdjustTokenPrivileges Lib "advapi32.dll" (ByVal
TokenHandle As Long, ByVal DisableAllPrivileges As Long, NewState As
TOKEN_PRIVILEGES, ByVal BufferLength As Long, PreviousState As
TOKEN_PRIVILEGES, ReturnLength As Long) As Long
Private Declare Function ExitWindowsEx Lib "user32.dll" (ByVal uFlags As
Long, ByVal dwReserved As Long) As Long
Private Declare Function GetVersionEx Lib "kernel32.dll" Alias
"GetVersionExA" (ByRef lpVersionInformation As OSVERSIONINFO) As Long

Private Sub EnableShutDown()
Dim hProc As Long
Dim hToken As Long
Dim mLUID As LUID
Dim mPriv As TOKEN_PRIVILEGES
Dim mNewPriv As TOKEN_PRIVILEGES

hProc = GetCurrentProcess()
OpenProcessToken hProc, TOKEN_ADJUST_PRIVILEGES + TOKEN_QUERY, hToken
LookupPrivilegeValue "", "SeShutdownPrivilege", mLUID
mPriv.PrivilegeCount = 1
mPriv.Privileges(0).Attributes = SE_PRIVILEGE_ENABLED
mPriv.Privileges(0).pLuid = mLUID
AdjustTokenPrivileges hToken, False, mPriv, 4 + (12 *
mPriv.PrivilegeCount), mNewPriv, 4 + (12 * mNewPriv.PrivilegeCount)
End Sub

Public Sub ShutDownNT(Force As Boolean)
Dim Ret As Long
Dim flags As Long

flags = EWX_SHUTDOWN
If Force Then flags = flags + EWX_FORCE
EnableShutDown
ExitWindowsEx flags, 0
End Sub

Public Sub RebootNT(Force As Boolean)
Dim Ret As Long
Dim flags As Long

flags = EWX_REBOOT
If Force Then flags = flags + EWX_FORCE
EnableShutDown
ExitWindowsEx flags, 0
End Sub

Public Sub LogOffNT(Force As Boolean)
Dim Ret As Long
Dim flags As Long

flags = EWX_LOGOFF
If Force Then flags = flags + EWX_FORCE
ExitWindowsEx flags, 0
End Sub

Posted on Jan 05, 2009

1 Suggested Answer

6ya6ya
  • 2 Answers

SOURCE: I have freestanding Series 8 dishwasher. Lately during the filling cycle water hammer is occurring. How can this be resolved

Hi,
a 6ya expert can help you resolve that issue over the phone in a minute or two.
best thing about this new service is that you are never placed on hold and get to talk to real repairmen in the US.
the service is completely free and covers almost anything you can think of (from cars to computers, handyman, and even drones).
click here to download the app (for users in the US for now) and get all the help you need.
goodluck!

Posted on Jan 02, 2017

Add Your Answer

Uploading: 0%

my-video-file.mp4

Complete. Click "Add" to insert your video. Add

×

Loading...
Loading...

Related Questions:

1 Answer

How to do vb.net framework ??


You need Visual Studio from Microsoft. Inside this visual Rapid Application Development (RAD) tools, you can use c++, c#, or basic language. It is lot of learning to become programmer.
You can find SharpDevelop free programing studio if you want to learn more. With this program, you will need .NET packages on your computer. It is like JAVA from Sun (Oracle). It is copy from Microsoft of JAVA ideas. Like free NetBeans IDE for JAVA development.
Inside studio you will have option for create New project. It can be grafical with graphical designer for draw some button, text input frame ... You will have properties for this objects, and possibility to write programming code. It is lot of learning to do real application. When you write some application you can compile it to exe output.
Visual Basic is only simplest part of this technology. C# (C-sharp) need more learning, and C++ is hardest thing.
Good luck!

Aug 26, 2011 | Computers & Internet

1 Answer

How to run vb


How to Run a Visual Basic Program on a PC By an eHow Contributor

Like C++, C Sharp and Java, Visual Basic (VB) is an object oriented programming language. Recently it was integrated to the Microsoft .NET Framework. The .NET Framework is a software infrastructure that speeds up program development. It is supported by the Microsoft Visual Studio Integrated Development Environment (IDE), Microsoft's chief programming environment, and that of SharpDevelop.
Difficulty: Easy Instructions Things You'll Need:

  • Visual Microsoft Studio and .NET Framework
  1. Launch your Microsoft Visual Studio. It is a "heavy" application so depending on how much RAM you have it may take a few minutes to load.
  2. Click the Project tab on the first screen. Notice two buttons at the bottom of the screen named "New Project" and "Open Project." Since the tutorial assumes that this is your first VB program, click the "New Project" button. If you worked on a project before, its name will appear in an area labeled "Open an Existing Project" with a hyperlink that opens the project.
  3. Select "Windows Application" in the "Visual Basic Projects" folder if you intend to run your end program on a computer running a Microsoft Windows operating system. Focus in the "Name" text box near the bottom. Change the name from the default to something more descriptive such as "MyFirstVBProgram." Leave the Location to the default value to save your project to the "My Documents" folder. Press OK.
  4. Concentrate on the grey square area with the arrays of dots. This is the "form." The pinboard shows where components like buttons and text boxes will be installed to make a complete graphic user interface (GUI). The purpose of the grid is to align the components.
  5. Run your program. Click "Debug" from the menu bar. Click "Start" from the drop down menu. Alternatively, you can press F5 on your keyboard.
  6. Enjoy your first Visual Basic program in its simplest form. It is identical to the form in Step 4 except that the dots are gone. What you are looking at is a stand alone program that exists as an ".exe" file having the same name as your project. You can find it under the MyFirstVBProgram folder by default.
  7. Understand the difference between the two distinct environments of the IDE, the Design Environment and the Debug Environment. You saw the Design Environment in Step 4 of this tutorial. That was the environment where you could design a GUI on the form using your mouse. The Debug Environment takes over during the compilation interval in Step 5. That is where you can insert break points in your source code so that you test the correctness of the program.


Read more: How to Run a Visual Basic Program on a PC ' eHow.com http://www.ehow.com/how_2072757_run-visual-basic-program-pc.html#ixzz17b5EMirN

Dec 09, 2010 | Computers & Internet

1 Answer

Visual basic 6.0


okay its easy do this click start then go to all programs check all programs untill u come to microsoft visual studio 6.0 follow the right arrow and screw down to microsoft visual basic 6.0 thats it u are done.click ok ok and u are home

Nov 11, 2009 | Computers & Internet

2 Answers

Can not find script file cleanvirus vbs


Can not Find. Script File
C:\WINDOWS\System32\CleanViirus.vbs

Oct 22, 2009 | Microsoft Windows XP Professional With...

1 Answer

I need help in Visual Basic as i am new to the visual basic 6


Dear, the following page contains the tutorial for beginner to visual basic 6, I hope that would be very helpful to you.

http://www.hitmill.com/programming/vb/beginner.html

Best regards.

May 26, 2009 | Microsoft Windows XP Professional

2 Answers

How to coonectivity excel sheet with visual basic with coding


Here is ur solution :
http://support.microsoft.com/kb/257819

Thanks,
Mukund
www.Einfochips.com

May 20, 2009 | Microsoft Windows XP Professional With...

1 Answer

How can i get the code of visual basic 6.0?


here the Hundreds of Visual Basic source code snippets and files. Copy and paste code from your browser directly into Visual Basic.
http://www.vbcode.com/
http://www.freevbcode.com/
http://www.vbcodesource.com/
http://www.a1vbcode.com/

Jan 15, 2009 | Microsoft Windows XP Professional

1 Answer

I need source code on how to play ogg, 3gp in visual basic


Hai...
It is a hint note it...
I am not sure about this,
1)Start ur Media player file as wmplayer.exe
OR
2)Set the file path..


process.start("wmplayer.exe")

Regards
Mani
mani@merittech.co.in

Dec 11, 2008 | Microsoft Windows Server Standard 2003 for...

1 Answer

Java code


To call another program from Visual Basic, you can use something like this. So, to call a Java program, the program name would be "java <name of Java program>".

Oct 06, 2008 | Computers & Internet

1 Answer

Java


If you don't already know how to program then i wouldn't start with Java but maybe with Visual Basic. Once you have a good grasp of Basic then you can move onto Java.

If you already know how to program in another language, especially C++ then you will find java to be quite familiar.

In any case your first step would be to go to yoru local book store and buy a book or two. Read through the book while at your computer and try all the examples.

For Visual Basic there are books like this: http://www.amazon.com/Microsoft-Visual-Basic-2008-Step/dp/0735625379/ref=pd_bbs_sr_1?ie=UTF8&s=books&qid=1215519837&sr=8-1 or http://www.amazon.com/Beginning-Microsoft-Visual-Basic-Guides/dp/0470191341/ref=pd_bbs_sr_6?ie=UTF8&s=books&qid=1215519932&sr=8-6 or http://www.amazon.com/Teach-Yourself-Visual-Basic-Hours/dp/0672329840/ref=pd_bbs_sr_9?ie=UTF8&s=books&qid=1215519932&sr=8-9

For Java you may want to check out: http://www.amazon.com/Head-First-Java-Kathy-Sierra/dp/0596009208/ref=pd_bbs_sr_1?ie=UTF8&s=books&qid=1215519994&sr=8-1 or http://www.amazon.com/Beginning-Programming-Java-Dummies-Computer/dp/0764588745/ref=pd_bbs_7?ie=UTF8&s=books&qid=1215519994&sr=8-7 or http://www.amazon.com/Sams-Teach-Yourself-Java-Days/dp/0672329433/ref=pd_bbs_9?ie=UTF8&s=books&qid=1215519994&sr=8-9

Jul 08, 2008 | Microsoft Windows XP Professional

Not finding what you are looking for?
Microsoft Windows XP Professional With Servise Pack 2 (e8503040) for PC Logo

279 people viewed this question

Ask a Question

Usually answered in minutes!

Top Microsoft Computers & Internet Experts

micky dee

Level 3 Expert

2638 Answers

Les Dickinson
Les Dickinson

Level 3 Expert

18333 Answers

Brian Sullivan
Brian Sullivan

Level 3 Expert

27725 Answers

Are you a Microsoft Computer and Internet Expert? Answer questions, earn points and help others

Answer questions

Manuals & User Guides

Loading...