|
How to count the number of startup services and processes using C#. Is there a specific Win32 Class for this.
-----Have A Nice Day-----
|
|
|
|
|
RegistryKey theKey = Registry.LocalMachine.OpenSubKey
@("Software\\Microsoft\\Windows\\CurrentVersion\\Run");
string[] theValueNamesOfKey = theKey.GetValueNames();
|
|
|
|
|
Actually I know about this registry key, but when I count the items in the Run Folder it comes out to be lesser than items listed in the startup section of the msconfig.
-----Have A Nice Day-----
|
|
|
|
|
Actually not.
If you watch msconfig carefully, you can see that it might be having a extra number of start ups, but this registry key will give you only those which are enabled.
|
|
|
|
|
Dude, the registry key you are talking about has nine entries on my computer where as the msconfig shows thirteen. And above all, they all the active. No one of them are INACIVE..
Check out my solution.
-----Have A Nice Day-----
|
|
|
|
|
I created the following method for finding out the number of all the startup processes which is exclusive of the one in the HKLM\Software\Microsoft\CurrentVersion\Run. Here it goes.
public int getStartupProcessCount()
{
RegistryKey theKeyHKLM = Registry.LocalMachine.OpenSubKey(@"Software\\Microsoft\\Windows\\CurrentVersion\\Run");
string[] theValueNamesOfKeyHKLM = theKeyHKLM.GetValueNames();
RegistryKey theKeyHKCU = Registry.CurrentUser.OpenSubKey(@"Software\\Microsoft\\Windows\\CurrentVersion\\Run");
string[] theValueNamesOfKeyHKCU = theKeyHKCU.GetValueNames();
string val;
string dName;
int indexVal;
int countStartupProcessess;
string[] allVal = new string[theValueNamesOfKeyHKCU.Length + theValueNamesOfKeyHKLM.Length];
theValueNamesOfKeyHKLM.CopyTo(allVal, 0);
theValueNamesOfKeyHKCU.CopyTo(allVal, theValueNamesOfKeyHKLM.Length);
countStartupProcessess = allVal.Length;
string[] directories = Directory.GetDirectories("C:\\Documents and Settings");
foreach (string d in directories)
{
foreach(string d1 in Directory.GetDirectories(d))
{
indexVal = d1.LastIndexOf("\\");
dName = d1.Substring(indexVal+1, d1.Length - (indexVal+1));
if (dName.ToUpper() == "START MENU")
{
foreach (string d2 in Directory.GetDirectories(d1))
{
foreach (string d3 in Directory.GetDirectories(d2))
{
indexVal = d3.LastIndexOf("\\");
dName = d3.Substring(indexVal + 1, d3.Length - (indexVal + 1));
if (dName.ToUpper().Trim() == "STARTUP")
{
foreach (string f in Directory.GetFiles(d3))
{
indexVal = f.LastIndexOf(".");
dName = f.Substring(indexVal + 1, f.Length - (indexVal + 1));
if (dName.ToUpper() == "LNK" && dName.ToUpper() != "INI")
countStartupProcessess++;
}
}
}
}
}
}
}
return countStartupProcessess;
}
-----Have A Nice Day-----
|
|
|
|
|
|
You have no file name - C:\Documents and Settings is just a folder
System.IO.File.WriteAllText(@"C:\Documents and Settings<big>\MYFILE>TXT</big>", Entries.ToString());
You will need to change the file name each time, otherwise it will just be overwritten with each new message
Bob
Ashfield Consultants Ltd
|
|
|
|
|
thanks Bob.... but i forgot to include the file in my post (fax.txt).
since entries will be different from time to time, the file needs to be overwritten eachtime the code runs...
|
|
|
|
|
The same applies, you are overwriting the same file all the time!
|
|
|
|
|
ok...so how can i modify the code?
i believe this part here is not working:
Entries.ToAdd(sAMAccountName + " " + displayName + "" + myADFax + " " + strFAXLDAP + "");
|
|
|
|
|
mabby216 wrote: ok...so how can i modify the code?
Just asking that will gain you nothing. If you dont understand the problem, chances are you wont have a clue what the solution does. You need to understand both the problem and the solution, that's the only way you learn.
Else if you are stubborn, and not willing to learn, make a job request on the CP jobs forum, and pay someone to do it.
|
|
|
|
|
OK, so you are only posting some of the code and expecting us to guess whats wrong. Have you tried stepping through the code to see if you have any values? Are there any errors generated?
Bob
Ashfield Consultants Ltd
|
|
|
|
|
I want to know how I can get files from ftp server, what should I use...I haven't used ftp servers before...so I am completely new in that field...thx ahead
|
|
|
|
|
|
hi, i want to define coclass,and progid in my c# com object,but i cant !
can i perform this ?
|
|
|
|
|
iman_kh wrote: coclass
What do you mean?
Freshman
|
|
|
|
|
Hi,
I am using VS2008 and I am trying to access the appSetting value inside the app.config file.
This GetSetting method returns null but there is value in the app.config file?
Any thoughts please?
This is what I am doing:
string logFilePath = Util.GetSetting("LOGFILENAME");
public static string GetSetting(string val)
{
try
{
return ConfigurationSettings.AppSettings[val];
}
catch (Exception ex)
{
return "";
}
finally
{
}
}
--------------
App.Config file contains:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="LOGFILENAME" value="C:\Work\Developments\Services\LogFile\Log.txt" />
<add key="ERRORLOGFILENAME" value="C:\Work\Developments\Services\ErrorLogFile\Log.txt" />
<add key="PATHTOWATCH" value="C:\Work\Developments\" />
</appSettings>
</configuration>
|
|
|
|
|
I use VS 2005 and this works:
Properties.Settings.Default["name"]
|
|
|
|
|
I am using a windows service which has the app.config in it.
That does not work.
|
|
|
|
|
In VS2008
Properties.Settings.Default.yourpropertyname
(intellisense should show yourpropertyname)
works, and is (I believe) the currently recommended method.
Bob
Ashfield Consultants Ltd
|
|
|
|
|
Maybe this has something to do with this:
[ObsoleteAttribute("This method is obsolete, it has been replaced by System.Configuration!System.Configuration.ConfigurationManager.AppSettings")]
I know that obsolete doesn't mean it doesn't work but try to use the other method.
|
|
|
|
|
I have taken refences
using PowerPoint = Microsoft.Office.Interop.PowerPoint;
using Word = Microsoft.Office.Interop.Word;
and some code
public class PptToWord
{
PowerPoint.Application objApp;
PowerPoint.Presentations objPresSet;
PowerPoint._Presentation objPres;
PowerPoint.Slides objSlides;
public void CreateFile(StringCollection array)
{
String strTemplate;
strTemplate = "C:\\TFSPRESENTATION.ppt";
try
{
//Create a new presentation based on a template.
objApp = new PowerPoint.Application();
objPresSet = objApp.Presentations;
objApp.Visible = MsoTriState.msoTrue;
objPres = objPresSet.Open(strTemplate,MsoTriState.msoFalse , MsoTriState.msoTrue, MsoTriState.msoTrue);
objSlides = objPres.Slides;
// word doc
object oMissing = System.Reflection.Missing.Value;
Word._Application oWord;
Word._Document oDoc;
oWord = new Word.Application();
oWord.Visible = true;
oDoc = oWord.Documents.Add(ref oMissing, ref oMissing,ref oMissing, ref oMissing);
//oWord.ActiveDocument.InlineShapes.AddPicture();
foreach(PowerPoint._Slide slide in objSlides)
{
foreach(PowerPoint.Shape Slideshape in slide.Shapes)
{
if (Microsoft.Office.Core.MsoTriState.msoTrue == Slideshape.HasTextFrame)
{
if (Microsoft.Office.Core.MsoTriState.msoTrue == Slideshape.TextFrame.HasText)
{
//MessageBox.Show(Slideshape.TextFrame.TextRange.Text);
Word.Paragraph oPara1;
oPara1 = oDoc.Content.Paragraphs.Add(ref oMissing);
oPara1.Range.Text = Slideshape.TextFrame.TextRange.Text;
oPara1.Range.Font.Bold = 1;
oPara1.Format.SpaceAfter = 24; //24 pt spacing after paragraph.
oPara1.Range.InsertParagraphAfter();
}
}
if(Microsoft.Office.Core.MsoShapeType.msoPicture==Slideshape.Type)//for image
{
//Word.Shape oPicture;
// oPicture = (Word.Shape)Slideshape
// I am facing problem here, as i m not able to directly transfer pictures from power point slides to word document pictures.
// I dont want to save images on temprory location to my system hard disk. Can anyone guide me to do the same.
}
}
}
}
catch (Exception exp)
{
MessageBox.Show(exp.Message);
}
}
}
Can any one guide me.
Thanks and Regards
Haroon(SolnTryst)
Haroon(SolnTryst)
|
|
|
|
|
Hey guys
how can i add the following .cs file to VS so that the control will always be in VS toolbox for me to just drag and drop?
namespace DoubleBufferPanelNameSpace
{
class DoubleBufferPanel : Panel
{
public DoubleBufferPanel()
{
this.SetStyle(ControlStyles.AllPaintingInWmPaint |
ControlStyles.UserPaint |
ControlStyles.DoubleBuffer |
ControlStyles.ResizeRedraw,
true);
this.UpdateStyles();
}
}
}
thanx
Harvey Saayman - South Africa
Junior Developer
.Net, C#, SQL
you.suck = (you.passion != Programming)
|
|
|
|
|
To have it appear in your projects, you need to put it in a dll, and then import it into your project. For something this trival, a snippet could be a better idea ?
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|