Search in sources :

Example 1 with EVT_VARIANT

use of com.sun.jna.platform.win32.Winevt.EVT_VARIANT in project jna by java-native-access.

the class WevtapiUtil method EvtGetChannelConfigProperty.

/**
     * Gets the specified channel configuration property.
     *
     * @param channelHandle [in] A handle to the channel's configuration properties that
     *                      the {@link Wevtapi#EvtOpenChannelConfig} function returns.
     * @param propertyId    [in] The identifier of the channel property to retrieve. For a list of property
     *                      identifiers, see the {@link Winevt.EVT_CHANNEL_CONFIG_PROPERTY_ID} enumeration.
     * @return EVT_VARIANT(already reading from native memory)
     */
public static EVT_VARIANT EvtGetChannelConfigProperty(EVT_HANDLE channelHandle, int propertyId) {
    IntByReference propertyValueBufferUsed = new IntByReference();
    boolean result = Wevtapi.INSTANCE.EvtGetChannelConfigProperty(channelHandle, propertyId, 0, 0, null, propertyValueBufferUsed);
    int errorCode = Kernel32.INSTANCE.GetLastError();
    if ((!result) && errorCode != Kernel32.ERROR_INSUFFICIENT_BUFFER) {
        throw new Win32Exception(errorCode);
    }
    Memory propertyValueBuffer = new Memory(propertyValueBufferUsed.getValue());
    result = Wevtapi.INSTANCE.EvtGetChannelConfigProperty(channelHandle, propertyId, 0, (int) propertyValueBuffer.size(), propertyValueBuffer, propertyValueBufferUsed);
    if (!result) {
        throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
    }
    EVT_VARIANT resultEvt = new EVT_VARIANT(propertyValueBuffer);
    resultEvt.read();
    return resultEvt;
}
Also used : IntByReference(com.sun.jna.ptr.IntByReference) EVT_VARIANT(com.sun.jna.platform.win32.Winevt.EVT_VARIANT) Memory(com.sun.jna.Memory)

Aggregations

Memory (com.sun.jna.Memory)1 EVT_VARIANT (com.sun.jna.platform.win32.Winevt.EVT_VARIANT)1 IntByReference (com.sun.jna.ptr.IntByReference)1