com.neva
Class Win32PlatformFunction

java.lang.Object
  |
  +--com.neva.Win32PlatformFunction

public class Win32PlatformFunction
extends java.lang.Object


Constructor Summary
Win32PlatformFunction()
          Creates a Win32PlatformFunction.
Win32PlatformFunction(java.lang.String library, java.lang.String function)
          Creates a Win32PlatformFunction.
 
Method Summary
static void Beep(int freq, int dura)
          Generates simple tones on the speaker.
static boolean CloseHandle(int handle)
          Closes an open object handle.
static int CreateEvent(java.lang.String name, boolean state)
          Creates a named or unnamed event object.
static int CreateProcess(java.lang.String commandLine)
          Creates a new process.
static int CreateProcess(java.lang.String commandLine, boolean showWindow)
          Creates a new process.
static int CreateProcess(java.lang.String commandLine, boolean showWindow, int[] id)
          Creates a new process.
static int[] EnumerateWindows()
          Answers an array of window handles
static java.lang.String ExpandEnvironmentStrings(java.lang.String in)
          Replaces environment-variable strings in in by their values
static java.lang.String GetClipboardText()
          Copies text from Clipboard and aswers it.
static java.lang.String GetEnvironmentVariable(java.lang.String env)
          Answers the value of the specified variable from the process' environment block.
static java.lang.String GetOSVersion(int[] osver)
          Answers extended information about the version of the OS that is currently running.
static java.lang.String GetWindowText(int hwnd)
          Answers the specified window's title
static int GetWindowThreadProcessId(int hwnd)
          Answers the thread id of the thread that created the specified window
static int MessageBox(int owner, java.lang.String message, java.lang.String title, int style)
          Displays modeless message box.
static int OpenEvent(java.lang.String name)
          Obtains a handle of an existing named event object.
static boolean Play(java.lang.String path)
          Plays WAV file.
static boolean Play(java.lang.String path, int how)
          Plays WAV file.
static com.neva.ExternalObject ReadFile(java.lang.String path)
          Opens a file with FILE_SHARE_READ attribute.Reads the file bytes.
static int RegCloseKey(int key)
          Closes the handle to the specified registry key.
static int RegCreateKey(int key, java.lang.String subkey, java.lang.String clazz, int accessMask, int options, int[] handle)
          Creates the specified registry key.
static int RegDeleteKey(int key, java.lang.String subkey)
          Deletes the specified registry key.
static int RegDeleteValue(int key, java.lang.String valueName)
          Removes a named value from the specified registry key.
static int RegOpenKey(int key, java.lang.String subkey, int accessMask, int[] handle)
          Opens the specified registry key.
static byte[] RegQueryValue(int key, java.lang.String valueName, int[] type)
          Retrieves the type and data for a specified value name.
static int RegSetValue(int key, java.lang.String valueName, byte[] data)
          Stores a byte array in the value field of an open registry key.
static int RegSetValue(int key, java.lang.String valueName, byte[] data, int type)
          Stores data in the value field of an open registry key.
static int RegSetValue(int key, java.lang.String valueName, int data)
          Stores integer data in the value field of an open registry key.
static int RegSetValue(int key, java.lang.String valueName, java.lang.String data)
           
static boolean SetClipboardText(java.lang.String data)
          Copies text to Clipboard.
static boolean SetEvent(int handle)
          Sets the state of the specified event object to signaled.
static int Wait(int handle, int howLong)
          Wrapper for Win32 WaitForSingleObject api.
static boolean WriteFile(java.lang.String path, byte[] data, int length)
          Opens a file exclusively.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Win32PlatformFunction

public Win32PlatformFunction()
Creates a Win32PlatformFunction.


Win32PlatformFunction

public Win32PlatformFunction(java.lang.String library,
                             java.lang.String function)
Creates a Win32PlatformFunction.

Method Detail

Beep

public static void Beep(int freq,
                        int dura)
                 throws java.lang.SecurityException
Generates simple tones on the speaker. The freq parameter specifies the frequency, in hertz, of the sound. The dura parameter specifies the duration, in milliseconds, of the sound.

java.lang.SecurityException

CloseHandle

public static boolean CloseHandle(int handle)
Closes an open object handle.

Parameters:
handle - specifies handle to object to close.
Returns:
a boolean that indicates whether the function was successful.

CreateEvent

public static int CreateEvent(java.lang.String name,
                              boolean state)
Creates a named or unnamed event object.

Parameters:
name - specifies the name of the event object. If name is null, the event object is created without a name.
state - specifies the initial state of the event object.
Returns:
a handle to the event object. If the function fails, the return value is 0.

CreateProcess

public static int CreateProcess(java.lang.String commandLine)
                         throws java.lang.SecurityException
Creates a new process.

Parameters:
commandLine - specifies the command line to execute.
Returns:
zero when successful.
java.lang.SecurityException

CreateProcess

