|
Try using WMI to get these values. You could combine them to create a unique ID too. Microsoft has a WMI generator tool that will help with the code, you can get it here: http://www.microsoft.com/downloads/details.aspx?familyid=2CC30A64-EA15-4661-8DA4-55BBC145C30E&displaylang=en
|
|
|
|
|
got ppl know how to change form bgcolor or label fontcolor which using dropdownlist????
|
|
|
|
|
iyoko wrote: got ppl know how to change form bgcolor or label fontcolor which using dropdownlist????
Your question is a little unclear.
If you mean, change either the form background colour / label font-colour when an item is selected in a dropdownlist, the you simply need to handle one of the selection changed events (SelectedIndexChanged, SelectedValueChanged or SelectionChangeCommitted). In the event handler, you can then call a method to change the colour of the target control by setting the value of the approriate property.
|
|
|
|
|
hi
I try to write a program that can add in IE .and when I open IE it running .(windows application no web application).
I want when I right click on link in IE(or another browser)when open popup menu choose an item that I add this to popup menu .this item have runnig an external program .I don't know how can add new item in right click popup menu in IE .I search about IE programming but don't arrive anythings about this.
if you know about this , please help me.
tanks
-- modified at 4:42 Sunday 22nd October, 2006
computer
|
|
|
|
|
Hi everyone,
I wrote an java applet for smart card with eclipse(3.1) ,I wrote oncard and offcard applet and I would like use the offcard applet in visual studio .I mean I need to add the offcard applet in C#,but I don't know how can I do it because I used some type in the offcard applet that they are not known in C#(such as JCTerminal or JCard or OPApplet),If anyone knows the solution please inform me.
yours sincerely ,
Orchid.
|
|
|
|
|
how could i get that in which drive windows is installed?!
|
|
|
|
|
System.Environment.SystemDirectory returns the path to the System directory... you could just get the first character.
|
|
|
|
|
You can retrieve the path of the system directory using the Environment.SystemDirectory property and extract drive information from it:
string windowsDrive = Path.GetPathRoot(Environment.SystemDirectory);
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
Dear all,
I want to calculate the execution time of a certain piece of code. I noticed that the min. value I can get is the tick which is equivalent to 100 nanoseconds. I want to know what shall I do if the code takes less 100 nanoseconds, especially on fast computers? I tried to use DateTime class and TimeSpan class but they were of no use. Any help
Regards
islheg
|
|
|
|
|
If you're using .Net 2.0, there is a new class:
System.Diagnostics.Stopwatch
----------------------------
Be excellent to each other
|
|
|
|
|
That still has a resolution of at least 10-15 milliseconds.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
From MSDN:
The Stopwatch measures elapsed time by counting timer ticks in the underlying timer mechanism. If the installed hardware and operating system support a high-resolution performance counter, then the Stopwatch class uses that counter to measure elapsed time. Otherwise, the Stopwatch class uses the system timer to measure elapsed time. Use the Frequency and IsHighResolution fields to determine the precision and resolution of the Stopwatch timing implementation.
The resolution is 0.5 nanoseconds on my 2GHz system, although the overhead of calling Start and Stop seems to be about 10 microseconds.
----------------------------
Be excellent to each other
|
|
|
|
|
Well, it looks like I'm going to have to go back and read that again! :->
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
You'll have to use the QueryPerformanceCounter API. Just search the articles for that term. It's the only timer that has a resolution even close to that.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Why does this throw an error?
byte b=Byte.Parse("4F");
I have this string array of numbers 20 00 08 01 08 4C 82 32 that I want to convert to a byte array. The thing is thought, that I want to treat the numbers literally. It all works fine until i get to 4C in my loop:
for (int i = 0; i < chars.Length; i++)
{
OutputReportBuffer[i] = Byte.Parse(chars[i]);
}
/\ |_ E X E GG
|
|
|
|
|
eggie5 wrote: I have this string array of numbers 20 00 08 01 08 4C 82 32 that I want to convert to a byte array. The thing is thought, that I want to treat the numbers literally. It all works fine until i get to 4C in my loop:
It's not throwing an exception until you hit 4C, but you're not getting what you think you're getting. The Parse() method expects the string to be base 10 (decimal), not hex. Convert your hex value to decimal, then pass it in.
Share and enjoy.
Sean
|
|
|
|
|
Sean Michael Murphy wrote: It's not throwing an exception until you hit 4C, but you're not getting what you think you're getting. The Parse() method expects the string to be base 10 (decimal), not hex. Convert your hex value to decimal, then pass it in.
Even better, let the framework take care of the conversion for you. Check out this Byte.Parse() overload[^], passing NumberStyles.HexNumber in as the second argument.
|
|
|
|
|
Hi Everyone,
I have an application that I wrote in C# that allows users to back up their files to a network storage automatically. It uses the file modification times to figure out which files are newer on the computer than the storage location, and only copies the files it needs to on to the server.
The application starts a thread and the thread does all of the work in the background. What I would like to do is deploy the software to our computers and have it run automatically (and minimize itself) at system logon using a logon script.
I want my application to be able to detect when the CPU usage is at a certain level. If the CPU usage is below, lets say 20%, the application will do it's monitoring and copying. If the application detects the CPU usage rises above a certain threshold, it will suspend its operations and wait around for a while doing nothing.
I don't want the application running all of the time taking up CPU. My users run Photoshop and VS .NET and other applications simultaneously that take up most all of thier CPU.
Does anyone know of a way to detect what the current CPU usage is at? (Not the CPU usage of my application, but total CPU usage of all applications). I saw an article on here that gave you the usage of the current application, but it said it was difficult to do in .NET and they did not know how to do it.
Any help would be appreciated!
|
|
|
|
|
I have done this in ASP.NET, but I am having trouble with it in a C# windows app (that could be because this is my first c# project). At the moment I am just practicing skills against the northwind db.
I have a form with a datagridview bound to a SQL datasource. No problem. I can see and edit the northwind data just fine. I have a textbox that repeats the value of the first column of the selected datagridview row using SelectedCells[0].FormattedValue.ToString(). Works great.
Now, I have a list box that I would like to populate with data from a second table based on the value of SelectedCells[0].FormattedValue.ToString().
How do I do that?
Dave
|
|
|
|
|
Hi,
whats the preferred method of connecting to a database.
a)
create a static SqlConnection object
or
b)
using Sqlconnection = new... {}
having a Using section in every Add, Get, Delete function.
My question is, is having a static object connection open for the duration of the application, a major overhead?
Or is it better (all be it, more code) to have a Using statement, that connects, executes, then disconnects from the database? Thus no permanent connection.
Any thoughts?
Mark
|
|
|
|
|
Microsoft recommends the latter. The SqlClient provider maintains a pool of connection objects (adjustable via the connection string) for each process (the pool is actually keyed by the texet in the connection string, so you should take care to always use exactly the same string content). The ool largely eliminatesw the overhead of creating connection objects (the new... actually justs pulls an exixting idle connection from the pool) so what is left is onloy the overhead of opening the connection which is fairly small. The recommendation is to open the connection as late as possible, and close it as soon as you are done with the operation at hand. Keeping the connection open for the duration runs the risk that your process could terminate unexpectedly and leave a dead connection behind. This will not be reclaimed until the server is restarted. It also ties up a limited resource unnecessarily.
|
|
|
|
|
Microsoft recommends the latter. The SqlClient provider maintains a pool of connection objects (adjustable via the connection string) for each process (the pool is actually keyed by the texet in the connection string, so you should take care to always use exactly the same string content). The ool largely eliminatesw the overhead of creating connection objects (the new... actually justs pulls an exixting idle connection from the pool) so what is left is onloy the overhead of opening the connection which is fairly small. The recommendation is to open the connection as late as possible, and close it as soon as you are done with the operation at hand. Keeping the connection open for the duration runs the risk that your process could terminate unexpectedly and leave a dead connection behind. This will not be reclaimed until the server is restarted. It also ties up a limited resource unnecessarily.
Another reason not to do this is that should your connection become damaged (by a network or server fault) you have no way to recover other than to restart your entire process. Closing the connection when you are done with it (or on an error) and opening a new one whenever needed limits the damage to a single query, which could be retried.
|
|
|
|
|
Hi guys, I have this code:
public void showProcesses()<br />
{<br />
Process[] processes = Process.GetProcesses();<br />
List<Process> killList = new List<Process>();<br />
foreach (Process p in processes)<br />
{<br />
if (!(p.ProcessName == "System" || p.ProcessName == "Idle"))<br />
{<br />
string theProcess = p.MainModule.ModuleName;<br />
processesTest = processesTest + theProcess;<br />
killList.Add(p);<br />
}<br />
}<br />
richTextBox1.Text = processesTest;<br />
}
I keep getting the error: Error 1 'System.Windows.Forms.ColumnHeader' does not contain a definition for 'GetProcesses'
I have referenced System.Diagnostics too, this is really confusing! Any ideas anyone?
|
|
|
|
|
You perhaps named a Column as Process ?
|
|
|
|
|
Hi,
i got a big problem, i have to read in C# a propertyBag that was serialized in VB6 and persisted on a SQLServer Blob (IMAGE) field. So i got it from DataBase and tried Deserialize using this code
byte [] objSerialized = izDAL.loadSession(token)
MemoryStream memoStream = new MemoryStream(objSerialized);
BinaryFormatter binaryFormatter = new BinaryFormatter();
Hashtable sessionBag = (Hashtable)binaryFormatter.Deserialize(memoStream);
IDictionaryEnumerator en = sessionBag.GetEnumerator();
but i got this erros
{"BinaryFormatter Version incompatibility. Expected Version 1.0. Received Version 1426065408.740500660." }
Any idea? I'm using ASP.NET 1.4 framework...
Thx
|
|
|
|