package de.frankbuss.jni;

public class WinAccess {
	public final static int VER_PLATFORM_WIN32s = 0;
	public final static int VER_PLATFORM_WIN32_WINDOWS = 1;
	public final static int VER_PLATFORM_WIN32_NT = 2;

	private static int windowsPlatformId;
	
	private native static void initWindowsPlatformId();
	
	public static int getWindowsPlatformId() {
		return windowsPlatformId;
	}
	
	public native static String getenv(String name);

	public native static void clrscr();
	
	public static String getWindowsPlatform() {
		switch (windowsPlatformId) {
			case VER_PLATFORM_WIN32s:
				return "Win32s on Windows 3.1";
			case VER_PLATFORM_WIN32_WINDOWS:
				return "Win32 on Windows 95 or Windows 98";
			case VER_PLATFORM_WIN32_NT:
				return "Win32 on Windows NT/Windows 2000";
		}
		return "unknown version";
	}
 
 	/**
 	 * Tests for the native methods.
 	 */
	public static void main(String args[]) {
		clrscr();
		System.out.println(getWindowsPlatform());
		System.out.println(getenv("windir"));
	}

	static {
		System.loadLibrary("WinAccess");
		initWindowsPlatformId();
	}
}

