Click here to Skip to main content
15,915,509 members
Home / Discussions / C#
   

C#

 
GeneralRe: how to get the recognized phoneme in SAPI Pin
Elgimas19-Nov-09 15:52
Elgimas19-Nov-09 15:52 
QuestionMultiple inheritance.. Pin
kumar sanghvi12-Nov-09 7:33
kumar sanghvi12-Nov-09 7:33 
AnswerRe: Multiple inheritance.. Pin
Abhishek Sur12-Nov-09 8:03
professionalAbhishek Sur12-Nov-09 8:03 
AnswerRe: Multiple inheritance.. Pin
Christian Graus12-Nov-09 9:24
protectorChristian Graus12-Nov-09 9:24 
AnswerRe: Multiple inheritance.. Pin
PIEBALDconsult12-Nov-09 9:37
mvePIEBALDconsult12-Nov-09 9:37 
AnswerRe: Multiple inheritance.. Pin
Shameel12-Nov-09 22:42
professionalShameel12-Nov-09 22:42 
GeneralRe: Multiple inheritance.. Pin
Paulo Zemek13-Nov-09 2:02
Paulo Zemek13-Nov-09 2:02 
Questionhow to find list of all the url tabs of IE presently running (multiple tabs) its name as application for each find cpu usage? Pin
namratabuddhadev12-Nov-09 6:58
namratabuddhadev12-Nov-09 6:58 
HI,
I am trying to find cpu usage or total processor time of each tab of IE. I am able to just list one main url in the list of application. I am able to list all the url using shdocvw but for that url, I am not able to find totalprocessortime and also for each cpuusage, as i am trying to find the power consumed by each url tab individually,can any body help me on it.

The code i have written is as follows:
using System;
using System.Collections.Generic;
using System.Text;
using System.Management;
using SHDocVw;
using System.Diagnostics;
//using System.ComponentModel; Smile | :)
//using System.Threading;
using System.Net;
using System.IO;
using System.Text.RegularExpressions;