public static int CreateProcess(java.lang.String commandLine,
                                boolean showWindow)
                         throws java.lang.SecurityException
Creates a new process.

Parameters:
commandLine - specifies the command line to execute.
showWindow - specifies whether to show new process' main window or run it in minimized state.
Returns:
zero when successful.
java.lang.SecurityException

CreateProcess

public static int CreateProcess(java.lang.String commandLine,
                                boolean showWindow,
                                int[] id)
                         throws java.lang.SecurityException
Creates a new process.

Parameters:
commandLine - specifies the command line to execute.
showWindow - specifies whether to show new process' main window or run it in minimized state.
id - receives identification information about the new process: id[0] - the handle to the newly created process that can be used to perform operations on the process object; id[1] - the global process identifier that can be used to identify a process.
Returns:
zero when successful.
java.lang.SecurityException

EnumerateWindows

public static int[] EnumerateWindows()
                              throws java.lang.SecurityException
Answers an array of window handles

java.lang.SecurityException

ExpandEnvironmentStrings

public static java.lang.String ExpandEnvironmentStrings(java.lang.String in)
Replaces environment-variable strings in in by their values


GetClipboardText

public static java.lang.String GetClipboardText()
                                         throws java.lang.SecurityException
Copies text from Clipboard and aswers it.

java.lang.SecurityException

GetEnvironmentVariable

public static java.lang.String GetEnvironmentVariable(java.lang.String env)
                                               throws java.lang.SecurityException
Answers the value of the specified variable from the process' environment block. Answers null when fails.

Parameters:
env - specifies the environment variable.
Returns:
the value of the specified variable from the process' environment block. Answers null when fails.
java.lang.SecurityException

GetOSVersion

public static java.lang.String GetOSVersion(int[] osver)
                                     throws java.lang.SecurityException
Answers extended information about the version of the OS that is currently running.

Parameters:
osver - is used to return four integer that identify the major version number , the minor version number, the build number, the OS platform id
Returns:
a String that indicates the latest Service Pack installed.
java.lang.SecurityException

GetWindowText

public static java.lang.String GetWindowText(int hwnd)
                                      throws java.lang.SecurityException
Answers the specified window's title

Parameters:
hwnd - specifies native window handle
Returns:
window's title string
java.lang.SecurityException

GetWindowThreadProcessId

public static int GetWindowThreadProcessId(int hwnd)
                                    throws java.lang.SecurityException
Answers the thread id of the thread that created the specified window

java.lang.SecurityException

MessageBox

public static int MessageBox(int owner,
                             java.lang.String message,
                             java.lang.String title,
                             int style)
                      throws java.lang.SecurityException
Displays modeless message box.

Parameters:
message - specifies the message to be displayed.
title - specifies the message box title.
style - specifies the message box styles.
owner - specifies the window handle of the window that owns the message box. Owner set to zero creates modeless dialog.
java.lang.SecurityException

OpenEvent

public static int OpenEvent(java.lang.String name)
Obtains a handle of an existing named event object. $param name specifies the name of the event object. $return a handle to the event object. If the function fails, the return value is 0.


Play

public static boolean Play(java.lang.String path)
                    throws java.lang.SecurityException
Plays WAV file.

Parameters:
path - specifies file's path name.
Returns:
true if successful or false otherwise
java.lang.SecurityException

Play

public static boolean Play(java.lang.String path,
                           int how)
                    throws java.lang.SecurityException
Plays WAV file.

Parameters:
path - specifies file's path name.
how - specifies flags for playing the sound
Returns:
true if successful or false otherwise
java.lang.SecurityException

ReadFile

public static com.neva.ExternalObject ReadFile(java.lang.String path)
                                        throws java.lang.SecurityException
Opens a file with FILE_SHARE_READ attribute.Reads the file bytes.

Parameters:
path - specifies the name of the file.
Returns:
an ExternalObject that contains references to file's data. To retrieve data length, use length() in ExternalObject; to retrieve data bytes, use valueAsByteArray(int) in ExternalObject. Answers null if fails.
java.lang.SecurityException

RegCloseKey

public static int RegCloseKey(int key)
                       throws java.lang.SecurityException
Closes the handle to the specified registry key. If the function succeeds, the return value is 0. Otherwise a nonzero error code is returned.

java.lang.SecurityException

RegCreateKey

public static int RegCreateKey(int key,
                               java.lang.String subkey,
                               java.lang.String clazz,
                               int accessMask,
                               int options,
                               int[] handle)
                        throws java.lang.SecurityException
Creates the specified registry key. If the key already exists, the method opens it.

Parameters:
key - specifies a currently open key or any of the HKEY_* constants.
subkey - specifies the name of the subkey to create/open.
clazz - specifies the class of this key.
accessMask - specifies the desired security access for the key - a combination of the KEY_ACCESS_* constants.
options - specifies special options for the key (see REG_OPTION_* constants).
handle - is an int array of two elements. On return, the first element contains the key handle and the second element contains REG_CREATED_NEW_KEY or REG_OPENED_EXISTING_KEY.
Returns:
0 when the function succeeds. Otherwise a nonzero error code is returned.
java.lang.SecurityException

