Reading HDD serialNo  
Author Message
ezelsari85





PostPosted: 2006-3-31 20:16:00 Top

java-programmer, Reading HDD serialNo Hi all,

Could you help me please to find out how to read the harddisk serial
number in java ?

Thanks a lot!!

 
ezelsari85





PostPosted: 2006-3-31 20:31:00 Top

java-programmer >> Reading HDD serialNo
No matter learning how to do it in C or Java . I want to get the source
code of reading the serial number of HDD.
Is there another way to find the source code of reading serial number
or the HDD?

thanx!!

 
Gordon Beaton





PostPosted: 2006-3-31 21:21:00 Top

java-programmer >> Reading HDD serialNo On 31 Mar 2006 04:16:21 -0800, email***@***.com wrote:
> Could you help me please to find out how to read the harddisk serial
> number in java ?

Three simple steps:

1: learn how to do it in C
2: learn about JNI
3: write a native method that invokes the code from step 1

/gordon

--
[ do not email me copies of your followups ]
g o r d o n + n e w s @ b a l d e r 1 3 . s e
 
 
Gordon Beaton





PostPosted: 2006-3-31 21:39:00 Top

java-programmer >> Reading HDD serialNo On 31 Mar 2006 04:30:45 -0800, email***@***.com wrote:
> No matter learning how to do it in C or Java . I want to get the
> source code of reading the serial number of HDD. Is there another
> way to find the source code of reading serial number or the HDD?

Use Runtime.exec(). Run "vol" on windows or "hdparm -i /dev/hda" as
root on Linux. Parse the output to get the serial number.

Hope that the system doesn't have SCSI disks, which don't have serial
numbers.

Google "HDD serial number" would have found this information for you.

/gordon

--
[ do not email me copies of your followups ]
g o r d o n + n e w s @ b a l d e r 1 3 . s e
 
 
ezelsari85





PostPosted: 2006-3-31 21:46:00 Top

java-programmer >> Reading HDD serialNo thank you!!
I am trying to import the source code to java by using JNI.

 
 
James McGill





PostPosted: 2006-4-1 0:24:00 Top

java-programmer >> Reading HDD serialNo On Fri, 2006-03-31 at 05:46 -0800, email***@***.com wrote:
> thank you!!
> I am trying to import the source code to java by using JNI.
>

That might be more work than you're anticipating. Make a JNI "Hello
World" first.

 
 
Roedy Green





PostPosted: 2006-4-1 2:17:00 Top

java-programmer >> Reading HDD serialNo On 31 Mar 2006 04:16:21 -0800, email***@***.com wrote, quoted or
indirectly quoted someone who said :

>Could you help me please to find out how to read the harddisk serial
>number in java ?

If you can't find it predone, I would be willing to research and write
the code for you for a fee. The trick is to do it in C and provide JNI
glue. I did it years ago in DOS using assembler. However, over the
years security closes holes. It may not be possible to do it anymore
unless the OS has an API for it. Getting the volser should be easier
-- the name you assign yourself to the volume.

I presume you are doing this for some sort of copy protection scheme.
You might be interested in http://mindprod.com/products1.html#PENTIUM
which will give you the Pentium CPU serial number.

--
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
 
 
Real Gagnon





PostPosted: 2006-4-1 7:06:00 Top

java-programmer >> Reading HDD serialNo email***@***.com wrote in news:1143812782.462105.118020
@g10g2000cwb.googlegroups.com:

> thank you!!
> I am trying to import the source code to java by using JNI.
>

For Windows, use the following API wrapped in a JNI routine :

FUNCTION long GetVolumeInformationA &
(string lpRootPathName, REF string lpVolumeNameBuffer,
long nVolumeNameSize,
REF long lpVolumeSerialNumber, REF long lpMaximumComponentLength,
REF long lpFileSystemFlags, REF string lpFileSystemNameBuffer,
long nFileSystemNameSize)
LIBRARY "Kernel32.dll"

Bye.

--
Real Gagnon from Quebec, Canada
* Looking for Java or PB code examples ? Visit Real's How-to
* http://www.rgagnon.com/howto.html