-
October 20th, 2003, 01:58 AM
#1
How to read the HD Serial Number
Hello,
for registry reasons, I want to read an unique ID from the computer that runs my app.
I think reading HD serial number will be enough but I don't know how to do this by C#.
Please, send me some information about this.
Please, help me!
-
October 20th, 2003, 02:58 PM
#2
i'm also interested in this matter
is there anyone who could help us?
Code:
using System.Logik;
-
October 20th, 2003, 04:01 PM
#3
like this i knocked up for you? ....
Code:
using System.Runtime.InteropServices;
[DllImport("kernel32.dll")]
private static extern int GetVolumeInformation(string PathName, System.Text.StringBuilder VolumeNameBuffer, int VolumeNameSize, ref int VolumeSerialNumber, ref int MaximumComponentLength, ref int FileSystemFlags, System.Text.StringBuilder FileSystemNameBuffer, int FileSystemNameSize);
private[/COLOR] void button1_Click(object sender, System.EventArgs e)
{
int result=0;
int zero=new int();
string drive=System.IO.Directory.GetParent(Application.ExecutablePath).Root.ToString();
System.Text.StringBuilder volume=new System.Text.StringBuilder(256);
System.Text.StringBuilder buffer=new System.Text.StringBuilder(256);
GetVolumeInformation(drive,volume,volume.Capacity,ref result,ref zero,ref zero,buffer,buffer.Capacity);
MessageBox.Show(result.ToString());
}
hope it's what you need
string Signature = Censored;
-
October 20th, 2003, 04:06 PM
#4
BTW, if you mean this serial number:
C:\umc\cpu3>dir /p
Volume in drive C has no label.
Volume Serial Number is 98D8-23D2
that number is quite easy to change, even without reformatting, so its not too good for security. Also.. if you're keying off that number to get application data, then if the user upgrades their harddrive, does that mean your program stops working and must be reinstalled?
-
October 21st, 2003, 02:23 PM
#5
how can the serial number be changed? what c# functions or winAPI functions are used for this?
Code:
using System.Logik;
-
October 21st, 2003, 02:59 PM
#6
Originally posted by logik
how can the serial number be changed? what c# functions or winAPI functions are used for this?
I'm not sure.. but I've got a program that changes it without reformatting, or even rebooting windows. After noticing that 4 people here had the same number, I'm thinking it's not really the serial number of the drive itself (which makes sense.. different manufacturers wouldn't use the same format).
-
October 22nd, 2003, 04:45 AM
#7
Originally posted by dynamic_sysop
like this i knocked up for you? ....
Code:
using System.Runtime.InteropServices;
[DllImport("kernel32.dll")]
private static extern int GetVolumeInformation(string PathName, System.Text.StringBuilder VolumeNameBuffer, int VolumeNameSize, ref int VolumeSerialNumber, ref int MaximumComponentLength, ref int FileSystemFlags, System.Text.StringBuilder FileSystemNameBuffer, int FileSystemNameSize);
private[/COLOR] void button1_Click(object sender, System.EventArgs e)
{
int result=0;
int zero=new int();
string drive=System.IO.Directory.GetParent(Application.ExecutablePath).Root.ToString();
System.Text.StringBuilder volume=new System.Text.StringBuilder(256);
System.Text.StringBuilder buffer=new System.Text.StringBuilder(256);
GetVolumeInformation(drive,volume,volume.Capacity,ref result,ref zero,ref zero,buffer,buffer.Capacity);
MessageBox.Show(result.ToString());
}
hope it's what you need
But when you have shared the executable of this code your code does not work, because of security reasons
can u solve this problem...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|