use of com.sun.jna.platform.win32.WinNT.HRESULT in project jna by java-native-access.
the class ProxyObject method resolveDispId.
protected DISPID resolveDispId(final IDispatch pDisp, String name) {
assert COMUtils.comIsInitialized() : "COM not initialized";
if (pDisp == null)
throw new COMException("pDisp (IDispatch) parameter is null!");
// variable declaration
final WString[] ptName = new WString[] { new WString(name) };
final DISPIDByReference pdispID = new DISPIDByReference();
// Get DISPID for name passed...
HRESULT hr = pDisp.GetIDsOfNames(new REFIID(Guid.IID_NULL), ptName, 1, factory.getLCID(), pdispID);
COMUtils.checkRC(hr);
return pdispID.getValue();
}
use of com.sun.jna.platform.win32.WinNT.HRESULT in project jna by java-native-access.
the class ProxyObject method fetchRawConnectionPoint.
// ---------------------- IConnectionPoint ----------------------
private ConnectionPoint fetchRawConnectionPoint(IID iid) throws InterruptedException, ExecutionException, TimeoutException {
assert COMUtils.comIsInitialized() : "COM not initialized";
// query for ConnectionPointContainer
IConnectionPointContainer cpc = this.queryInterface(IConnectionPointContainer.class);
Dispatch rawCpcDispatch = (Dispatch) cpc.getRawDispatch();
final ConnectionPointContainer rawCpc = new ConnectionPointContainer(rawCpcDispatch.getPointer());
// find connection point for comEventCallback interface
final REFIID adviseRiid = new REFIID(iid.getPointer());
final PointerByReference ppCp = new PointerByReference();
HRESULT hr = rawCpc.FindConnectionPoint(adviseRiid, ppCp);
COMUtils.checkRC(hr);
final ConnectionPoint rawCp = new ConnectionPoint(ppCp.getValue());
return rawCp;
}
use of com.sun.jna.platform.win32.WinNT.HRESULT in project jna by java-native-access.
the class ProxyObject method getUnknownId.
private long getUnknownId() {
assert COMUtils.comIsInitialized() : "COM not initialized";
if (-1 == this.unknownId) {
try {
final PointerByReference ppvObject = new PointerByReference();
Thread current = Thread.currentThread();
String tn = current.getName();
IID iid = com.sun.jna.platform.win32.COM.IUnknown.IID_IUNKNOWN;
HRESULT hr = ProxyObject.this.getRawDispatch().QueryInterface(new REFIID(iid), ppvObject);
if (WinNT.S_OK.equals(hr)) {
Dispatch dispatch = new Dispatch(ppvObject.getValue());
this.unknownId = Pointer.nativeValue(dispatch.getPointer());
// QueryInterface returns a COM object pointer with a +1
// reference, we must drop one,
// Note: createProxy adds one;
int n = dispatch.Release();
} else {
String formatMessageFromHR = Kernel32Util.formatMessage(hr);
throw new COMException("getUnknownId: " + formatMessageFromHR);
}
} catch (Exception e) {
throw new COMException("Error occured when trying get Unknown Id ", e);
}
}
return this.unknownId;
}
use of com.sun.jna.platform.win32.WinNT.HRESULT in project jna by java-native-access.
the class Shell32Util method getFolderPath.
/**
* Get a special folder path.
* @param hwnd
* Parent window.
* @param nFolder
* Folder CSLID.
* @param dwFlags
* Flags.
* @return
* Special folder.
*/
public static String getFolderPath(HWND hwnd, int nFolder, DWORD dwFlags) {
char[] pszPath = new char[WinDef.MAX_PATH];
HRESULT hr = Shell32.INSTANCE.SHGetFolderPath(hwnd, nFolder, null, dwFlags, pszPath);
if (!hr.equals(W32Errors.S_OK)) {
throw new Win32Exception(hr);
}
return Native.toString(pszPath);
}
use of com.sun.jna.platform.win32.WinNT.HRESULT in project jna by java-native-access.
the class VariantTest method testVariantCopyBoolean.
public void testVariantCopyBoolean() {
VARIANT variantSource = new VARIANT(Variant.VARIANT_TRUE);
VARIANT variantDest = new VARIANT();
HRESULT hr = OleAuto.INSTANCE.VariantCopy(variantDest.getPointer(), variantSource);
assertTrue("hr: " + hr.intValue(), hr.intValue() == 0);
}
Aggregations