469,934 Members | 2,132 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,934 developers. It's quick & easy.

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 1722
"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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Guillaume Senneville | last post: by
reply views Thread by Manoj Nair | last post: by
1 post views Thread by Howard Pinsley | last post: by
reply views Thread by Condor | last post: by
5 posts views Thread by STom | last post: by
4 posts views Thread by Urs Vogel | last post: by
3 posts views Thread by sam | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.