|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.safs.natives.NativeWrapper
public class NativeWrapper
This class is used to encapsulate platform independent calls to native operating systems through JNA, or other native platform technologies.
JAN is the Java Native Access library supplied via JNA Home
JNA provides Java programs easy access to native shared libraries on multiple operating systems without writing anything but Java codeĉ˘o JNI or native code is required. This functionality is comparable to Windows' Platform/Invoke and Python's ctypes. Access is dynamic at runtime without code generation.
SAFS is now delivered with the core JNA.ZIP(JAR). Other JNA support libraries may be added as needed.
| Field Summary | |
|---|---|
static int |
NO_RESULT
-99 |
static java.lang.String |
RESULT_KEY
"Result" |
static java.lang.String |
VECTOR_KEY
"Vector" |
| Constructor Summary | |
|---|---|
NativeWrapper()
|
|
| Method Summary | |
|---|---|
protected static int |
_processLastError()
Retrieves last error via GetLastError and also attempts to debug log the error code and any system message for the error code. |
static boolean |
DoesRegistryKeyExist(java.lang.Object key,
java.lang.Object valuename)
True if the requested "registry key" already exists, false otherwise. This is currently only supported on Windows. |
static java.lang.Object[] |
EnumChildWindows(java.lang.Object parent)
Platform independent entry-point to receive the ID or HANDLE of all child Windows of a parent. |
static java.lang.Object[] |
EnumWindows()
Platform independent entry-point to receive the ID or HANDLE of all top-level Windows. |
static java.lang.Object |
GetDesktopWindow()
Platform independent entry-point to receive the ID or HANDLE of the Desktop window. |
static boolean |
getFileTime(java.lang.String filename,
java.util.Date createTime,
java.util.Date accessTime,
java.util.Date writeTime)
This method will get the file's created time, access time, and write time. |
static java.lang.Object |
GetForegroundWindow()
Platform independent entry-point to receive the ID or HANDLE of the current foreground window. |
static java.lang.Object |
GetProcessFileName(java.lang.Object processID)
Retrieve the name of the executable file for the specified process. |
static java.lang.Object |
GetProcessUIResourceCount(java.lang.Object processID)
Retrieve the count of UI elements used by the specified process. |
static java.lang.Object |
GetRegistryKeyValue(java.lang.Object key,
java.lang.Object valuename)
Return the value of the specified key. |
static java.lang.Object[] |
GetWindowThreadProcessId(java.lang.Object parent)
The GetWindowThreadProcessId function retrieves the identifier of the thread that created the specified window and, optionally, the identifier of the process that created the window. |
static java.lang.Object |
LaunchURLInDefaultWebBrowser(java.lang.String url)
Attempt to launch a web URL via the system's default web browser. |
static void |
main(java.lang.String[] args)
Simple regression tests with output to System.out |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int NO_RESULT
public static final java.lang.String VECTOR_KEY
public static final java.lang.String RESULT_KEY
| Constructor Detail |
|---|
public NativeWrapper()
| Method Detail |
|---|
public static boolean DoesRegistryKeyExist(java.lang.Object key,
java.lang.Object valuename)
The Windows version uses Reg.EXE which is supplied with WindowsXP. If this EXE is not present on the Windows system then this function will return false.
key - For Windows this is a String. Ex:"HKLM\Software\Rational Software\Rational Test\8\Options"valuename - For Windows this is a String. Ex:"SpyHeapSize"
public static java.lang.Object GetRegistryKeyValue(java.lang.Object key,
java.lang.Object valuename)
The Windows version uses Reg.EXE which is supplied with WindowsXP. If this EXE is not present on the Windows system then this function will always return false.
key - For Windows this is a String. Ex:"HKLM\Software\Rational Software\Rational Test\8\Options"valuename - For Windows this is a String. Ex:"SpyHeapSize"
protected static int _processLastError()
public static java.lang.Object GetForegroundWindow()
For windows NOTE: WIN32: we will return a Long representing the Handle (HWND), or null on error. NOTE: Support for other Platforms will be added as needed.
User32.GetForegroundWindow()public static java.lang.Object GetDesktopWindow()
For windows NOTE: WIN32: we will return a Long representing the Handle (HWND), or null on error. NOTE: Support for other Platforms will be added as needed.
User32.GetDesktopWindow()public static java.lang.Object[] EnumWindows()
For windows NOTE: WIN32: we will return an array of Longs representing the Handles (HWND), or null on error. NOTE: Support for other Platforms will be added as needed.
User32.EnumWindows(WNDENUMPROC,Pointer)public static java.lang.Object[] EnumChildWindows(java.lang.Object parent)
For windows NOTE: WIN32: we will return an array of Longs representing the Handles (HWND), or null on error. NOTE: Support for other Platforms will be added as needed.
handle - to the parent. For WIN32, this is a Long.
User32.EnumWindows(WNDENUMPROC,Pointer)public static java.lang.Object[] GetWindowThreadProcessId(java.lang.Object parent)
parent - - handle to the parent. For WIN32, this is a Long.
public static java.lang.Object GetProcessUIResourceCount(java.lang.Object processID)
processID - -- the id of the process to query. For WIN32 this is an Integer.
org.safs.natives.win32.Kernel32#GetGuiResources(Pointer, int)public static java.lang.Object GetProcessFileName(java.lang.Object processID)
processID - -- the id of the process to query. For WIN32 this is an Integer.
Kernel32.GetProcessImageFileNameA(Pointer, Pointer, int),
Psapi.GetProcessImageFileNameA(Pointer, Pointer, int)public static java.lang.Object LaunchURLInDefaultWebBrowser(java.lang.String url)
On Windows this uses ShellExecute's "open" operation to open the URL document using the default app.
url - -- User should include the 'protocol' portion of the url (Ex: 'http://')
Shell32.ShellExecuteA(NativeLong, String, String, String, String, long)
public static boolean getFileTime(java.lang.String filename,
java.util.Date createTime,
java.util.Date accessTime,
java.util.Date writeTime)
This method will get the file's created time, access time, and write time. Dor in parameter filename: it MUST be an absolute file path. For out parameters: createTime, accessTime and writeTime, if you don't want some of them, you can just pass a null value; If you want some of them, you MUST pass an instance of java.util.Date as value.
filename - In The absolute file pathcreateTime - Out The java.util.Date object contains the file created timeaccessTime - Out The java.util.Date object contains the file last accessed timewriteTime - Out The java.util.Date object contains the file last modified time
public static void main(java.lang.String[] args)
java org.safs.natives.NativeWrapper > outputFile.txt
args - --accepts none
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||