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!
Printable View
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!
i'm also interested in this matter :)
is there anyone who could help us?
like this i knocked up for you? ....
hope it's what you need :)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());
}
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?
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).Quote:
Originally posted by logik
how can the serial number be changed? what c# functions or winAPI functions are used for this?
Quote:
Originally posted by dynamic_sysop
like this i knocked up for you? ....
hope it's what you need :)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());
}
But when you have shared the executable of this code your code does not work, because of security reasons
can u solve this problem...