How to get the Client Hard Disk No Using C#

Hello,

i need to validate the client using his hard disk number. So how to get the Client hard disk number using c# language.

thanks in advance
sen007
sen007Asked:
Who is Participating?
 
moduloCommented:
PAQed, with points refunded (70)

modulo
Community Support Moderator
0
 
AerosSagaCommented:
Public Declare Function GetVolumeSerialNumber Lib "kernel32" Alias "GetVolumeInformationA" (ByVal

lpRootPathName As String, ByVal lpVolumeNameBuffer As Long, ByVal nVolumeNameSize As Long,

lpVolumeSerialNumber As Long, ByVal lpMaximumComponentLength As Long, ByVal lpFileSystemFlags As

Long, ByVal lpFileSystemNameBuffer As Long, ByVal nFileSystemNameSize As Long) As Long

Public Function VolumeSerial(DriveLetter) As Long
    Dim Serial As Long
    Call GetVolumeSerialNumber(UCase(DriveLetter) & ":\", 0&, 0&, Serial, 0&, 0&, 0&, 0&)
    VolumeSerial = Serial
End Function

 
Example Usage

MsgBox VolumeSerial("C")

I am currently trying to convert this to C# for you

Regards,

Aeros
0
 
AerosSagaCommented:
Heres the function part:

public long VolumeSerial(object DriveLetter)
{
 long Serial;
 GetVolumeSerialNumber(UCase(DriveLetter) + ":\", 0, 0, Serial, 0, 0, 0, 0);
 VolumeSerial = Serial;
}
0
Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

 
AerosSagaCommented:
Heres the rest of it:

public class abcd
{
[System.Runtime.InteropServices.DllImport("kernel32", EntryPoint="GetVolumeInformationA")]
public long GetVolumeSerialNumber(string lpRootPathName, long lpVolumeNameBuffer, long nVolumeNameSize, long lpVolumeSerialNumber, long lpMaximumComponentLength, long lpFileSystemFlags, long lpFileSystemNameBuffer, long nFileSystemNameSize);
0
 
raterusCommented:
I don't see how that will get you the "client" hard-disk number, maybe the servers...  Getting anything like that of the client would be off limits from an asp.net application.
0
 
AerosSagaCommented:
I don't believe that will be possible, as it is a security risk

0
 
raterusCommented:
yeah, I think that is what the author is after.  To do it using your code, he'll probably have to embed a client-side control in IE.

http://msdn.microsoft.com/msdnmag/issues/02/01/UserCtrl/default.aspx
0
 
AerosSagaCommented:
wasn't aware of the safe initizlization for activeX

http://msdn.microsoft.com/workshop/components/activex/safety.asp
0
 
raterusCommented:
Here is probably a better way to authenticate clients if you are interested, all the stuff Aeros and I were talking about is fairly bloated if you are dealing with real clients.  (I sure wouldn't want to download a program to access their website..who knows what "else" they are looking at)

http://support.microsoft.com/default.aspx?scid=kb;EN-US;315588
0
 
crescendoCommented:
Just hang around your local high school and ask a spotty teenager which exploit to use...
0
 
crescendoCommented:
No offence intended to Aerosaga, who's worked hard on this one, but his solution doesn't actually solve the problem as it gives the server's disk serial number, not the client's.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.