package com.mindprod.volser;
/**
* Access Windows 32-bit volume serial number. Uses JNI native C++/ASM code that only works on Vista, XP, Windows 2000.
* Do not confuse this with the case-sensitive volume label.
*
* @author Roedy Green, Canadian Mind Products
* @version 1.0 2007-12-17
*/
public final class Volser
{
/**
* true if you want to include the debugging harness code.
*/
private static final boolean DEBUGGING = true;
/**
* undisplayed embedded copyright notice
*/
public static final String EMBEDDED_COPYRIGHT =
"copyright (c) 2007-2008 Roedy Green, Canadian Mind Products, http://mindprod.com";
/**
* undisplayed embedded release date
*/
private static final String RELEASE_DATE = "2007-12-17";
/**
* undisplayed embedded version string.
*/
public static final String VERSION_STRING = "1.0";
/**
* Get the volume serial number.
*
* @param rootPath drive with trailing colon and backslash e.g. "C:\\". Can also be a network drive.
* @return 32-bit volume serial number as an int. Normally displayed in hex in two pieces separated by a colon or
* dash.
*/
public static native int getVolser( String rootPath );
static
{
System.loadLibrary( "nativevolser" );
}
/**
* test debug harness
*
* @param args not used
*/
public static void main( String[] args )
{
if ( DEBUGGING )
{
final int volser = Volser.getVolser( "C:\\" );
System.out.println( Integer.toHexString( volser ) );
final int high = volser >>> 16;
final int low = volser & 0xffff;
final String hexVolser = Integer.toHexString( high ) + ":" + Integer.toHexString( low );
System.out.println( "4-byte Volume serial number for drive C: is " + hexVolser );
}
}
}