Class BStrFFM
java.lang.Object
oshi.ffm.ForeignFunctions
oshi.ffm.windows.WindowsForeignFunctions
oshi.ffm.windows.com.BStrFFM
FFM utilities for handling BSTR (Basic String) - the string type used in COM automation.
A BSTR is a pointer to a null-terminated Unicode string preceded by a 4-byte length prefix. The pointer points to the first character, not the length prefix.
-
Field Summary
Fields inherited from class ForeignFunctions
CAPTURE_CALL_STATE, CAPTURED_STATE_LAYOUT, ERRNO_HANDLE, LIBRARY_ARENA, LINKER, SYMBOL_LOOKUP -
Method Summary
Modifier and TypeMethodDescriptionstatic voidfree(MemorySegment bstr) Frees a BSTR allocated by SysAllocString.static MemorySegmentfromString(Arena arena, String str) Allocates a new BSTR and copies the specified string into it.static intlength(MemorySegment bstr) Returns the length of a BSTR in characters (not bytes).static StringtoString(MemorySegment bstr, Arena arena) Converts a BSTR to a Java String.Methods inherited from class WindowsForeignFunctions
checkSuccess, isSuccess, readAnsiString, readWideString, setupTokenPrivileges, toWideStringMethods inherited from class ForeignFunctions
downcall, getByteArrayFromNativePointer, getErrno, getStringFromNativePointer, getStructFromNativePointer, lib, libraryLookup
-
Method Details
-
fromString
Allocates a new BSTR and copies the specified string into it.- Parameters:
arena- the arena for string conversionstr- the string to convert- Returns:
- the BSTR pointer, or NULL if allocation failed
-
free
Frees a BSTR allocated by SysAllocString.- Parameters:
bstr- the BSTR to free
-
length
Returns the length of a BSTR in characters (not bytes).- Parameters:
bstr- the BSTR- Returns:
- the length in characters, or 0 if null
-
toString
Converts a BSTR to a Java String.- Parameters:
bstr- the BSTR pointerarena- the arena for memory reinterpretation- Returns:
- the Java string, or empty string if null
-