我将项目导出到服务中,我可以获取所有进程,可以获取“ chrome”进程,但不知道如何获取标签的网址, 这是开始
//start
protected override void OnStart(string[] args)
{
LogText("MMA_Service", "In OnStart.");
System.Timers.Timer timer = new System.Timers.Timer();
timer.Interval = 60000; // 60 seconds
timer.Elapsed += new ElapsedEventHandler(this.OnTimer);
timer.Start();
ServiceStatus serviceStatus = new ServiceStatus();
serviceStatus.dwCurrentState = ServiceState.SERVICE_START_PENDING;
serviceStatus.dwWaitHint = 100000;
SetServiceStatus(this.ServiceHandle, ref serviceStatus);
serviceStatus.dwCurrentState = ServiceState.SERVICE_RUNNING;
SetServiceStatus(this.ServiceHandle, ref serviceStatus);
}
这是ontimer方法
//onTimer
public void OnTimer(object sender, ElapsedEventArgs args)
{
LogText("MMA_Service", "Monitoring the System " + (eventId++).ToString());
IntPtr CHandle = GetChromeHandle();
}
在这里,我想提示该过程的网址
// GetChromeProcess
public static IntPtr GetChromeHandle()
{
Process[] Allpro = Process.GetProcesses();
foreach (Process pro in Allpro)
{
if (pro.ProcessName == "chrome")
{
//get the url !!
}
}
}