Examples of PointerByReference


Examples of com.sun.jna.ptr.PointerByReference

     * @param index
     *            the index
     * @return the type info
     */
    public ITypeInfo getTypeInfo(int index) {
        PointerByReference ppTInfo = new PointerByReference();
        HRESULT hr = this.typelib.GetTypeInfo(new UINT(index), ppTInfo);
        COMUtils.checkRC(hr);
        return new TypeInfo(ppTInfo.getValue());
    }
View Full Code Here

Examples of com.sun.jna.ptr.PointerByReference

     * Gets the lib attr.
     *
     * @return the lib attr
     */
    public TLIBATTR getLibAttr() {
        PointerByReference ppTLibAttr = new PointerByReference();
        HRESULT hr = typelib.GetLibAttr(ppTLibAttr);
        COMUtils.checkRC(hr);

        return new TLIBATTR(ppTLibAttr.getValue());
    }
View Full Code Here

Examples of com.sun.jna.ptr.PointerByReference

     * Gets the type comp.
     *
     * @return the i type comp. by reference
     */
    public TypeComp GetTypeComp() {
        PointerByReference ppTComp = new PointerByReference();
        HRESULT hr = this.typelib.GetTypeComp(ppTComp);
        COMUtils.checkRC(hr);

        return new TypeComp(ppTComp.getValue());
    }
View Full Code Here

