@Override public DWORD callback(Pointer pbData, Pointer pvCallbackContext, ULONGByReference ulLength) { int elementsRead = elementsReadWrapper.getValue(); int remainingElements = outputStream.size() - elementsRead; int length = Math.min(remainingElements, ulLength.getValue().intValue()); pbData.write(0, outputStream.toByteArray(), elementsRead, length); elementsReadWrapper.setValue(elementsRead + length); ulLength.setValue(new ULONG(length)); return new DWORD(W32Errors.ERROR_SUCCESS); } };
/** * Find name. * * @param name * the name * @param hashVal * the hash val or 0 if unknown * @param maxResult * maximum number of items to search * @return the find name */ public FindName FindName(String name, int hashVal, short maxResult) { Pointer p = Ole32.INSTANCE.CoTaskMemAlloc((name.length() + 1L) * Native.WCHAR_SIZE); WTypes.LPOLESTR olestr = new WTypes.LPOLESTR(p); olestr.setValue(name); ULONG lHashVal = new ULONG(hashVal); USHORTByReference pcFound = new USHORTByReference(maxResult); Pointer[] ppTInfo = new Pointer[maxResult]; MEMBERID[] rgMemId = new MEMBERID[maxResult]; HRESULT hr = this.typelib.FindName(olestr, lHashVal, ppTInfo, rgMemId, pcFound); COMUtils.checkRC(hr); FindName findName = new FindName(olestr.getValue(), ppTInfo, rgMemId, pcFound.getValue().shortValue()); Ole32.INSTANCE.CoTaskMemFree(p); return findName; }
/** * Create a SAFEARRAY with supplied element type. * * <p> * The array will have as many dimensions as parameters are passed in. * The lowerbound for each dimension is set to zero, the count to the * parameter value.</p> * * @param vartype type of array contents (see Variant.VT_* constants) * @param size array of dimension size * @return SAFEARRAYWrapper or {@code NULL} if creation fails. */ public static SAFEARRAY.ByReference createSafeArray(VARTYPE vartype, int... size) { OaIdl.SAFEARRAYBOUND[] rgsabound = (OaIdl.SAFEARRAYBOUND[]) new OaIdl.SAFEARRAYBOUND().toArray(size.length); for (int i = 0; i < size.length; i++) { rgsabound[i].lLbound = new WinDef.LONG(0); rgsabound[i].cElements = new WinDef.ULONG(size[size.length - i - 1]); } SAFEARRAY.ByReference data = OleAuto.INSTANCE.SafeArrayCreate(vartype, new WinDef.UINT(size.length), rgsabound); return data; }
/** * Checks if is name. * * @param nameBuf * the name buf * @param hashVal * the hash val * @return the checks if is name */ public IsName IsName(String nameBuf, int hashVal) { LPOLESTR szNameBuf = new LPOLESTR(nameBuf); ULONG lHashVal = new ULONG(hashVal); BOOLByReference pfName = new BOOLByReference(); HRESULT hr = this.typelib.IsName(szNameBuf, lHashVal, pfName); COMUtils.checkRC(hr); return new IsName(szNameBuf.getValue(), pfName.getValue() .booleanValue()); }
public ULONGbyReference() { this(new ULONG(0)); }
protected void cacheNext() { assert COMUtils.comIsInitialized() : "COM not initialized"; final PointerByReference rgelt = new PointerByReference(); final WinDef.ULONGByReference pceltFetched = new WinDef.ULONGByReference(); WinNT.HRESULT hr = this.raw.Next(new WinDef.ULONG(1), rgelt, pceltFetched); if (WinNT.S_OK.equals(hr) && pceltFetched.getValue().intValue() > 0) { this.rawNext = new Moniker(rgelt.getValue()); } else { if (!WinNT.S_FALSE.equals(hr)) { COMUtils.checkRC(hr); } this.rawNext = null; } }
public ULONG getValue() { return new ULONG(getPointer().getInt(0)); } }
public SAFEARRAYBOUND(int cElements, int lLbound) { this.cElements = new ULONG(cElements); this.lLbound = new LONG(lLbound); this.write(); }
/** * Gets the value. * * @return the value */ public ULONG getValue() { return new ULONG(getPointer().getInt(0)); } }
public SAFEARRAYBOUND(int cElements, int lLbound) { this.cElements = new ULONG(cElements); this.lLbound = new LONG(lLbound); this.write(); } }
/** * Instantiates a new ULONG by reference. */ public ULONGByReference() { this(new ULONG(0)); }