Servertec
Foundation Classes
1.3.3 09/04/2005

stec.sfc.Win32
Class System

java.lang.Object
  extended by stec.sfc.Win32.System

public final class System
extends java.lang.Object

Used to logoff, reboot, shutdown and poweroff the computer. Also used to specify how errors are handled, to generate a tone on the speaker or play a registered wave sound and to get and set the last error.

Since:
1.0.0 01/07/2001

Constructor Summary
System()
           
 
Method Summary
static void abortSystemShutdown(java.lang.String computer_name)
          Attempts to stop the named system from being shutdown or restarted.
static void beep(int type)
          Plays the registered wave sound.
static void beep(int frequency, int duration)
          On Windows 9x/Me plays the standard sound and on Windows NT/2000/XP plays a sound of specified frequency and duration on the system's speaker.
static java.lang.String expandEnvironmentVariables(java.lang.String s)
          Returns a String with environment variables replaced with associated values.
static java.lang.String getAccountName(java.lang.String domain_name, java.lang.String sid)
          Returns the account name for the given SID from the specified domain name.
static int getBuildNumber()
          Returns the build number.
static java.lang.String getCommandLine()
          Returns the command line specified to run the current program.
static java.lang.String getComputerName()
          Returns the name of the computer.
static int getLastError()
          Returns the last error code.
static int getMajorVersion()
          Returns major version number.
static int getMinorVersion()
          Returns minor version number.
static int getVersion()
          Deprecated. This method method has been superseded by getMajorVersion(), getMinorVersion() and getBuildNumber().
static void logoff(boolean force)
          Shutdowns all processes and logs the user off.
static void poweroff(boolean force)
          Shutdowns the system and then turns the power off.
static void reboot(boolean force)
          Shutdowns all processes and then restarts the computer.
static void reboot(java.lang.String computer_name, java.lang.String message, long timeout, boolean force)
          Displays the Reboot dialog for the specified amount of time, then shutdowns all processes and restarts the specified computer.
static int setErrorMode(int mode)
          Sets how errors are handled by the system.
static void setLastError(int error_code)
          Sets the last error code.
static void shutdown(boolean force)
          Shutdowns the system and then turns the power off.
static void shutdown(java.lang.String computer_name, java.lang.String message, long timeout, boolean force)
          Displays the Shutdown dialog for the specified amount of time, then shutdowns all processes and shutdowns the specified computer.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

System

public System()
Method Detail

poweroff

public static final void poweroff(boolean force)
                           throws Win32Exception
Shutdowns the system and then turns the power off.

Not all systems support power-off.

Parameters:
force - whether to force the shutdown and power off.

Use only in emergencies. Setting this to true will cause all running applications to be abruptly terminated and may result in data corruption or loss.

Throws:
Win32Exception - if any error occurs.

logoff

public static final void logoff(boolean force)
                         throws Win32Exception
Shutdowns all processes and logs the user off.

Parameters:
force - whether to force the shutdown and user off.

Use only in emergencies. Setting this to true will cause all running applications to be abruptly terminated and may result in data corruption or loss.

Throws:
Win32Exception - if any error occurs.

reboot

public static final void reboot(boolean force)
                         throws Win32Exception
Shutdowns all processes and then restarts the computer.

Parameters:
force - whether to force the shutdown and restart.

Use only in emergencies. Setting this to true will cause all running applications to be abruptly terminated and may result in data corruption or loss.

Throws:
Win32Exception - if any error occurs.

shutdown

public static final void shutdown(boolean force)
                           throws Win32Exception
Shutdowns the system and then turns the power off.

Parameters:
force - whether to force the shutdown and power off.

Use only in emergencies. Setting this to true will cause all running applications to be abruptly terminated and may result in data corruption or loss.

Throws:
Win32Exception - if any error occurs.

reboot

public static final void reboot(java.lang.String computer_name,
                                java.lang.String message,
                                long timeout,
                                boolean force)
                         throws Win32Exception
Displays the Reboot dialog for the specified amount of time, then shutdowns all processes and restarts the specified computer.

Requires Windows NT/2000/XP.

Parameters:
computer_name - the name of the computer to restart.
message - the message to display.
timeout - the amount of time in seconds to display the message.
force - whether to force the shutdown and restart.

Use only in emergencies. Setting this to true will cause all running applications to be abruptly terminated and may result in data corruption or loss.