namespace monitor_18_10
{

class Program
{


static void Main(string[] args)
{

// FileStream file1 = new FileStream("d:\\class\\log.txt", FileMode.OpenOrCreate, FileAccess.ReadWrite);
FileStream file1 = new FileStream("d:\\class\\yyyn.txt", FileMode.Create, FileAccess.ReadWrite);
StreamWriter sw1 = new StreamWriter(file1);
FileStream file2 = new FileStream("d:\\class\\log4.txt", FileMode.OpenOrCreate, FileAccess.ReadWrite);
StreamWriter sw2 = new StreamWriter(file1);
Process[] allProcs = Process.GetProcesses();

foreach (Process thisProc in allProcs)
{
//if (!thisProc.HasExited)
//{
// thisProc.Refresh();

string procName = thisProc.ProcessName;
//string totproc = thisProc.TotalProcessorTime.ToString();


int procID = thisProc.Id;

// string totproc=thisProc.TotalProcessorTime.ToString();
//string su=thisProc.StartTime.ToShortTimeString ();

//string su=thisProc.StartTime.ToString ();
//string su = proctime.ToString();

string s = procID.ToString();
string ss = procName.ToString();
// string sss = totproc.ToString();



// richTextBox1.AppendText(s + "\t" + ss + "\n");
Console .WriteLine (s + "\t" + ss + "\n");
sw1.WriteLine(s + "\t" + ss + "\n");


//}
}
sw1.WriteLine("-------------------------------------------------");
Console.WriteLine("-------------------------------------------------");
foreach (Process p in Process.GetProcesses("."))
{

try
//{do
{


// if(!p.HasExited )
// {
// p.Refresh ();

if (p.MainWindowTitle.Length > 0)
{
Console.Write("");
string s2;
string s3;
string pt;
s2 = p.MainWindowTitle.ToString();
s3 = p.StartTime.ToString();
pt = p.TotalProcessorTime.ToString();

//richTextBox2.AppendText(s2 + "\t" + s3 + "\t" + pt + "\n\n\n");
//richTextBox4.AppendText(s3 + "\n\n\n");

Console .WriteLine (s2 + "\t" + s3 + "\t" + pt + "\n");
Console.WriteLine(s3 + "\n\n\n");
sw1.WriteLine(s2 + "\t\t\t" + s3 + "\t\t\t" + pt + "\n\n\n");
//sw1.WriteLine(s3 + "\n\n\n");
//}
}

//} while (!p.WaitForExit(1000));
}
catch { }



}
Console.WriteLine("-------------------------------------------------");
sw1.WriteLine("-------------------------------------------------");
/// cpu usage of each processes
foreach (Process proc in Process.GetProcesses())
{
using (PerformanceCounter pcProcess = new PerformanceCounter("Process", "% Processor Time", proc.ProcessName))
{
pcProcess.NextValue();
//System.Threading.Thread.Sleep(1000);
// Console.WriteLine("Process:{0} CPU% {1}", proc.ProcessName, pcProcess.NextValue());
string cpuname = proc.ProcessName.ToString();
string pcprocess = (pcProcess.NextValue() / 100).ToString();

//richTextBox5.AppendText(cpuname + "\t" + pcprocess + "\n");
Console.WriteLine(cpuname + "\t" + pcprocess + "\n");
sw1.WriteLine(cpuname + "\t" + pcprocess + "\n");

}
}

Console.WriteLine("-------------------------------------------------");
sw1.WriteLine("-------------------------------------------------");
///reading excel data
///
StreamReader SR;
string S;
int i = 0;
SR = File.OpenText(@"d:\\class\\WR111.xls");

S = SR.ReadToEnd();
SR.Close();
Console.WriteLine(S);
string[] words = S.Split(';');
Array.Sort(words);
for (i = 0; i < words.Length; i++)
Console.WriteLine(words[i]);

//this will create the archive
//StreamWriter SW;
//SW = File.CreateText(@"d:\\class\\data2.txt");
for (i = 0; i < words.Length; i++)
sw1.WriteLine(words[i]);
//SW.Close();

//reading excel data ends here
/// cpu usage ends here


// --------------------------------------------------------------------
// List of application processes
// --------------------------------------------------------------------
string processName;
ShellWindows SW = new ShellWindowsClass();

foreach (SHDocVw.WebBrowser IE in SW)
{

processName = System.IO.Path.GetFileNameWithoutExtension(IE.FullName).ToLower();

string s4 = processName;

//Console.WriteLine(processName);
sw1.WriteLine(processName);

if (processName.Equals("iexplore"))
{
string s5 = IE.LocationURL.ToString();
sw1.WriteLine(s5);
Console.WriteLine(IE.LocationURL);
sw1.WriteLine(IE.LocationURL);
String s1 = ReadUrl(IE.LocationURL);
//richTextBox3.AppendText(IE.LocationURL + "\n");
Console.WriteLine(IE.LocationURL + "\n");
sw1.WriteLine(IE.LocationURL + "hello"+"\n");
Console.WriteLine("hi y this stupid is not running");
sw1.WriteLine(IE.LocationURL + "\n");
sw1.WriteLine("hi y this stupid is not running");

sw2.WriteLine(IE.LocationURL + "\n");

//Console.WriteLine(s1);
bool m;

if (m = s1.Contains(".aac"))

//Console.WriteLine("it contains audio");
sw1.WriteLine("it contains audio");

else if (m = s1.Contains(".aif"))

sw1.WriteLine("it contains audio");
else if (m = s1.Contains(".iff"))
sw1.WriteLine("it contains audio");
else if (m = s1.Contains(".m3u"))
sw1.WriteLine("it contains audio");
else if (m = s1.Contains(".mid"))
sw1.WriteLine("it contains audio");
else if (m = s1.Contains(".midi"))
sw1.WriteLine("it contains audio");
else if (m = s1.Contains(".mp3"))
sw1.WriteLine("it contains audio");
else if (m = s1.Contains(".mpa"))
sw1.WriteLine("it contains audio");
else if (m = s1.Contains(".wav"))
sw1.WriteLine("it contains audio");
else if (m = s1.Contains(".wma"))
sw1.WriteLine("it contains audio");
else if (m = s1.Contains(".3g2"))
sw1.WriteLine("it contains video");
else if (m = s1.Contains(".3gp"))
sw1.WriteLine("it contains video");
else if (m = s1.Contains(".asf"))
sw1.WriteLine("it contains video");
else if (m = s1.Contains(".asx"))
sw1.WriteLine("it contains video");
else if (m = s1.Contains(".avi"))
sw1.WriteLine("it contains video");
else if (m = s1.Contains(".flv"))
sw1.WriteLine("it contains video");
else if (m = s1.Contains(".mkv"))
sw1.WriteLine("it contains video");
else if (m = s1.Contains(".mov"))
sw1.WriteLine("it contains video");
else if (m = s1.Contains(".mp4"))
sw1.WriteLine("it contains video");
else if (m = s1.Contains(".mpg"))
sw1.WriteLine("it contains video");
else if (m = s1.Contains(".qt"))
sw1.WriteLine("it contains video");
else if (m = s1.Contains(".rm"))
sw1.WriteLine("it contains video");
else if (m = s1.Contains(".swf"))
sw1.WriteLine("it contains video");
else if (m = s1.Contains(".vob"))
sw1.WriteLine("it contains video");
else if (m = s1.Contains(".wmv"))
sw1.WriteLine("it contains video");
else
sw1.WriteLine("no audio or video in the file");




string type = ExtractApplicationType(s1);

if (type.CompareTo("vedio") == 0)
{
sw1.WriteLine("Running Vedio application");

}
else
{
sw1.WriteLine("Running text application");
}

}







//this.Refresh();

}
//reading data from the meter
//readexceldata();
sw1.Close();
}

static string ReadUrl(string url)

{
//FileStream file2 = new FileStream("d:\\class\\log2.txt", FileMode.OpenOrCreate, FileAccess.ReadWrite);
//StreamWriter sw2 = new StreamWriter(file2);
Uri uri = new Uri(url);
//sw2.WriteLine("hi");
//sw2.WriteLine(url);
//Create the request object
WebRequest req = WebRequest.Create(uri);

WebResponse resp = req.GetResponse();
Stream stream = resp.GetResponseStream();
StreamReader sr = new StreamReader(stream);

string sss = sr.ReadToEnd();
//string sss = uri.ToString();

return (sss);

}
//public static void readexceldata()
// {
// StreamReader SR;
// string S;
// int i = 0;
// SR = File.OpenText(@"d:\\class\\WR111.xls");

// S = SR.ReadToEnd();
// SR.Close();
// Console.WriteLine(S);
// string[] words = S.Split(';');
// Array.Sort(words);
// for (i = 0; i < words.Length; i++)
// Console.WriteLine(words[i]);

// //this will create the archive
// StreamWriter SW;
// SW = File.AppendText(@"d:\\class\\yyy.txt");
// for (i = 0; i < words.Length; i++)
// SW.WriteLine(words[i]);
// SW.Close();

// }
static string ExtractApplicationType(string s)
{

// Line like: "Last</TD><TD ALIGN=RIGHT NOWRAP><B>&nbsp;78 3/16"
// Line Like embed src
string sPattern = "application/x-shockwave-flash";
if (System.Text.RegularExpressions.Regex.IsMatch(s, sPattern, System.Text.RegularExpressions.RegexOptions.IgnoreCase))
{
// richTextBox3.AppendText(" (match for '{0}' found)", sPattern);
return "vedio";
}
else
{
return "text";
}
// return "text";
}



}
}