Examples of com.sun.jna.ptr.PointerByReference

    }
   
    private FileInfo waitForChange() {
        IntByReference rcount = new IntByReference();
        ULONG_PTRByReference rkey = new ULONG_PTRByReference();
        PointerByReference roverlap = new PointerByReference();
        if (! Kernel32.INSTANCE.GetQueuedCompletionStatus(port, rcount, rkey, roverlap, WinBase.INFINITE)) {
            return null;
        }
        synchronized (this) {
            return handleMap.get(new HANDLE(rkey.getValue().toPointer()));
View Full Code Here

Examples of com.sun.jna.ptr.PointerByReference

     * @param code
     *            int
     * @return Formatted message.
     */
    public static String formatMessage(int code) {
        PointerByReference buffer = new PointerByReference();
        if (0 == Kernel32.INSTANCE.FormatMessage(
                WinBase.FORMAT_MESSAGE_ALLOCATE_BUFFER
                        | WinBase.FORMAT_MESSAGE_FROM_SYSTEM
                        | WinBase.FORMAT_MESSAGE_IGNORE_INSERTS, null, code, 0, // TODO:
                                                                                // MAKELANGID(LANG_NEUTRAL,
                                                                                // SUBLANG_DEFAULT)
                buffer, 0, null)) {
            throw new LastErrorException(Kernel32.INSTANCE.GetLastError());
        }
        String s = buffer.getValue().getWideString(0);
        Kernel32.INSTANCE.LocalFree(buffer.getValue());
        return s.trim();
    }
View Full Code Here

Examples of com.sun.jna.ptr.PointerByReference

    public final static LCID LOCALE_SYSTEM_DEFAULT = Kernel32.INSTANCE
            .GetSystemDefaultLCID();

    private Dispatch createIDispatch() {
        try {
            PointerByReference pDispatch = new PointerByReference();

            // Get CLSID for Word.Application...
            CLSID.ByReference clsid = new CLSID.ByReference();
            HRESULT hr = Ole32.INSTANCE.CLSIDFromProgID("Shell.Application",
                    clsid);

            if (W32Errors.FAILED(hr)) {
                Ole32.INSTANCE.CoUninitialize();
                COMUtils.checkRC(hr);
            }

            hr = Ole32.INSTANCE.CoCreateInstance(clsid, null,
                    WTypes.CLSCTX_SERVER, IDispatch.IID_IDISPATCH, pDispatch);

            if (W32Errors.FAILED(hr)) {
                COMUtils.checkRC(hr);
            }

            return new Dispatch(pDispatch.getValue());
        } catch (Exception e) {
            e.printStackTrace();
        }

        return null;
View Full Code Here

Examples of com.sun.jna.ptr.PointerByReference

    }

    public void testGetTypeInfo() {
        Dispatch dispatch = this.createIDispatch();
       
        PointerByReference ppTInfo = new PointerByReference();
        HRESULT hr = dispatch.GetTypeInfo(new UINT(0), LOCALE_SYSTEM_DEFAULT, ppTInfo);
       
        COMUtils.checkRC(hr);
        assertEquals(0, hr.intValue());
    }
View Full Code Here

Examples of com.sun.jna.ptr.PointerByReference

    }

    public void testAddressOfMember() {
        ITypeInfo typeInfo = getTypeInfo();
        MEMBERID memid = new MEMBERID();
        PointerByReference ppv = new PointerByReference();
        HRESULT hr = typeInfo.AddressOfMember(memid, INVOKEKIND.INVOKE_FUNC,
                ppv);

        COMUtils.checkRC(hr);
        assertEquals(0, hr.intValue());
View Full Code Here

Examples of com.sun.jna.ptr.PointerByReference

   * @return A structure containing the account SID.
   */
  public static Account getAccountByName(String systemName, String accountName) {
    IntByReference pSid = new IntByReference(0);
    IntByReference cchDomainName = new IntByReference(0);
    PointerByReference peUse = new PointerByReference();

    if (Advapi32.INSTANCE.LookupAccountName(systemName, accountName, null,
        pSid, null, cchDomainName, peUse)) {
      throw new RuntimeException(
          "LookupAccountNameW was expected to fail with ERROR_INSUFFICIENT_BUFFER");
    }

    int rc = Kernel32.INSTANCE.GetLastError();
    if (pSid.getValue() == 0 || rc != W32Errors.ERROR_INSUFFICIENT_BUFFER) {
      throw new Win32Exception(rc);
    }

    Memory sidMemory = new Memory(pSid.getValue());
    PSID result = new PSID(sidMemory);
    char[] referencedDomainName = new char[cchDomainName.getValue() + 1];

    if (!Advapi32.INSTANCE.LookupAccountName(systemName, accountName,
        result, pSid, referencedDomainName, cchDomainName, peUse)) {
      throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
    }

    Account account = new Account();
    account.accountType = peUse.getPointer().getInt(0);
    account.name = accountName;

    String[] accountNamePartsBs = accountName.split("\\\\", 2);
    String[] accountNamePartsAt = accountName.split("@", 2);

View Full Code Here

Examples of com.sun.jna.ptr.PointerByReference

   * @return Account.
   */
  public static Account getAccountBySid(String systemName, PSID sid) {
    IntByReference cchName = new IntByReference();
    IntByReference cchDomainName = new IntByReference();
    PointerByReference peUse = new PointerByReference();

    if (Advapi32.INSTANCE.LookupAccountSid(null, sid, null, cchName, null,
        cchDomainName, peUse)) {
      throw new RuntimeException(
          "LookupAccountSidW was expected to fail with ERROR_INSUFFICIENT_BUFFER");
    }

    int rc = Kernel32.INSTANCE.GetLastError();
    if (cchName.getValue() == 0
        || rc != W32Errors.ERROR_INSUFFICIENT_BUFFER) {
      throw new Win32Exception(rc);
    }

    char[] domainName = new char[cchDomainName.getValue()];
    char[] name = new char[cchName.getValue()];

    if (!Advapi32.INSTANCE.LookupAccountSid(null, sid, name, cchName,
        domainName, cchDomainName, peUse)) {
      throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
    }

    Account account = new Account();
    account.accountType = peUse.getPointer().getInt(0);
    account.name = Native.toString(name);

    if (cchDomainName.getValue() > 0) {
      account.domain = Native.toString(domainName);
      account.fqn = account.domain + "\\" + account.name;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.