RegDeleteKey

public static int RegDeleteKey(int key,
                               java.lang.String subkey)
                        throws java.lang.SecurityException
Deletes the specified registry key.

Parameters:
key - specifies a currently open key or any of the HKEY_* constants.
subkey - specifies the name of the subkey to delete.
Returns:
0 if the function succeeds. Otherwise a nonzero error code is returned.
java.lang.SecurityException

RegDeleteValue

public static int RegDeleteValue(int key,
                                 java.lang.String valueName)
                          throws java.lang.SecurityException
Removes a named value from the specified registry key.

Parameters:
key - specifies the handle to an opened key.
valueName - specifies the name of the value.
Returns:
0 if the function succeeds. Otherwise a nonzero error code is returned.
java.lang.SecurityException

RegOpenKey

public static int RegOpenKey(int key,
                             java.lang.String subkey,
                             int accessMask,
                             int[] handle)
                      throws java.lang.SecurityException
Opens the specified registry key.

Parameters:
key - specifies a currently open key or any of the HKEY_* constants.
subkey - specifies the name of the subkey to open.
accessMask - specifies the desired security access for the opened key - a combination of the KEY_ACCESS_* constants.
handle - is an int array. On return, the handle to the opened key is returned in handle[0]
Returns:
0 if the function succeeds. Otherwise a nonzero error code is returned.
java.lang.SecurityException

RegQueryValue

public static byte[] RegQueryValue(int key,
                                   java.lang.String valueName,
                                   int[] type)
                            throws java.lang.SecurityException
Retrieves the type and data for a specified value name.

Parameters:
key - specifies the handle to an opened key.
valueName - specifies the name of the value to query.
type - receives the data type(REG_SZ, REG_EXPAND_SZ, REG_BINARY,REG_DWORD, REG_MULTI_SZ).
Returns:
if the function succeeds, the return value is a byte array that contains value's data. Otherwise null is returned.
java.lang.SecurityException

RegSetValue

public static int RegSetValue(int key,
                              java.lang.String valueName,
                              byte[] data)
                       throws java.lang.SecurityException
Stores a byte array in the value field of an open registry key.

Parameters:
key - specifies the handle to an opened key.
valueName - specifies the name of the value.
data - specifies a byte array to store.
Returns:
0 if the function succeeds. Otherwise a nonzero error code is returned.
java.lang.SecurityException

RegSetValue

public static int RegSetValue(int key,
                              java.lang.String valueName,
                              byte[] data,
                              int type)
                       throws java.lang.SecurityException
Stores data in the value field of an open registry key.

Parameters:
key - specifies the handle to an opened key.
valueName - specifies the name of the value.
data - specifies data to store.
type - specifies data type (REG_SZ, REG_EXPAND_SZ, REG_BINARY, REG_DWORD, REG_MULTI_SZ).
Returns:
0 if the function succeeds. Otherwise a nonzero error code is returned
java.lang.SecurityException

RegSetValue

public static int RegSetValue(int key,
                              java.lang.String valueName,
                              int data)
                       throws java.lang.SecurityException
Stores integer data in the value field of an open registry key.

Parameters:
key - specifies the handle to an opened key.
valueName - specifies the name of the value.
data - specifies a 32-bit integer to store.
Returns:
0 if the function succeeds. Otherwise a nonzero error code is returned.
java.lang.SecurityException

RegSetValue

public static int RegSetValue(int key,
                              java.lang.String valueName,
                              java.lang.String data)
                       throws java.lang.SecurityException
java.lang.SecurityException

SetClipboardText

public static boolean SetClipboardText(java.lang.String data)
                                throws java.lang.SecurityException
Copies text to Clipboard.

java.lang.SecurityException

SetEvent

public static boolean SetEvent(int handle)
Sets the state of the specified event object to signaled.

Parameters:
handle - specifies the event object.
Returns:
a boolean that indicates whether the function was successful.

Wait

public static int Wait(int handle,
                       int howLong)
                throws java.lang.SecurityException
Wrapper for Win32 WaitForSingleObject api. Puts Java thread to sleep while waiting for the kernel object to become signaled or the time-out interval elapsed.

Parameters:
handle - specifies the kernel object (for example, the process handle).
howLong - specifies the time-out interval, in milliseconds. If howLong is -1, the time-out interval never elapses.
Returns:
an integer that indicates the event that caused the function to return.
java.lang.SecurityException

WriteFile

public static boolean WriteFile(java.lang.String path,
                                byte[] data,
                                int length)
                         throws java.lang.SecurityException
Opens a file exclusively. Writes bytes from the data byte array.

Parameters:
length - specifies how many bytes to write.
Returns:
a boolean that inndicates whether operation was successful.
java.lang.SecurityException