com.jniwrapper.win32.system
Class Kernel32

java.lang.Object
  extended by com.jniwrapper.util.FunctionCache
      extended by com.jniwrapper.win32.WinFunctionCache
          extended by com.jniwrapper.win32.system.Kernel32

public class Kernel32
extends WinFunctionCache

This class provides functions from the Kernel32 library.


Method Summary
static java.lang.String expandEnvironmentStrings(java.lang.String source)
           
static java.lang.String getCurrentDirectory()
           
static int getCurrentProcessId()
          Returns the identifier of the current process.
static int getCurrentThreadId()
          Returns the identifier of the current thread.
static Kernel32 getInstance()
           
static Handle[] getProcessHeaps()
           
static long getProcessId(Process process)
           
static java.lang.String getSystemDirectory()
          Returns the absolute path to the Windows system directory.
static java.lang.String getWindowsDirectory()
          Returns the absolute path to the Windows directory.
static int globalAddAtom(java.lang.String value)
          Creates a globally unique identifier that corresponds to the specified string.
static boolean heapLock(Handle heap)
           
static boolean heapUnlock(Handle heap)
           
static boolean heapWalk(Handle heap, ProcessHeapEntry heapEntry)
           
 boolean isUnicode()
          Says if ANSI or Unicode functions should be used.
static int lstrlen(com.jniwrapper.Pointer.Void lpStr)
          Returns the length of a zero-terminated string.
static int mulDiv(int number, int numerator, int denominator)
          Multiplies two 32-bit values and then divides the 64-bit result by a third 32-bit value.
static int multiByteToWideChar(int codePage, int dwFlags, com.jniwrapper.Pointer.Void srcStr, int srcLen, com.jniwrapper.Pointer.Void destStr, int destLen)
          Translates a multibyte string to a Unicode string.
static long processIdToSessionId(com.jniwrapper.UInt32 processId)
           
static void setCurrentDirectory(java.lang.String directory)
           
 void setUnicode(boolean unicode)
          Instructs the cache to use Unicode or ANSI functions and parameter types.
protected  void setupEncoding()
           
 
Methods inherited from class com.jniwrapper.util.FunctionCache
getFunction, getVariable
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

setupEncoding

protected void setupEncoding()
Overrides:
setupEncoding in class WinFunctionCache

isUnicode

public boolean isUnicode()
Says if ANSI or Unicode functions should be used.

Detects the platform if this wasn't done before, or property wasn't explicitly modified directly via setUnicode(). If the property wasn't set explicitly, assumes that Unicode should be used if the underlying OS is NT-based.

NOTE: Since the Unicode support detection is based on the platform version detection, which itself requires Kernel32 instance, the detection cannot be performed in the constructor to prevent recursion, and should be delayed until actually queried.

Overrides:
isUnicode in class WinFunctionCache
Returns:
true if Unicode versions of functions should be used.

setUnicode

public void setUnicode(boolean unicode)
Description copied from class: WinFunctionCache
Instructs the cache to use Unicode or ANSI functions and parameter types.

Overrides:
setUnicode in class WinFunctionCache
Parameters:
unicode - if true, Unicode names and types will be used; otherwise ANSI.

getInstance

public static Kernel32 getInstance()

multiByteToWideChar

public static int multiByteToWideChar(int codePage,
                                      int dwFlags,
                                      com.jniwrapper.Pointer.Void srcStr,
                                      int srcLen,
                                      com.jniwrapper.Pointer.Void destStr,
                                      int destLen)
Translates a multibyte string to a Unicode string.

Parameters:
codePage - code page.
dwFlags - options
srcStr - address multibyte string.
srcLen - the length of multibyte string.
destStr - address for the Unicode string.
destLen - the number of bytes allocated for the Unicode string.
Returns:
if succeeded, returns the number of characters written to buffer, else returns 0.

lstrlen

public static int lstrlen(com.jniwrapper.Pointer.Void lpStr)
Returns the length of a zero-terminated string.

Parameters:
lpStr - the address of a zero-terminated string.
Returns:
the length of a zero-terminated string.

mulDiv

public static int mulDiv(int number,
                         int numerator,
                         int denominator)
Multiplies two 32-bit values and then divides the 64-bit result by a third 32-bit value. The return value is rounded up or down to the nearest integer.

Parameters:
number - Multiplicand.
numerator - Multiplier.
denominator - Number by which the result of the multiplication (nNumber * nNumerator) is to be divided
Returns:
If the function succeeds, the return value is the result of the multiplication and division. If either an overflow occurred or nDenominator was 0, the return value is 1.

getCurrentThreadId

public static int getCurrentThreadId()
Returns the identifier of the current thread.

Returns:
the identifier of the current thread.

getCurrentProcessId

public static int getCurrentProcessId()
Returns the identifier of the current process.

Returns:
the identifier of the current process.

getWindowsDirectory

public static java.lang.String getWindowsDirectory()
Returns the absolute path to the Windows directory.

Returns:
the absolute path to the Windows directory.

getSystemDirectory

public static java.lang.String getSystemDirectory()
Returns the absolute path to the Windows system directory.

Returns:
the absolute path to the Windows system directory.

globalAddAtom

public static int globalAddAtom(java.lang.String value)
Creates a globally unique identifier that corresponds to the specified string.

Parameters:
value - a string value not longer than 255 bytes.
Returns:
a globally unique identifier.

getCurrentDirectory

public static java.lang.String getCurrentDirectory()

setCurrentDirectory

public static void setCurrentDirectory(java.lang.String directory)

expandEnvironmentStrings

public static java.lang.String expandEnvironmentStrings(java.lang.String source)

getProcessId

public static long getProcessId(Process process)

getProcessHeaps

public static Handle[] getProcessHeaps()

processIdToSessionId

public static long processIdToSessionId(com.jniwrapper.UInt32 processId)

heapLock

public static boolean heapLock(Handle heap)

heapUnlock

public static boolean heapUnlock(Handle heap)

heapWalk

public static boolean heapWalk(Handle heap,
                               ProcessHeapEntry heapEntry)