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

How to reboot local machine in c# using InitiateSystemShutdown(...) ---a function in "advapi32.dll"

the following codes won't work.
==============================
using System;
using System.Runtime;
using System.Runtime.InteropServices;

namespace Shutdown
{
/// <summary>
/// Class1 µÄժҪ˵Ã÷¡£
/// </summary>
class Class1
{
/// <summary>
/// Ó¦ÓóÌÐòµÄÖ÷Èë¿Úµã¡£
/// </summary>
[DllImport("advapi32.dll")]
public static extern bool InitiateSystemShutdown(string Machinename,string
Message,long Timeout,int ForceAppsClosed,int RebootAfterShutdown);

[STAThread]
static void Main(string[] args)
{
//
// TODO: ÔÚ´Ë´¦Ìí¼Ó´úÂëÒÔÆô¶¯Ó¦ÓóÌÐò
//
InitiateSystemShutdown("","",30,1,1);
}
}
}
Nov 15 '05 #1
3 8399
> InitiateSystemShutdown("","",30,1,1);

Try changing the empty strings to 'null'.
Also, for more shutdown options than InitiateSystemShutdown offers, check
out http://www.mentalis.org/soft/class.qpx?id=7

Regards,
Pieter Philippaerts
Managed SSL/TLS: http://www.mentalis.org/go.php?sl
Nov 15 '05 #2
thanks a lot to you ,the Mentalist.
Nov 15 '05 #3
Thanks a lot.
Nov 15 '05 #4

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

Similar topics

4
by: dongdong | last post by:
I wrote as following: content=urllib2.urlopen("http://www.sdfagfa.org/asasg/a.zip").read() f=open("d:\\a.zip",'a+',1) f.writelines(content) the zip file has been download to my machine,but when...
2
by: jayadevi | last post by:
Hi all, I have to get IP of the local machine. For ex:Using machine A , i have connected to another server(machine) B, in machine B i am browsing one asp page which gets the IP address using the...
4
by: Abhi | last post by:
Hi All, I have a web service method which works fine when called from my local machine i.e. from localhost but when I publish the web services to a remote machine it throws an invalid cast soap...
0
by: subiparihar | last post by:
Hi guys, I m currently facing a problem , in copying a doc file to the web server from the local machine using c#. Pls suggest some Support. Thank You Subi
1
by: yellowblueyellow | last post by:
Hi, I want to list all groups on a local machine using C#. How do I go about this? Thanks
5
rajiv07
by: rajiv07 | last post by:
Hi experts, i want save a file in a local machine using saveas dialogue box.Is any idea.
3
by: ramesh.nrk | last post by:
Hi, Is there any way to read the cookies which are in local machine? Can we create cookies using windows Application in the local machine? I am developing a windows application which needs...
3
by: subhashinivasan | last post by:
How to get version of the oracle installed in Local Machine using VB.NET. Please do reply at the earliest Thanks, Subha
4
by: supersav144 | last post by:
Hi there, i have a simple application which connects to a web service and then this web service creates a file on the machine which the application was accessed on... the problem i have though...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...

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.