重启Windows [英] reboot windows

查看:99
本文介绍了重启Windows的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我在vb2005中编写了以下代码来重新启动Windows,但结束了

,错误ExitWindows(EWX_REBOOT,& HFFFFFFFF),调用PInvoke函数

''shutdown!shutdown.Form1 :: ExitWindows''使堆栈失衡。这可能是因为托管的PInvoke签名与非托管的

目标签名不匹配


任何想法,都可以帮忙。


Public Class Form1


Const EWX_LogOff As Long = 0


Const EWX_SHUTDOWN = 1


Const EWX_REBOOT = 2


Const EWX_FORCE = 4


私有声明函数ExitWindows _


Lib" User32"别名ExitWindowsEx _ $ />

(ByVal dwOptions As Long,ByVal dwReserved As Long)长期


Private Sub Form1_Load(ByVal sender As System.Object,ByVal e As

System.EventArgs)处理MyBase.Load

End Sub


Private Sub Button1_Click_1(ByVal sender As System.Object ,ByVal e As

System.EventArgs)处理Button1.Click


ExitWindows(EWX_REBOOT,& HFFFFFFFF)


End Sub


结束班

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

推荐答案

" Lee Kok Onn" < ko *** @ viperlink.com.sgschrieb
"Lee Kok Onn" <ko***@viperlink.com.sgschrieb




我在vb2005中编写了以下代码重新启动windows,

但以错误ExitWindows(EWX_REBOOT,& HFFFFFFFF)结束,调用

PInvoke函数''shutdown!shutdown.Form1: :ExitWindows''具有

不平衡堆栈。这可能是因为托管的PInvoke

签名与非托管目标签名不匹配


任何想法,都可以帮助。

Public Class Form1


Const EWX_LogOff As Long = 0


Const EWX_SHUTDOWN = 1


Const EWX_REBOOT = 2


Const EWX_FORCE = 4


私有声明功能ExitWindows _


Lib" User32"别名ExitWindowsEx _


(ByVal dwOptions As Long,ByVal dwReserved As Long)As Long
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



这些是VB6的声明,不是VB.Net。 32Bit现在是Integer或Int32

,或IntPtr,或布尔,取决于定义。


未经测试:


ReadOnly EWX_LogOff As New IntPtr(0)

ReadOnly EWX_SHUTDOWN As New IntPtr(1)

''...


私有声明函数ExitWindows _

Lib" User32"别名ExitWindowsEx _

(ByVal dwOptions作为IntPtr,ByVal dwReserved为整数)_

作为布尔值


我使用Intptr作为第一个参数因为它在PSDK中声明为UINT,

和UINT等于unsigned int谁的大小被宣布为系统

依赖,这意味着IntPtr。

Armin

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

http://www.gotdotnet.com/Community/U...C-4A9A89D47FAD


-

新手编码器
(这只是一个名字)
http://www.gotdotnet.com/Community/U...C-4A9A89D47FAD

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


" Lee Kok Onn" < ko *** @ viperlink.com.sgschrieb:
"Lee Kok Onn" <ko***@viperlink.com.sgschrieb:

我在vb2005中编写了以下代码来重启windows,但结束了

,错误ExitWindows(EWX_REBOOT,& HFFFFFFFF),调用PInvoke

函数''shutdown!shutdown.Form1 :: ExitWindows''使堆栈失衡。

这可能是因为托管的PInvoke签名与

非托管目标签名不匹配
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"



你的函数声明是错误的。请查看以下示例,了解有效的

声明:


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


-

MS Herfried K. Wagner

MVP< URL:http://dotnet.mvps .org />

VB< URL:http://dotnet.mvps.org/dotnet/faqs/>

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/>


这篇关于重启Windows的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