jwrapper.jwutils
Class JWWindowsOS

java.lang.Object
  extended by jwrapper.jwutils.JWGenericOS
      extended by jwrapper.jwutils.JWWindowsOS

public class JWWindowsOS
extends JWGenericOS

Utility APIs for Windows


Nested Class Summary
 class JWWindowsOS.NetworkAdapterInfo
           
 class JWWindowsOS.OSVersionInfo
           
static class JWWindowsOS.RDPSessionInfo
           
 
Constructor Summary
JWWindowsOS()
           
 
Method Summary
 void createShortcut(java.io.File linkfile, java.io.File target)
           
 void createShortcut(java.io.File linkfile, java.io.File target, java.lang.String args)
           
 void createShortcut(java.io.File linkfile, java.lang.String linkDesc, java.io.File target, java.lang.String args, java.io.File icon, int iconIndex)
           
 void createShortcutWithAppID(java.io.File linkfile, java.io.File target, java.lang.String appID)
           
 void createShortcutWithAppID(java.io.File linkfile, java.io.File target, java.lang.String args, java.lang.String appID)
           
 void createShortcutWithAppID(java.io.File linkfile, java.lang.String linkDesc, java.io.File target, java.lang.String args, java.io.File icon, int iconIndex, java.lang.String appID)
           
 void createWebShortcut(java.io.File linkfile, java.lang.String targetURL)
           
 void createWebShortcut(java.io.File linkfile, java.lang.String targetURL, java.io.File iconFile, int iconIndex)
           
 void deleteShortcut(java.io.File linkfile)
           
 void deleteWebShortcut(java.io.File linkfile)
           
 java.lang.String[] getAllConsoleUsers()
          Get the console user (the user logged into the console session)
 java.lang.String getAllUsersStartMenuProgramsFolder()
          This is language specific in XP so cannot easily be recreated based on environment variables E.g.
 java.io.File getAppStartMenuFolder()
          Get the start menu folder for the app bundle (will return current user or all users folder depending on install type for the bundle).
 int[] getCaretLocation()
          Get the caret (text cursor) location
 java.lang.String getEnvironmentVariable(java.lang.String name)
          Get a Windows environment variable
 java.lang.String getEnvShortPath(java.lang.String env)
          Return the value of the path referenced by the environment variable env, and convert to 8.3 short path format if possible.
 java.lang.String getHostname()
           
 java.lang.String getLoggedOnUsername()
          Get the username for the currently logged on session that this JVM is running in
 java.lang.String getLoggedOnUserSID()
          Get the SID of the user that is currently logged in
 int[] getMouseLocation()
          Get the mouse pointer location
 JWWindowsOS.NetworkAdapterInfo[] getNetworkInfo()
           
 java.lang.String getOSName()
          Return the OS name - utility for getting accurate OS names even with older JVMs.
 java.lang.String getOSNameWithBitness()
          Return the OS name with x86 for 32bit systems and x64 for 64bit systems
 JWWindowsOS.OSVersionInfo getOSVersionInfo()
          Return Windows specific versioning information
 JWWindowsOS.RDPSessionInfo[] getRDPSessionInfos()
           
static java.lang.String getRequestedURL()
          Returns the requested URL if this application was launched using a URL handler
 java.lang.String getShortPathFormatFor(java.lang.String fullPath)
          Returns a 8.3 formatted short path name for the given full path.
 java.io.File getStartMenuFolder(java.lang.String group)
          Get a start menu folder, or the start menu itself if group is null
 java.lang.String getUserStartMenuProgramsFolder()
          This is language specific in XP so cannot easily be recreated based on environment variables E.g.
static JWWindowsOS getWindowsInstance()
           
 boolean is64BitWindowsOS()
          Return true if this Windows OS is 64 bit
 boolean isProcessDPIAware()
          Return true of the process is set as DPI aware.
 boolean killProcess(int pid)
           
 void makeCurrentProcessHighPriority()
          Make the currently running JVM a high priority process
 void makeCurrentProcessLowPriority()
          Make the currently running JVM a low priority process
 void makeCurrentProcessNormalPriority()
          Make the currently running JVM a normal priority process
