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

Recovery settings of a windows service

Hi All,
I written one windows service and its working fine. I Need to check
the recovery settings of that service from one windows application.
How do I can get the recovery settings of(first failure, second
failure and third failure) a service programatically. can any one
please help me in this regard.

Thanks in advance
Sivakumar V
Nov 19 '07 #1
1 4483
"svandanapu" <sk**************@gmail.comwrote in message
news:85**********************************@w28g2000 hsf.googlegroups.com...
Hi All,
I written one windows service and its working fine. I Need to check
the recovery settings of that service from one windows application.
How do I can get the recovery settings of(first failure, second
failure and third failure) a service programatically. can any one
please help me in this regard.

Thanks in advance
Sivakumar V

There is nothing in the framework that covers this, so you'll have to call
the native QueryServiceConfig2 service API for this.
To give you a head start, herewith a class with the Pinvoke declaration and
the structures required by this function.

class ServiceConfigEx
{
[DllImport("advapi32.dll", CharSet=CharSet.Unicode,
SetLastError=true)]
public static extern int QueryServiceConfig2(IntPtr serviceHandle,
int infoLevel,
IntPtr query_service_config_ptr, int bufferSize, out int
bytesNeeded);

[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Unicode)]
public struct SERVICE_FAILURE_ACTIONS
{
public uint dwResetPeriod;
public string rebootMsg;
public string command;
public uint numActions;
public IntPtr actions; //ptr to an array of AC_ACTION structures
}
[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Unicode)]
public struct SC_ACTION
{
public SC_ACTION_TYPE type;
public uint delay;
}
public enum SC_ACTION_TYPE
{
SC_ACTION_NONE,
SC_ACTION_RESTART,
SC_ACTION_REBOOT,
SC_ACTION_RUN_COMMAND
}

public const int SERVICE_CONFIG_FAILURE_ACTIONS = 2;
}

Note that this information is only available on Vista and higher, you also
need to administrator privileges to call this API.

Willy.

Nov 19 '07 #2

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

Similar topics

1
by: Mike Mazar | last post by:
I have a service which I create in vb.net. I'm trying to use the Recovery feature of Windows 2000/XP to restart the service if it fails to start. Looks like there are some steps that a service must...
10
by: xixi | last post by:
i have db2 udb v8.1 on windows 64 bit 2003 server, after db2 server start , i found this in the db2diag.log, is this error? 2004-05-05-15.28.30.780000 Instance:DB2 Node:000...
2
by: Strahimir Antoljak | last post by:
I am creating a new windows service and I would like to control its Recovery property. On a system administrator level the Recovery property is found in Control Panel -> Administrative Tools ->...
5
by: Dhilip Kumar | last post by:
Hi All, I'm writing a Windows Service app using C#. I need to read some configuration settings before the service starts up. These settings will be used by the service in its operation. ...
3
by: pealy2 | last post by:
Sorry if this is in the wrong group, I've searched long & hard without finding anything even slightly useful. (recommendations for a more relevant group gratefuly received) I need to change the...
0
by: Snofkeen | last post by:
I have created a Windows service that tracks the file system and perform actions according to received input. the service is working, though I need to set it's recovery serttings, meaning, I need to...
2
by: Tom Bean | last post by:
I have written a Windows Service in C# and need to "Restart the Service" when the service fails. Is there any way to have these settings happen automatically as part of the service installation?...
0
by: Winder | last post by:
Computer Data Recovery Help 24/7 Data recovering tools and services is our focus. We will recover your data in a cost effective and efficient manner. We recover all operating systems and media....
5
by: Mika M | last post by:
Hi! I have made quite simple Windows Service using C# 2005. I also made Setup for it into same solution. When I run Setup, it will be installed ok into C:\Program Files\<MyCompany>\<MyService>....
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: 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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.