Click here to Skip to main content
15,921,840 members
Home / Discussions / C#
   

C#

 
GeneralRe: windows not in focus Pin
michaelgr117-Jan-10 5:28
michaelgr117-Jan-10 5:28 
GeneralRe: windows not in focus Pin
wjp_auhtm17-Jan-10 18:33
wjp_auhtm17-Jan-10 18:33 
GeneralRe: windows not in focus Pin
michaelgr117-Jan-10 20:06
michaelgr117-Jan-10 20:06 
GeneralRe: windows not in focus Pin
wjp_auhtm17-Jan-10 21:24
wjp_auhtm17-Jan-10 21:24 
GeneralRe: windows not in focus Pin
michaelgr117-Jan-10 21:35
michaelgr117-Jan-10 21:35 
GeneralRe: windows not in focus Pin
wjp_auhtm17-Jan-10 21:57
wjp_auhtm17-Jan-10 21:57 
GeneralRe: windows not in focus Pin
michaelgr117-Jan-10 22:00
michaelgr117-Jan-10 22:00 
GeneralRe: windows not in focus Pin
wjp_auhtm17-Jan-10 22:26
wjp_auhtm17-Jan-10 22:26 
OK, the simple code to check if the service is running like this.

/// <summary>
/// TODO: Is the windows service running.
/// </summary>
/// <param name="name">The name of windows service.</param>
private bool IsRunning(string name)
{
    bool IsRun = false;
    if (!isServiceIsExisted(name)) // this function was named previously.
    {
        return false;
    }
    ServiceController sc = new ServiceController(name);
    if (sc.Status == ServiceControllerStatus.StartPending ||
        sc.Status == ServiceControllerStatus.Running)
    {
        IsRun = true;
    }
    sc.Close();

    return IsRun;
}


Set the service to start automatically:
Change the value of property named "StartType" of the windows service to "Automatic".

BTW, owing to the limitation of my knowledge, the code are not very strong.I suggest that you can research them by yourself. I think that after you reserach them, you will learn more.
GeneralRe: windows not in focus Pin
michaelgr117-Jan-10 22:39
michaelgr117-Jan-10 22:39 
GeneralRe: windows not in focus Pin
wjp_auhtm17-Jan-10 22:57
wjp_auhtm17-Jan-10 22:57 
GeneralRe: windows not in focus Pin
Heinzzy18-Jan-10 3:51
Heinzzy18-Jan-10 3:51 
GeneralRe: windows not in focus Pin
wjp_auhtm18-Jan-10 14:21
wjp_auhtm18-Jan-10 14:21 
GeneralRe: windows not in focus Pin
Ravi Bhavnani17-Jan-10 9:26
professionalRavi Bhavnani17-Jan-10 9:26 
GeneralRe: windows not in focus Pin
wjp_auhtm17-Jan-10 18:41
wjp_auhtm17-Jan-10 18:41 
AnswerRe: windows not in focus Pin
Heinzzy17-Jan-10 5:47
Heinzzy17-Jan-10 5:47 
GeneralRe: windows not in focus Pin
michaelgr117-Jan-10 6:40
michaelgr117-Jan-10 6:40 
QuestionHow to reject changes between two equal DataTables? Pin
obarahmeh16-Jan-10 21:13
obarahmeh16-Jan-10 21:13 
AnswerRe: How to reject changes between two equal DataTables? Pin
dan!sh 16-Jan-10 21:20
professional dan!sh 16-Jan-10 21:20 
QuestionUSB read Pin
michaelgr116-Jan-10 20:39
michaelgr116-Jan-10 20:39 
AnswerRe: USB read Pin
Alex Manolescu16-Jan-10 21:24
Alex Manolescu16-Jan-10 21:24 
QuestionMicrosoft.SqlServer.Management.Smo.FailedOperationException: Backup failed for Server ‘\\.\pipe\3F103E6E-3FD4-47\tsql\query’ Pin
Mohammad Dayyan16-Jan-10 20:28
Mohammad Dayyan16-Jan-10 20:28 
AnswerRe: Microsoft.SqlServer.Management.Smo.FailedOperationException: Backup failed for Server ‘\\.\pipe\3F103E6E-3FD4-47\tsql\query’ Pin
dan!sh 16-Jan-10 21:15
professional dan!sh 16-Jan-10 21:15 
GeneralRe: Microsoft.SqlServer.Management.Smo.FailedOperationException: Backup failed for Server ‘\\.\pipe\3F103E6E-3FD4-47\tsql\query’ Pin
Mohammad Dayyan16-Jan-10 21:21
Mohammad Dayyan16-Jan-10 21:21 
GeneralRe: Microsoft.SqlServer.Management.Smo.FailedOperationException: Backup failed for Server ‘\\.\pipe\3F103E6E-3FD4-47\tsql\query’ Pin
dan!sh 16-Jan-10 21:54
professional dan!sh 16-Jan-10 21:54 
GeneralRe: Microsoft.SqlServer.Management.Smo.FailedOperationException: Backup failed for Server ‘\\.\pipe\3F103E6E-3FD4-47\tsql\query’ Pin
Mohammad Dayyan16-Jan-10 23:29
Mohammad Dayyan16-Jan-10 23:29 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.