static void registerURLSchemeForVirtualApp(java.lang.String schemeProtocol, java.lang.String virtualApp)
           
 void setFrameAlwaysOnTop(java.awt.Frame window)
          Set a Java Frame to be 'always on top' (in the Windows sense - the Frame will be kept on top of other windows)
 void setWindowAlwaysOnTop(java.awt.Window window)
          Set a Java Window to be 'always on top' (in the Windows sense - the Window will be kept on top of other windows)
 boolean setWindowsAppID(java.lang.String appID)
          Set the Windows App ID - used to group processes together by application ID.
 
Methods inherited from class jwrapper.jwutils.JWGenericOS
getCurrentProcessID, getInstance, getOSVersion, setCurrentDirectory, setReadableForAllUsers, setReadableForAllUsersAndWait, setWritableForAllUsers, setWritableForAllUsersAndWait, terminateProcess
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JWWindowsOS

public JWWindowsOS()
Method Detail

createShortcut

public void createShortcut(java.io.File linkfile,
                           java.io.File target)
                    throws java.io.IOException
Throws:
java.io.IOException

createShortcut

public void createShortcut(java.io.File linkfile,
                           java.io.File target,
                           java.lang.String args)
                    throws java.io.IOException
Throws:
java.io.IOException

createShortcut

public void createShortcut(java.io.File linkfile,
                           java.lang.String linkDesc,
                           java.io.File target,
                           java.lang.String args,
                           java.io.File icon,
                           int iconIndex)
                    throws java.io.IOException
Throws:
java.io.IOException

createShortcutWithAppID

public void createShortcutWithAppID(java.io.File linkfile,
                                    java.io.File target,
                                    java.lang.String appID)
                             throws java.io.IOException
Throws:
java.io.IOException

createShortcutWithAppID

public void createShortcutWithAppID(java.io.File linkfile,
                                    java.io.File target,
                                    java.lang.String args,
                                    java.lang.String appID)
                             throws java.io.IOException
Throws:
java.io.IOException

createShortcutWithAppID

public void createShortcutWithAppID(java.io.File linkfile,
                                    java.lang.String linkDesc,
                                    java.io.File target,
                                    java.lang.String args,
                                    java.io.File icon,
                                    int iconIndex,
                                    java.lang.String appID)
                             throws java.io.IOException
Throws:
java.io.IOException

createWebShortcut

public void createWebShortcut(java.io.File linkfile,
                              java.lang.String targetURL)
                       throws java.io.IOException
Throws:
java.io.IOException

createWebShortcut

public void createWebShortcut(java.io.File linkfile,
                              java.lang.String targetURL,
                              java.io.File iconFile,
                              int iconIndex)
                       throws java.io.IOException
Throws:
java.io.IOException

deleteShortcut

public void deleteShortcut(java.io.File linkfile)
                    throws java.io.IOException
Throws:
java.io.IOException

deleteWebShortcut

public void deleteWebShortcut(java.io.File linkfile)
                       throws java.io.IOException
Throws:
java.io.IOException

getAllConsoleUsers

public java.lang.String[] getAllConsoleUsers()
Get the console user (the user logged into the console session)

Specified by:
getAllConsoleUsers in class JWGenericOS
Returns:

getAllUsersStartMenuProgramsFolder

public java.lang.String getAllUsersStartMenuProgramsFolder()
This is language specific in XP so cannot easily be recreated based on environment variables E.g. C:\Documents and Settings\All Users\Start Menu\Programs


getAppStartMenuFolder

public java.io.File getAppStartMenuFolder()
Get the start menu folder for the app bundle (will return current user or all users folder depending on install type for the bundle). Will return the app folder (Start Menu/Programs/)


getCaretLocation

public int[] getCaretLocation()
Get the caret (text cursor) location

Returns:
an int array where index 0 = X position and index 1 = Y position

getEnvironmentVariable

