473,473 Members | 1,759 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Problem on shutdown computer if my appication is opened

I wrote two application for my company,
but I found that, if anyone of application is opened, the user cannot
shutdown the computer.

the behaviour is that:
if one of application is opened, and then click the shutdown, my
application will be terminate but the computer didn't shotdown.
afterward, if I click the shutdown again, since my application is
already terminated, so the computer can shutdown this time.

What the problem is??

May 4 '07 #1
6 1016
"Cylix" <cy*******@gmail.comwrote in message
news:11**********************@q75g2000hsh.googlegr oups.com...
>I wrote two application for my company,
but I found that, if anyone of application is opened, the user cannot
shutdown the computer.

the behaviour is that:
if one of application is opened, and then click the shutdown, my
application will be terminate but the computer didn't shotdown.
afterward, if I click the shutdown again, since my application is
already terminated, so the computer can shutdown this time.

What the problem is??
I had this happen when; in my application I was aborting the form close
event if there was unsaved data. Apparently setting the cancel property to
true was getting in the way of Windows being allowed to close.

I had to look at the way windows was being asked to close and act
accordingly, then allow the form to close and in turn allow Windows to
close.
May 4 '07 #2
Thanks Ray,

I have tried to comment the form closing event already, but the
problem still here.
Do you find any solution for this?

May 4 '07 #3
Do you have any forms that are hidden at the time? They might be causing
issues.

"Cylix" <cy*******@gmail.comwrote in message
news:11*********************@p77g2000hsh.googlegro ups.com...
Thanks Ray,

I have tried to comment the form closing event already, but the
problem still here.
Do you find any solution for this?

May 5 '07 #4
Cylix,

Use this code & it will do what you need:

' Exit Windows message
Private Shared WM_QUERYENDSESSION As Integer = &H11
#Region "Window Proc (SUB)"
<System.Security.Permissions.PermissionSetAttribut e(System.Security.Permissi
ons.SecurityAction.Demand, Name:="FullTrust")_
Protected Overrides Sub WndProc(ByRef m As
System.Windows.Forms.Message)
' Listen for operating system messages
If m.Msg = WM_QUERYENDSESSION Then
Application.Exit()
End If
' Handle the message
MyBase.WndProc(m)
End Sub
#End Region

I hope this helps,

--
Newbie Coder
(It's just a name)

"Ray Cassick" <rc******@enterprocity.comwrote in message
news:eo**************@TK2MSFTNGP03.phx.gbl...
Do you have any forms that are hidden at the time? They might be causing
issues.

"Cylix" <cy*******@gmail.comwrote in message
news:11*********************@p77g2000hsh.googlegro ups.com...
Thanks Ray,

I have tried to comment the form closing event already, but the
problem still here.
Do you find any solution for this?


May 6 '07 #5
I know the problem and solved it.
Thanks a lot.

May 8 '07 #6

"Cylix" <cy*******@gmail.comwrote in message
news:11**********************@l77g2000hsb.googlegr oups.com...
>I know the problem and solved it.
Thanks a lot.
share share share.

:)
May 10 '07 #7

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

Similar topics

3
by: Roy Benjamin | last post by:
I'm developing a WEB service for Sun ONE deployment (AppServer7). I'm developing on Windows XP Pro though will deploy on Solaris, Sun AppServer7 includes a XercesImpl.jar in share/lib. 2 kb...
3
by: Senthil | last post by:
Hi, I would like to know the code for reboot and shutdown windows xp professional using VB.Net. thanx Senthil
13
by: Bob Greschke | last post by:
We have some equipment that communicates at 57600 baud RS232. The path from the PC is USB to a Phillips USB hub, then off of that a TUSB3410 USB/Serial converter. The driver for the 3410 chip...
2
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,...
5
by: lgbjr | last post by:
Hi All, I'm having a problem with a VB.NET project that I'm building in VS.NET 2003 (7.1.3088). As my project has increased in size (the executable is now about 2.5MB), I am experiencing a lot...
3
by: newsgroups.jd | last post by:
Let me start by saying I am a noob to VB.net and am not a programmer anyways I am trying to learn and would like to get this to work... so please be gentle, If Im doing it wrong please tell me......
1
by: Titeuf | last post by:
Hi, I work under VS2003 and I want to know how get the shutdown reason code ? On msdn nothing found...No api :( Have you an idea ? Thank's
5
by: Phil Tusa | last post by:
Greetings to all .... I have a need to issue a shutdown and/or Restart Windows XP inside my application. Any help or example code would be appreciated! -- Phil
22
by: V S Rawat | last post by:
(bringing the discussion here for php.general) I am on xpsp3, wampserver 2.0, having apache 2.2.8, php 5.2.6, MySQL 5.0.51b. http://localhost/ is E:\wamp\www\ I have put the first php script...
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,...
1
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...
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,...
1
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...
0
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...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.