|
There is no single method for getting a hard drive serial number. WMI does not work in all cases because the is no mandate that says every manufacturer has to support it.
There are about 4 different methods for getting a hard drive serial number. None of them work on all hard drives. It's best to use multiple methods to be sure your actually getting the correct information.
There are libraries out there that will do this for you, such as this one[^]. I haven't used it though, nor any other library for this.
|
|
|
|
|
Adding to what others have said, on Vista and later you may get UAC trouble, as getting physical information is considered dangerous. Having some kind of solution that works on XP is no guarantee it will work on more recent Windows versions.
|
|
|
|
|
Hi,
suppose my SP returns 8 results sets i want to fetch only the 8th resultset....the issue which im facing with IMultipleResults.GetResult<> is
it is not able to give the 8th resultset...and i need to call all the 7 resultsets before i call 8th resultset....and please let me know how to fetch the 8th resultset directly....
As this is possible in classic ado.net using tablemapping to fetch the desired result set ...please let me know how this can be achieved using Linq to Sql..
|
|
|
|
|
siva455 wrote: please let me know how this can be achieved using Linq to Sql.
Maybe by posting in the LINQ forum.
|
|
|
|
|
I'd recommend rewriting your SP so it only returns the information needed.
Since you're returning 8 results set and throwing out 7 of them, you're wasting compute resources on the SQL Server.
|
|
|
|
|
Thanks for ur solution...but as my SP used across other places of code where they coonsume some of the
resultsets in 8 resultsets....
Please suggest me is there a way to fetch only the particukar resultset from SP...
|
|
|
|
|
Then write another SP that only returns the resultset in question.
Having a single SP that returns all kinds of data your don't need is very wasteful.
Or dont use an SP and just code the SELECT string to return the data required.
|
|
|
|
|
|
I am not able to access the crystal reports at run time using C# GUI. I am running the application in Windows 7. Evrything is ok bt while running, it is giving error in the statement where crystal report is initialized. Do we require some component to be installed there???
NEHA GUPTA
|
|
|
|
|
Since you didn't think the error message was all that important to post, we can only guess.
Yes, you have to install the CrystalReports runtime in order to run your app that uses CR. It must be the same version as what you wrote your app against.
|
|
|
|
|
I'm trying to understand how to use the P/Invoke method SystemParametersInfo() to get some information from my mobile computer. I am ok with the following requirements:
using System.Runtime.InteropServices;
[DllImport("coredll.dll")]
private static extern int SystemParametersInfo(uint uiAction, uint uiParam, StringBuilder pvParam, uint fWiniIni);
with a question regarding the 'pvParam' parameter. I have seen it used as StringBuilder, string, int, etc. If I type it as a string, does that limit the types of uiActions and uiParams I can return? Do I have to re-construct it with a different type for the 'pvParam' for others? I apologize that this is a bit confusing, but the document on MSDN shows the constructor and the parameters, but it's difficult to figure out exactly how to use it from that. My final source of confusion, and this is the one I'm really hung up on, is why I have to perform the following:
private const uint SPI_GETPLATFORMTYPE = 257;
private const uint SPI_GETOEMINFO = 258;
I don't understand why I have to specify an int value, and does the value matter? I see that it happens to be the next two values after 256, which seems significant but I'm not sure why. I can't find any documentation that shows that this is what I must do in order to use something like SPI_GETOEMINFO, nor can I find an explanation for the use of '258'.
Regards,
Scott
|
|
|
|
|
The reason for the StringBuider is so that the called method can modify it - strings are immutable in .NET so when a change is to be made a new string is created. This is not the case with StringBuider. If you pass string to the P/Invoked method, it cannot change it.
pvParam just stands for "pointer to a void" parameter, which is the C++ version of a reference to an object - it is a parameter which can be in effect any type, depending on what function the method is to perform on it.
Why an int value? Because the constant is an integer! C# is strongly typed, so if you didn't specify the type when you declared it, it could cause confusion when you used it later.
Yes, the value does matter! It is the value that is passed through to the P/Invoked method, and which tells it what action it is to perform - not the name of the constant! If the value is wrong, the method will perform the wrong action. You don't need to declare these as constants - you could just use the numbers directly in the method call - but it is a lot, lot more readable and checkable to use the same names and values that the called method does. (We can't use the same definition file, because they are stored in a ".h" file for the C++ and C# cannot understand those. However, what most people do is to read the ".h" file in a text editor, and automaticlly replace
#define SPI_GETPLATFORMTYPE 257 with
private const uint SPI_GETPLATFORMTYPE = 257; to make sure they are the same throughout! I know I do...
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
Manfred R. Bihy: "Looks as if OP is learning resistant."
|
|
|
|
|
That helps a great deal! This is the kind of stuff that I just can't seem to find in books. I figured the integers had a specific meaning, and that they weren't just randomly chosen. Thanks for providing me with the insight as to where they come from. Where could I find the C++ header to review?
|
|
|
|
|
Sorry - in this case I can't help: I've never needed SPI_GETPLATFORMTYPE!
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
Manfred R. Bihy: "Looks as if OP is learning resistant."
|
|
|
|
|
According to the documentation[^], the header file is Winuser.h. It says to include Windows.h so there may be some things declared in there that you need also.
On my system (W7 64bit with Visual Studio 2010 Ultimate) they can both be found in
C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Include\
|
|
|
|
|
Dave -
The documentation you refer to is for desktop, whereas I'm using this on a Windows Mobile platform. Not sure if that matters when it comes to the Winuser.h header. I'll take a look nonetheless. Thanks for the info.
Regards,
Scott
|
|
|
|
|
Not sure where this header will be on the system - I'll have a look. The documentation is here.
|
|
|
|
|
I have seen information on the web about how to access private methods and properties from outside of a PUBLIC class by using a public method that exposes only the specific property one is interested in. But how does one gain access outside of the class when the entire class is private?
Regards,
Scott
|
|
|
|
|
You don't. Private members are not available to consumers outside the class.
What are you trying to do?
|
|
|
|
|
Sure they are. You can use reflection, expression trees, etc. Thats not to say its recommended, but to flat out say you can't is incorrect.
|
|
|
|
|
Since reflection is excruciatingly slow, it would be nice to know what he's really trying to do with this. If speed is an issue, it's really not going to work very well.
If hyjaking someones work is the reason, well, you where I stand on that...
|
|
|
|
|
SledgeHammer01 wrote: Sure they are.
Cool, than it'd be very easy for you to write a code example. He's talking about a private class, which is not the thing below as you'd might expect;
namespace MyTest
{
private class Test
{
}
}
Try to compile that, and you'll get an error;
Compiler says: Elements defined in a namespace cannot be explicitly declared as private, protected, or protected internal.
This would be a private class;
static class Owner
{
private class SomeClass
{
private string SomeMethod()
{
return "Hello world";
}
}
}
Standard reflection would look like the two lines below, which would both return NULL , not the Type "SomeClass";
Type someClassType = Type.GetType("SomeClass");
Type someClassType = Type.GetType("Owner.SomeClass");
Bastard Programmer from Hell
|
|
|
|
|
Cool, how do you think .NET Reflector sees private classes? Or ILSpy? You just need the FULLY qualified name of the class including assembly information.
|
|
|
|
|
SledgeHammer01 wrote: Cool, how do you think .NET Reflector sees private classes? Or ILSpy?
Easy to find out by using ILSpy on Reflector
I know that they're accessible, just wanted to point out that it might be somewhat harder than it initially looks.
SledgeHammer01 wrote: You just need the FULLY qualified name of the class including assembly information.
Type someClassType = Type.GetType("ConsoleApplication7.Owner.SomeClass, ConsoleApplication7, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null");
someClassType remains null .
Bastard Programmer from Hell
|
|
|
|
|
using System;
using System.Diagnostics;
using System.Reflection;
namespace ConsoleApplication7
{
static class Owner
{
private class SomeClass
{
private string SomeMethod()
{ return "Hello world"; }
}
}
class Program
{
static int Main(string[] args)
{
Type ownerClassType = Type.GetType(
"ConsoleApplication7.Owner, ConsoleApplication7, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null");
Type someClassType = ownerClassType.GetNestedType(
"SomeClass",
BindingFlags.Instance | BindingFlags.NonPublic);
Object someObject = Activator.CreateInstance(someClassType);
MethodInfo mi = someClassType.GetMethod(
"SomeMethod",
BindingFlags.Instance | BindingFlags.NonPublic);
Object result = mi.Invoke(someObject, null);
Console.WriteLine(result);
Console.ReadKey();
return 0;
}
}
}
Yup, works
Bastard Programmer from Hell
|
|
|
|