public java.lang.String getEnvironmentVariable(java.lang.String name)
Get a Windows environment variable

Parameters:
name - the name of the environment variable
Returns:

getEnvShortPath

public java.lang.String getEnvShortPath(java.lang.String env)
Return the value of the path referenced by the environment variable env, and convert to 8.3 short path format if possible.


getHostname

public java.lang.String getHostname()
Overrides:
getHostname in class JWGenericOS

getLoggedOnUsername

public java.lang.String getLoggedOnUsername()
Get the username for the currently logged on session that this JVM is running in


getLoggedOnUserSID

public java.lang.String getLoggedOnUserSID()
Get the SID of the user that is currently logged in


getMouseLocation

public int[] getMouseLocation()
Get the mouse pointer location

Returns:
an int array where index 0 = X position and index 1 = Y position

getNetworkInfo

public JWWindowsOS.NetworkAdapterInfo[] getNetworkInfo()

getOSName

public java.lang.String getOSName()
Description copied from class: JWGenericOS
Return the OS name - utility for getting accurate OS names even with older JVMs.

Overrides:
getOSName in class JWGenericOS

getOSNameWithBitness

public java.lang.String getOSNameWithBitness()
Description copied from class: JWGenericOS
Return the OS name with x86 for 32bit systems and x64 for 64bit systems

Overrides:
getOSNameWithBitness in class JWGenericOS

getOSVersionInfo

public JWWindowsOS.OSVersionInfo getOSVersionInfo()
Return Windows specific versioning information


getRDPSessionInfos

public JWWindowsOS.RDPSessionInfo[] getRDPSessionInfos()

getRequestedURL

public static java.lang.String getRequestedURL()
Returns the requested URL if this application was launched using a URL handler

Returns:
the request URL or null if none exists.

getShortPathFormatFor

public java.lang.String getShortPathFormatFor(java.lang.String fullPath)
Returns a 8.3 formatted short path name for the given full path.


getStartMenuFolder

public java.io.File getStartMenuFolder(java.lang.String group)
Get a start menu folder, or the start menu itself if group is null

Parameters:
group - the sub-folder to create in the start menu, or null if the root start menu folder
Returns:

getUserStartMenuProgramsFolder

public java.lang.String getUserStartMenuProgramsFolder()
This is language specific in XP so cannot easily be recreated based on environment variables E.g. C:\Documents and Settings\Username\Start Menu\Programs


getWindowsInstance

public static JWWindowsOS getWindowsInstance()

is64BitWindowsOS

public boolean is64BitWindowsOS()
Return true if this Windows OS is 64 bit

Returns:

isProcessDPIAware

public boolean isProcessDPIAware()
Return true of the process is set as DPI aware. False otherwise.


killProcess

public boolean killProcess(int pid)

makeCurrentProcessHighPriority

public void makeCurrentProcessHighPriority()
Make the currently running JVM a high priority process


makeCurrentProcessLowPriority

public void makeCurrentProcessLowPriority()
Make the currently running JVM a low priority process


makeCurrentProcessNormalPriority

public void makeCurrentProcessNormalPriority()
Make the currently running JVM a normal priority process


registerURLSchemeForVirtualApp

public static void registerURLSchemeForVirtualApp(java.lang.String schemeProtocol,
                                                  java.lang.String virtualApp)
                                           throws java.io.IOException,
                                                  java.lang.InterruptedException
Throws:
java.io.IOException
java.lang.InterruptedException

setFrameAlwaysOnTop

public void setFrameAlwaysOnTop(java.awt.Frame window)
Set a Java Frame to be 'always on top' (in the Windows sense - the Frame will be kept on top of other windows)


setWindowAlwaysOnTop

public void setWindowAlwaysOnTop(java.awt.Window window)
Set a Java Window to be 'always on top' (in the Windows sense - the Window will be kept on top of other windows)


setWindowsAppID

public boolean setWindowsAppID(java.lang.String appID)
Set the Windows App ID - used to group processes together by application ID.

Returns:
true if the call succeeds.