|
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.ServiceProcess;
using System.Text;
namespace SystemTrayIconInSvc
{
public partial class Svc : ServiceBase
{
private SensAdvisor m_Advisor = new SensAdvisor();
private SettingDlg m_Dlg = null;
public Svc()
{
InitializeComponent();
m_Advisor.OnShellStarted += this.PostShell;
}
internal void DebugStart()
{
OnStart(null);
}
protected override void OnStart(string[] args)
{
// if the service started after the windows logon
CloseDlg();
m_Dlg = SettingDlg.StartUIThread();
}
protected override void OnStop()
{
CloseDlg();
}
/// <summary>
/// Called when the shell is ready
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
public void PostShell(object sender, SensLogon2EventArgs e)
{
CloseDlg();
m_Dlg = SettingDlg.StartUIThread();
}
protected void CloseDlg()
{
if (m_Dlg != null)
{
try
{
m_Dlg.Close();
m_Dlg.Dispose();
}
catch { }
m_Dlg = null;
}
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
Jerry is from China. He was captivated by computer programming since 13 years old when first time played with Q-Basic.
- Windows / Linux & C++
- iOS & Obj-C
- .Net & C#
- Flex/Flash & ActionScript
- HTML / CSS / Javascript
- Gaming Server programming / video, audio processing / image & graphics
Contact: vcer(at)qq.com
Chinese Blog: http://blog.csdn.net/wangjia184