|
-
Apr 17th, 2003, 10:40 PM
#1
Thread Starter
New Member
VB.NET: How to restart computer after installation process
Hi, I have a question with VB.NET.
I've developed an application using VB.NET and now I'm trying to make a setup file for its distribution process. I am using the built-in program (MSI) to do the task.
How do I make this setup project restart computer when the main application is installed?
Thanks in advance!
Eric.
What is finite, but boundaryless?
-
Apr 17th, 2003, 10:48 PM
#2
I wonder how many charact
Since a class for restarting the computer has not been included in the .Net framework yet... you simply need to call Win32 API's from your .Net applicaton....
do a Google search for Restart Computer in VB6 to get the right API's.... I believe its ExitWindowsEx..... (bear in mind, for XP and 2000, you also need to pass a security parameter, but most of the code I've seen around handles that)...
Then, you need to call the API from your .Net application..just like you would with VB6, just remember Longs in Vb6 are now Integers in VB.Net... so you need to replace any Long returned by a Win32API with Integer...
VB Code:
[u]vb6:[/u]
Private Declare Auto Function MBox Lib "user32.dll" _
Alias "MessageBox" (ByVal hWnd As [b]Long[/b], _
ByVal txt As String, ByVal caption As String, _
ByVal Typ As [b]Long[/b]) As [b]Long[/b]
[u]vb.Net:[/u]
Private Declare Auto Function MBox Lib "user32.dll" _
Alias "MessageBox" (ByVal hWnd As [b]Integer[/b], _
ByVal txt As String, ByVal caption As String, _
ByVal Typ As [b]Integer[/b]) As [b]Integer[/b]
There are also other ways to call Win32API's but the above is the simplest.... for other ways you may refer to this MSDN walkthrough:
http://msdn.microsoft.com/library/de...indowsAPIs.asp
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|