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

reboot windows

Hi,

I have written the following code in vb2005 to reboot the windows, but end
with error "ExitWindows(EWX_REBOOT, &HFFFFFFFF)", call to PInvoke function
'shutdown!shutdown.Form1::ExitWindows' has unbalanced the stack. This is
likely because the managed PInvoke signature does not match the unmanaged
target signature"

Any ideas, can pls help.

Public Class Form1

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 Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
End Sub

Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

ExitWindows(EWX_REBOOT, &HFFFFFFFF)

End Sub

End Class
Feb 8 '07 #1
18 1853
"Lee Kok Onn" <ko***@viperlink.com.sgschrieb
Hi,

I have written the following code in vb2005 to reboot the windows,
but end with error "ExitWindows(EWX_REBOOT, &HFFFFFFFF)", call to
PInvoke function 'shutdown!shutdown.Form1::ExitWindows' has
unbalanced the stack. This is likely because the managed PInvoke
signature does not match the unmanaged target signature"

Any ideas, can pls help.

Public Class Form1

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
These are declarations for VB6, not for VB.Net. 32Bit is Integer or Int32
now, or IntPtr, or Boolean, depending on the definition.

Untested:

ReadOnly EWX_LogOff As New IntPtr(0)
ReadOnly EWX_SHUTDOWN As New IntPtr(1)
'...

Private Declare Function ExitWindows _
Lib "User32" Alias "ExitWindowsEx" _
(ByVal dwOptions As IntPtr, ByVal dwReserved As Integer) _
As Boolean

I used Intptr for the first param because it's declared as UINT in the PSDK,
and UINT is equal to "unsigned int" who's size is declared as "System
dependent", which means IntPtr.
Armin

Feb 8 '07 #2
http://www.gotdotnet.com/Community/U...C-4A9A89D47FAD