Throws:
Win32Exception - if any error occurs.

shutdown

public static final void shutdown(java.lang.String computer_name,
                                  java.lang.String message,
                                  long timeout,
                                  boolean force)
                           throws Win32Exception
Displays the Shutdown dialog for the specified amount of time, then shutdowns all processes and shutdowns the specified computer.

Requires Windows NT/2000/XP.

Parameters:
computer_name - the name of the computer to shutdown.
message - the message to display.
timeout - the amount of time in seconds to display the message.
force - whether to force the shutdown and power-off.

Use only in emergencies. Setting this to true will cause all running applications to be abruptly terminated and may result in data corruption or loss.

Throws:
Win32Exception - if any error occurs.

abortSystemShutdown

public static final void abortSystemShutdown(java.lang.String computer_name)
                                      throws Win32Exception
Attempts to stop the named system from being shutdown or restarted.

Requires Windows NT/2000/XP.

Parameters:
computer_name - the name of the computer.
Throws:
Win32Exception - if any error occurs.

getComputerName

public static final java.lang.String getComputerName()
                                              throws Win32Exception
Returns the name of the computer.

Returns:
the computer's name.
Throws:
Win32Exception - if any error occurs.

getVersion

public static final int getVersion()
Deprecated. This method method has been superseded by getMajorVersion(), getMinorVersion() and getBuildNumber().

Returns the version number of the operating system.

Returns:
the version number.

Platform High-order bit Low-order bit
Windows NT/2000/XP 0 3, 4, or 5
Windows 95/98 1 4
Windows 3.1 with Win32s 1 3

beep

public static final void beep(int type)
                       throws Win32Exception
Plays the registered wave sound.

Parameters:
type - the wave sound defined in BeepType.
Throws:
Win32Exception - if any error occurs.
Since:
1.1.0 11/18/2001

beep

public static final void beep(int frequency,
                              int duration)
                       throws Win32Exception
On Windows 9x/Me plays the standard sound and on Windows NT/2000/XP plays a sound of specified frequency and duration on the system's speaker.

Parameters:
frequency - the frequency in hertz. A value is the range 37 through 32,767
duration - the duration in milliseconds
Throws:
Win32Exception - if any error occurs.
Since:
1.1.0 11/18/2001

setErrorMode

public static final int setErrorMode(int mode)
                              throws Win32Exception
Sets how errors are handled by the system.

Parameters:
mode - the error mode defined in ErrorMode.
Returns:
the previous error mode defined in ErrorMode.
Throws:
Win32Exception - if any error occurs.
Since:
1.1.0 11/18/2001

getLastError

public static final int getLastError()
Returns the last error code.

Returns:
the last error code.
Since:
1.1.0 11/18/2001

setLastError

public static final void setLastError(int error_code)
Sets the last error code.

Parameters:
error_code - the last error code.
Since:
1.1.0 11/18/2001

getCommandLine

public static final java.lang.String getCommandLine()
Returns the command line specified to run the current program.

Returns:
the command line.
Since:
1.1.0 11/18/2001

expandEnvironmentVariables

public static final java.lang.String expandEnvironmentVariables(java.lang.String s)
                                                         throws Win32Exception
Returns a String with environment variables replaced with associated values.

Parameters:
s - the String to expand.
Returns:
the expanded String.
Throws:
Win32Exception - if any error occurs.
Since:
1.1.0 11/18/2001

getMinorVersion

public static final int getMinorVersion()
Returns minor version number.

Returns:
the minor version number.
Since:
1.1.0 11/18/2001

getMajorVersion

public static final int getMajorVersion()
Returns major version number.

Returns:
the major version number.
Since:
1.1.0 11/18/2001

getBuildNumber

public static final int getBuildNumber()
Returns the build number.

Returns:
the build number.
Since:
1.1.0 11/18/2001

getAccountName

public static final java.lang.String getAccountName(java.lang.String domain_name,
                                                    java.lang.String sid)
                                             throws Win32Exception
Returns the account name for the given SID from the specified domain name.

Parameters:
domain_name - - the name of the domain. null for the local computer.
sid - the SID. In the form: S-revision-identity_authority{-subauthority}...
Returns:
the account name. null if none.
Throws:
Win32Exception - if any error occurs.
Since:
1.3.1 09/07/2004

Servertec
Foundation Classes
1.3.3 09/04/2005

Copyright © 2001-2005 Servertec. All rights reserved.