reboot windows

L

Lee Kok Onn

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
 
A

Armin Zingler

Lee Kok Onn said:
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
 
H

Herfried K. Wagner [MVP]

Lee Kok Onn said:
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>
 
L

Lee Kok Onn

I have try code and when I run it, it does not have any error, but it just
dont shutdown. Any ideas.
 
A

Armin Zingler

Lee Kok Onn said:
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.GetLastWin32Error immediatelly after
ExitWindows has returned. Or look it up on your own @
http://msdn2.microsoft.com/en-us/library/ms681381.aspx


Armin
 
A

aaron.kempf

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
 
A

aaron.kempf

seriously

managed signature this, managed signature that

it's a load of crap

WMI works _FINE_ for this **** dotnet
 
M

Martin H.

seriously

managed signature this, managed signature that

it's a load of crap

WMI works _FINE_ for this **** dotnet

Have you considered psychological help?

Martin
 
A

aaron.kempf

have you considered writing in a language with a future?

Microsoft killed Vb; did you not get the memo?

-Aaron
 
M

Martin H.

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
 
B

Bruce W. Darby

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
 
M

Martin H.

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
 
A

aaron.kempf

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 ****ing 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
 
A

aaron.kempf

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
 
A

aaron.kempf

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
 
A

aaron.kempf

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
 
M

Martin H.

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 ****ing 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
 
B

Bruce W. Darby

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top