473,396 Members | 1,834 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,396 software developers and data experts.

Shut Down Computer in VB6

24
Hi all, I try to shut down computer for security module developemnt. I used the following code, But its doesnt work also no error message come, Could you please clarify whicj way I can proceed? Thx a lot.

Const EWX_LogOff As Long = 0
Const EWX_SHUTDOWN = 1
Const EWX_REBOOT = 2
Const EWX_FORCE = 4
Private Declare Function ExitWindows _
Lib "User32" Alias "ExitWindowsEx" _
(ByVal dwOptions As Long, ByVal dwReserved As Long) As Long


Private Sub CommandButton3_Click()


'Shut down windows
ExitWindows EWX_SHUTDOWN, &HFFFFFFFF


End Sub
Apr 24 '08 #1
2 4889
if you are using xp, then this is a little bit easyer to use:

Shell "shutdown -X", vbHide

replace the -X with the one you want:

-s
shutdow
-r
restart
-l
logoff
Apr 24 '08 #2
jg007
283 100+
Hi all, I try to shut down computer for security module developemnt. I used the following code, But its doesnt work also no error message come, Could you please clarify whicj way I can proceed? Thx a lot.

Const EWX_LogOff As Long = 0
Const EWX_SHUTDOWN = 1
Const EWX_REBOOT = 2
Const EWX_FORCE = 4
Private Declare Function ExitWindows _
Lib "User32" Alias "ExitWindowsEx" _
(ByVal dwOptions As Long, ByVal dwReserved As Long) As Long


Private Sub CommandButton3_Click()


'Shut down windows
ExitWindows EWX_SHUTDOWN, &HFFFFFFFF


End Sub
all the code that I have seen to import the shutdown functions has also included changing the process token to give the required access for this so that may be why your code is not working.
Apr 25 '08 #3

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

Similar topics

303
by: mike420 | last post by:
In the context of LATEX, some Pythonista asked what the big successes of Lisp were. I think there were at least three *big* successes. a. orbitz.com web site uses Lisp for algorithms, etc. b....
1
by: Daniel | last post by:
System.IO.StreamWriter Close or Flush method to shut down the computer in such a way that just part of the file is written? or an empty file is written? Also if the Close or Flush is to a...
2
by: Jesper DK | last post by:
Hi, I would like a program invoked when the computer is shut down or a user logs off. Is there a fix way of doing this. I uses the startup folder to run the program, but I need to run it when...
4
by: Diogo Alves - Software Developer | last post by:
Hi, I have a application developed by me in C# that does not let windows shut down! What is the problem? is this a Framework bug? I would like to receive some feedback about this issue
5
by: Anders Both | last post by:
If no pages in my asp.net web-system, is being requested for some periode, it seems like the asp.net process is shut down automaticaly. Is this a normal behavior, or does my system contains some...
5
by: Won | last post by:
I want to know how to shut down computer using VB .NET. Thank you
0
by: Stephen | last post by:
Hi, I am trying to copy files from one computer to another, the problem I am facing is that the program chokes when the other computer is not available (shut down/off the n/w). is there any way...
1
by: =?Utf-8?B?bWl0cmVib3g=?= | last post by:
Ever since I loaded Office 2007 and Avast Anti-Virus, I cannot get Windows XP Professional to shut down and turn the computer off. I have to push and hold the On/Off for several seconds to turn...
6
sashi
by: sashi | last post by:
Shut down Windows For various reasons you may require a shut down of Windows to happen programmatically. For instance if the installation of your program requires system reconfiguration. The...
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: 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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
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...
0
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,...

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.