--
Newbie Coder
(It's just a name)
Feb 8 '07 #3
"Lee Kok Onn" <ko***@viperlink.com.sgschrieb:
I have written the following code in vb2005 to reboot the windows, but end
with error "ExitWindows(EWX_REBOOT, &HFFFFFFFF)", call to PInvoke
function 'shutdown!shutdown.Form1::ExitWindows' has unbalanced the stack.
This is likely because the managed PInvoke signature does not match the
unmanaged target signature"
Your function declarations are wrong. Check out the sample below for valid
declarations:

<URL:http://www.mentalis.org/soft/class.qpx?id=7>

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Feb 9 '07 #4
I have try code and when I run it, it does not have any error, but it just
dont shutdown. Any ideas.
"Armin Zingler" <az*******@freenet.dewrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
"Lee Kok Onn" <ko***@viperlink.com.sgschrieb
>Hi,

I have written the following code in vb2005 to reboot the windows,
but end with error "ExitWindows(EWX_REBOOT, &HFFFFFFFF)", call to
PInvoke function 'shutdown!shutdown.Form1::ExitWindows' has
unbalanced the stack. This is likely because the managed PInvoke
signature does not match the unmanaged target signature"

Any ideas, can pls help.

Public Class Form1

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

These are declarations for VB6, not for VB.Net. 32Bit is Integer or Int32
now, or IntPtr, or Boolean, depending on the definition.

Untested:

ReadOnly EWX_LogOff As New IntPtr(0)
ReadOnly EWX_SHUTDOWN As New IntPtr(1)
'...

Private Declare Function ExitWindows _
Lib "User32" Alias "ExitWindowsEx" _
(ByVal dwOptions As IntPtr, ByVal dwReserved As Integer) _
As Boolean

I used Intptr for the first param because it's declared as UINT in the
PSDK,
and UINT is equal to "unsigned int" who's size is declared as "System
dependent", which means IntPtr.
Armin

Feb 9 '07 #5
"Lee Kok Onn" <ko***@viperlink.com.sgschrieb
I have try code and when I run it, it does not have any error, but
it just dont shutdown. Any ideas.

What is the return value of ExitWindows? If it fails, additionally retrieve
(and post here) the value of
System.Runtime.InteropServices.Marshal.GetLastWin3 2Error immediatelly after
ExitWindows has returned. Or look it up on your own @
http://msdn2.microsoft.com/en-us/library/ms681381.aspx
Armin

Feb 9 '07 #6
go to freevbcode.com

and use VB6; VB 2005 is BLOATWARE.
it is SLOWER than vb6

they thought that they could convince us that they needed something
'faster'
but all they did is rob us of our code portability

VB 2002,2003,2005 DOES NOT RUN IN 1/4 OF THE PLACES THAT VB6 CODE
WORKED

-Aaron

Feb 10 '07 #7
seriously

managed signature this, managed signature that

it's a load of crap

WMI works _FINE_ for this fuck dotnet

Feb 10 '07 #8
aa*********@gmail.com wrote:
seriously

managed signature this, managed signature that

it's a load of crap

WMI works _FINE_ for this fuck dotnet
Have you considered psychological help?

Martin
Feb 10 '07 #9
have you considered writing in a language with a future?

Microsoft killed Vb; did you not get the memo?

-Aaron

Feb 10 '07 #10
Hello Aaron,
have you considered writing in a language with a future?
yes, I have. I use VB.NET.
Microsoft killed Vb; did you not get the memo?
I understand that you like Classic VB a lot. I surely has its advantages
(e.g. it's easier to start with it). On the other hand VB.NET gives you
a harder start - but also a lot of advantages (e.g. inheritance which
allows you to create your own controls based on the already existing
..NET controls or full Unicode support).

If you want to stick to Classic VB - that's OK. However, then I would
suggest that you use your time in a more productive way and write
productive comments in the VB.Classic newsgroups rather than complaining
in the VB.NET newsgroups. I would expect that most people here arranged
themselves with the changes in VB.NET.

Take me as an example: In the beginning I was also not too happy as I
had to learn a lot about VB.NET. But now, as I got used to VB.NET I
actually find it quite comfortable.

Best regards,

Martin
Feb 10 '07 #11
Welcome to the newsgroup, Martin. :) And like most of the others here,
sooner or later you'll add Aaron, susiebda, dbahooker, punjab_tom, et. al.,
ad nauseum, to your message killfile as he/she(?) hasn't gotten a clue that
actually asking for help and giving help is the purpose of this newsgroup.

Bruce

"Martin H." <hk***@gmx.netwrote in message
news:45***********************@news.freenet.de...
Hello Aaron,
>have you considered writing in a language with a future?

yes, I have. I use VB.NET.
>Microsoft killed Vb; did you not get the memo?

I understand that you like Classic VB a lot. I surely has its advantages
(e.g. it's easier to start with it). On the other hand VB.NET gives you a
harder start - but also a lot of advantages (e.g. inheritance which allows
you to create your own controls based on the already existing .NET
controls or full Unicode support).

If you want to stick to Classic VB - that's OK. However, then I would
suggest that you use your time in a more productive way and write
productive comments in the VB.Classic newsgroups rather than complaining
in the VB.NET newsgroups. I would expect that most people here arranged
themselves with the changes in VB.NET.

Take me as an example: In the beginning I was also not too happy as I had
to learn a lot about VB.NET. But now, as I got used to VB.NET I actually
find it quite comfortable.

Best regards,

Martin

Feb 10 '07 #12
Hello Bruce,
Welcome to the newsgroup, Martin. :)
Thanks! But actually, I've been here before...
And like most of the others here,
sooner or later you'll add Aaron, susiebda, dbahooker, punjab_tom, et. al.,
ad nauseum, to your message killfile as he/she(?) hasn't gotten a clue that
actually asking for help and giving help is the purpose of this newsgroup.
I use Thunderbird and don't have killfiles... ;-)

Anyway, since on my previous comment to Aaron's posting I did not
receive any bad language reply, I thought that perhaps now there's a
chance to discuss that seriously.

I understand that someone might feel stabbed into the back as you first
learn (classic) VB and then suddenly most of what you learned is no
longer of any use. I think that's also what my previous posting
expresses. I also was not too happy about that. But I figured that if I
want to write Unicode applications I either have to do tricky things
with my VB5 or I go VB.NET. So, I bought VS.NET 2003 Enterprise Edition
and started learning VB.NET...

Best regards,

Martin
Feb 10 '07 #13
advantages?

the IDE is slow as shit
the IDE _CRASHES_
the EXE won't run on half of the operating systems in the world,
including Windows 2000, XP and Vista.

the FRAMEWORK isn't present on _ANY_ desktops.
it's technically IMPOSSIBLE to determine 'which version of the
framework is on machine X'

plz buddy if your stupid fucking framework is so glorious, please tell
me how to determine 'which version of the framework is on machine X'

if you give me a serious answer that works for ANY MACHINE then I will
STFU and stop bitching on this newsgroup

Feb 10 '07 #14
bruce

stfu and stop hiding behind FUD

if you had the balls to question authority you wouldn't be a wussy ass
Microsoft yesman

-Aaron
Feb 10 '07 #15
my language STILL WORKS

it's your so called 'Visual Fred' that doesn't work in 3/4s of the
environments where VB6 / VBA / VBS works.

if you claim 'oh but they're different languages' you are WRONG

they're not different languages; they're all the same thing.

VB 2005, VB 2002, VB 2003 doesn't support code reuse.
it does not product portable code.

Can I cut and paste my VB 2005 into an 'ActiveX script' and run it via
SQL 2005?

SERIOUSLY HERE KIDS

I had one language that worked just fine

now they killed clientside vbScript in ASP.net
now they killed VBS batch files
now they killed EXCEL MACROS
now they killed SQL 2005
now they killed SQL 2000

I AM OUTRAGED THAT YOU KIDS PUT UP WITH A TYRANNICAL CORPORATION.

MOVE TO PHP AND DREAMWEAVER; AND TELL MICROSOFT WHAT YOU THINK OF
VISUAL FRED


Feb 10 '07 #16
I could care less about unicode apps; for starters.

gooks and chinks at microsoft should 'speak english or die'

I had ONE LANGUAGE and now, to get the same functionality I need
_FOUR_ languages

VB6 (VBA, VBS, etc)
VB 2005
Javascript (clientside DHTML)
C# (half of the examples coming from www.microsoft.com are only
available with C# _CRAP_)

DOES IT MAKE SENSE TO WORK WITH BASIC FOR TWENTY YEARS AND THEN ONE
DAY YOU NEED TO LEARN THREE NEW LANGUAGES????
DOES IT MAKE SENSE TO WORK WITH BASIC FOR TWENTY YEARS AND THEN ONE
DAY YOU NEED TO LEARN THREE NEW LANGUAGES????
DOES IT MAKE SENSE TO WORK WITH BASIC FOR TWENTY YEARS AND THEN ONE
DAY YOU NEED TO LEARN THREE NEW LANGUAGES????
DOES IT MAKE SENSE TO WORK WITH BASIC FOR TWENTY YEARS AND THEN ONE
DAY YOU NEED TO LEARN THREE NEW LANGUAGES????
it's time for them to STOP INVENTING THE NEXT GREAT THING AND START
FIXING BUGS EVERY SINGLE BUG WE FIND.

Ralph Nader is the only person that can save Microsoft at this point.

-Aaron

Feb 10 '07 #17
Hallo Aaron,
advantages?

the IDE is slow as shit
the IDE _CRASHES_
I heard about the problems of VB 2005. However, I use VB 2003 and I have
not encountered any of those problems.
the EXE won't run on half of the operating systems in the world,
including Windows 2000, XP and Vista.
Why shouldn't it? Ensure that the framework is installed and it will
run. Same as with classic VB. Without the runtime dlls it won't run.

And - VB.NET has an additional advantage - it can run on Linux (-mono
project).
the FRAMEWORK isn't present on _ANY_ desktops.
it's technically IMPOSSIBLE to determine 'which version of the
framework is on machine X'
plz buddy if your stupid fucking framework is so glorious, please tell
me how to determine 'which version of the framework is on machine X'
Check C:\WINDOWS\Microsoft.NET\Framework.
You will find one subdirectory for each framework version installed.
I have:
v1.0.3705 (Framework 1.0)
v1.1.4322 (Framework 1.1)
v2.0.50727 (Framework 2.0)
v3.0 (Framework 3.0)
if you give me a serious answer that works for ANY MACHINE then I will
STFU and stop bitching on this newsgroup
To work on any machine, you would of course check where the Windows
directory is as the user might have installed Windows on drive D: or so...

Best regards,

Martin
Feb 10 '07 #18
>if you give me a serious answer that works for ANY MACHINE then I will
STFU and stop bitching on this newsgroup
Aaron,

Apparently, you WON'T. I gave you that answer THREE days ago, but you're
still here harassing good folks trying to get their jobs done. Or don't you
know how to use Windows Explorer?

Bruce
Feb 10 '07 #19

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

Similar topics

6
by: Stephane Dalpe | last post by:
Hi all, I just want to know why when I'm installing jdk sometimes ask me to reboot and sometimes he don't. As part of our installation, we launch the jdk installation if it's not already...
3
by: Guillaume Senneville | last post by:
hi, we are having this weird problem that can be reproduced easily on 2 out of 2 servers where we've tried: - we run a SQL Server 2000 stored procedure that processes 2.5 million rows (big...
0
by: ThunderMusic | last post by:
Hi, I'm trying to install VS.NET 2003 and it keeps asking me to reboot the computer for installing the first step. After rebooting, I try to install the first step, then it tells me again an...
2
by: innesm | last post by:
Hi, Although I havent been able to find any documentation to confirm it, it looks like any change to a windows local group's membership is only reflected in the group editing UI (and the...
0
by: Manoj Nair | last post by:
Hi, I am writing a console application using WMI with C# . Development is for Windows XP machine. One of the methods requires to reboot the local terminal. In my application I make a call to...
1
by: Howard Pinsley | last post by:
Every time I reboot my machine, I can no longer run ASP.NET applications. I have to run aspnet_regiis.exe /i after every reboot. The error: Server Application Unavailable The web application...
0
by: Condor | last post by:
Hi There. There is a lot of post about reboot windows. I need to reboot my server with a ASPX application and the code must run on server side. Y do all that people says: (open a process token,...
5
by: STom | last post by:
I have an app that I need to make sure after installation that the machine has been rebooted. Is there a way to detect if a reboot has been performed? Maybe like initially writing to a config file...
4
by: Urs Vogel | last post by:
Hi I deploy a Windows Service which requires a reboot after setup. The setup project, however, does not automatically recognize this requirement.How do I force a reboot (or set a reboot...
3
by: sam | last post by:
I found reboot script at TechNet and I wonder how to apply in VB.Net? Reboot Coding ************ strComputer = "." Set objWMIService = GetObject("winmgmts:" _ &...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.