|
hot to get processor ID in C#
|
|
|
|
|
|
If you're talking about getting the capabilities of the processor, please continue reading the link posted by the other responder.
If you're talking about getting the processor serial number (CPUID), don't bother. Only Intel and Transmeta ever implemented it for a short time in certain CPU models. Intel doesn't even implement it in the latest CPUs and AMD never implemented it at all. It's utterly useless to identify a machine uniquely.
|
|
|
|
|
Hello
Add the System.Management reference
And use the following code
public static String GetCPUId()
{
String processorID = "";
ManagementObjectSearcher searcher = new ManagementObjectSearcher(
"Select * FROM WIN32_Processor");
ManagementObjectCollection mObject = searcher.Get();
foreach (ManagementObject obj in mObject)
{
processorID = obj["ProcessorId"].ToString();
}
return processorID;
}
P.S :
Some CPU didn't support the CPUID instruction, in which case, the call can't be guaranteed to succeed.
|
|
|
|
|
|
This must be a certain type of test. Looks like it is successful.
I suggest that this be the end of the test.
modified 21-Feb-12 9:00am.
|
|
|
|
|
G'day,
I am writing something to deal with logged multi-user access to our social media accounts, and what I want to do is add a second textbox when the message goes over the Twitter maximum - 140.
What I have at the moment is a form with the controls anchored to their spot on the page. When the second textbox is needed, i call a timer with a 1ms trigger time to expand the size of the form by one 1 px until it's at the "large" size.
The idea behind this is to have the second textbox slide down from behind the first one.
However it is not fluid. Any ideas how I can speed it up or a better way of doing it?
Thanks!
Brendan
|
|
|
|
|
Slow the timer down.
At the moment you are asking for 1000 frames per second animation - the drawing can't keep up with that rate so it looks "jerky". Change the interval to say 40 and try again.
If may also be worth turning DoubleBuffered to true for the form - experiment. If you don't need it then don't do it as it slows drawing down.
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
|
|
|
|
|
Is there a better way of doing it?
I would like it to slide out smoothly, but also at a decent speed!
Thanks,
Brendan
|
|
|
|
|
Movies get played at 24 or 25 frames per second, which is faster than the human eye can discern, resulting in smooth films. So there is no point in having a timer period which is less than say 30 milliseconds. What you should do however, is in each repaint use the actual time, not the predicted or expected one, to calculate how the new frame should look; doing it that way you'd compensate for most of the timing jitter a Windows PC may experience.
|
|
|
|
|
I have a text file in unicode. I want to convert it in english using C# or VB. Can any one help me?
|
|
|
|
|
Probably not.
A text file in Unicode could be in English already - Unicode just specifies a the character encoding to be used to represent the data (as opposed to ASCII or similar).
If your data is in Farsi, or French, or Mandarin, then you need serious help to convert it to English!
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
|
|
|
|
|
Unicode values less than 128 are the same as ASCII (which was the most common encoding for English before Unicode). So if you take your Unicode characters and put each one in a byte and write it out, you have ASCII.
Unicode characters 128 and above can't be translated to ASCII, so you could replace these with another character (space, ?, or whatever you want).
It may be helpful to know that pure ASCII is already compatible with the UTF-8 representation of Unicode. The only difference is that non-ASCII characters will take more than one byte in UTF-8. But since you're dealing with English, they're essentially the same for your application.
"Microsoft -- Adding unnecessary complexity to your work since 1987!"
|
|
|
|
|
Hi CodeProject community,
I have been using a custom print component, which was made by 'Duncan Edwards Jones' a member from here, and it has been such a huge help in letting me print parts of my form. Now that I have been using .NET framework 4 client profile, Duncan's component doesn't seem to be compatible with it The error I receeve is "Error 2 The type or namespace name 'FormPrintComponent' could not be found (are you missing a using directive or an assembly reference?)"
I would love to use this component in the .NET Framework 4 client profile, but I don't know how to fix the error
Please help me CodeProject, thank you
Heres the custom print component in case you're wondering: Form Print Control[^]
|
|
|
|
|
For any questions on the component, you'll have to ask him about it by posting in the forum at the bottom of the article.
But, the first thing I'd do is get the source code and recompile it targeting the .NET 4.0 Client Profile. Then you could probably use it without any problems.
|
|
|
|
|
It sounds like you are doing something wrong then. I haven't used that component, nor have I studied it in any detail, however here is what should fix the problem:
1. create a Visual Studio solution
2. add Duncan's project to it, and choose the target .NET version you want
3. build it (fix any problem that may occur, none expected)
4. add your project to the solution
5. add to your project a reference to Duncan's
6. add to your source code a "using FormPrintComponent;" statement referring to Duncan's namespace
7. choose the same target .NET version as before
8. now build it all.
|
|
|
|
|
Thank you both for trying to help me Yes I do have the source code because Duncan provided it. I might of not changed the target .NET version when I built it, since I never even thought of doing that lol, so I'll first try doing that, build it, and use it on my project which uses .NET 4 Client Profile and I'll get right back if all is a success or it still gives me issues Thanks again for the help
|
|
|
|
|
I tried doing what the two of you suggested, to build the .dll in the .NET framework 4 client profile, but an error occurs in this code(the bold is the error part):
#region FormPrintHelperComponent design
namespace Design
{
#region FormPrintHelperComponentDesigner
[System.Security.Permissions.PermissionSetAttribute(System.Security.Permissions.SecurityAction.Demand, Name="FullTrust")]
public class FormPrintHelperComponentDesigner :
System.ComponentModel.Design.ComponentDesigner
{
And highlighting it, it says: cannot resolve symbol 'ComponentDesigner'. It's strange as to why it won't build for framework 4 client profile, but it will build for framework 4
I'll ask Duncan, but I'm not sure he's still ever on. Thats why I was hoping for help here in the forum, but I'll ask in both places
|
|
|
|
|
The whole idea (as silly as it seems to me) of the client profile (introduced with .NET 4.0) is to offer a smaller run-time environment; the only way to achieve that was by eliminating some functionality. If you need more than what 4-client offers, you have to select the full 4.0 version. So change the target for both projects and you should be well.
|
|
|
|
|
yes I noticed that it and worked I just hope that my application will remain around the same size as using .NET 4 as it was using .NET 4 client profile.
|
|
|
|
|
AFAIK it doesn't change the size or even the code of the app itself, it just binds it to another .NET instance, one that is different in size. The smaller one could make sense on resource limited devices, provided it happens to include everything you need.
|
|
|
|
|
Your application, on disk, won't grow. What will change is the memory profile of your application.
|
|
|
|
|
hi, using c#, to export crystal report into excel; how to protect the excel with password?
below is my code for exporting all pages
ReportDocument objRDoc = new ReportDocument();
objRDoc.Load("rpt path");
ExportOptions CrExportOptions ;
DiskFileDestinationOptions CrDiskFileDestinationOptions = new DiskFileDestinationOptions();
ExcelFormatOptions CrFormatTypeOptions = new ExcelFormatOptions();
CrDiskFileDestinationOptions.DiskFileName = "c:\\1111.xls";
CrExportOptions = objRDoc.ExportOptions;
CrExportOptions.ExportDestinationType = ExportDestinationType.DiskFile;
CrExportOptions.ExportFormatType = ExportFormatType.Excel;
CrExportOptions.DestinationOptions = CrDiskFileDestinationOptions.DiskFileName;
CrExportOptions.FormatOptions = CrFormatTypeOptions;
objRDoc.Export();
|
|
|
|
|
this question is deserving of lmgtfy[^]
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
which is the best language to learn
|
|
|
|