Hope to get reply,

thanks in advance...


Cheers..
Namrata Smile | :)


Namrata
AnswerRe: how to find list of all the url tabs of IE presently running (multiple tabs) its name as application for each find cpu usage? Pin
The Man from U.N.C.L.E.12-Nov-09 9:43
The Man from U.N.C.L.E.12-Nov-09 9:43 
AnswerRe: how to find list of all the url tabs of IE presently running (multiple tabs) its name as application for each find cpu usage? Pin
Shameel12-Nov-09 22:46
professionalShameel12-Nov-09 22:46 
QuestionUrlEncode Problem Pin
snouto12-Nov-09 6:55
snouto12-Nov-09 6:55 
AnswerRe: UrlEncode Problem Pin
Abhishek Sur12-Nov-09 7:00
professionalAbhishek Sur12-Nov-09 7:00 
AnswerRe: UrlEncode Problem Pin
Shameel12-Nov-09 7:30
professionalShameel12-Nov-09 7:30 
AnswerRe: UrlEncode Problem Pin
Luc Pattyn12-Nov-09 7:39
sitebuilderLuc Pattyn12-Nov-09 7:39 
QuestionHow to capture screenshot of a web site in unattended mode? Pin
kskarun12-Nov-09 6:03
kskarun12-Nov-09 6:03 
AnswerRe: How to capture screenshot of a web site in unattended mode? Pin
Abhishek Sur12-Nov-09 6:57
professionalAbhishek Sur12-Nov-09 6:57 
AnswerRe: How to capture screenshot of a web site in unattended mode? Pin
Saksida Bojan12-Nov-09 7:36
Saksida Bojan12-Nov-09 7:36 
GeneralRe: How to capture screenshot of a web site in unattended mode? Pin
Abhishek Sur12-Nov-09 8:00
professionalAbhishek Sur12-Nov-09 8:00 
Questionc# vs c++ Pin
kumar sanghvi12-Nov-09 5:26
kumar sanghvi12-Nov-09 5:26 
AnswerRe: c# vs c++ Pin
The Man from U.N.C.L.E.12-Nov-09 5:29
The Man from U.N.C.L.E.12-Nov-09 5:29 
AnswerRe: c# vs c++ Pin
Not Active12-Nov-09 5:30
mentorNot Active12-Nov-09 5:30 
GeneralRe: c# vs c++ Pin
The Man from U.N.C.L.E.12-Nov-09 5:32
The Man from U.N.C.L.E.12-Nov-09 5:32 
GeneralRe: c# vs c++ Pin
Blubbo12-Nov-09 8:30
Blubbo12-Nov-09 8:30 
Questiona french question Pin
boudj12-Nov-09 5:01
boudj12-Nov-09 5:01 
AnswerRe: NOT a french question Pin
Luc Pattyn12-Nov-09 5:07
sitebuilderLuc Pattyn12-Nov-09 5:07 

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.