Package com.sun.jna.examples.win32.WinNT

Examples of com.sun.jna.examples.win32.WinNT.HRESULT


    }

    public COMBindingBaseObject(CLSID clsid, boolean useActiveInstance,
            int dwClsContext) {
        // Initialize COM for this thread...
        HRESULT hr = Ole32.INSTANCE.CoInitializeEx(null, Ole32.COINIT_APARTMENTTHREADED);
        if (hr.intValue() == 1) // Already initialized, no problem
            hr = new HRESULT(0);
        if (COMUtils.FAILED(hr)) {
            Ole32.INSTANCE.CoUninitialize();
            throw new COMException("CoInitialize() failed!");
        }
View Full Code Here


    }

    public COMBindingBaseObject(String progId, boolean useActiveInstance,
            int dwClsContext) throws COMException {
        // Initialize COM for this thread...
        HRESULT hr = Ole32.INSTANCE.CoInitializeEx(null, Ole32.COINIT_APARTMENTTHREADED);
        if (hr.intValue() == 1) // Already initialized, no problem
            hr = new HRESULT(0);

        if (COMUtils.FAILED(hr)) {
            this.release();
            throw new COMException("CoInitialize() failed!");
        }
View Full Code Here

        // variable declaration
        WString[] ptName = new WString[] { new WString(name) };
        DISPIDByReference pdispID = new DISPIDByReference();

        // Get DISPID for name passed...
        HRESULT hr = pDisp.GetIDsOfNames(Guid.IID_NULL, ptName, 1,
                LOCALE_USER_DEFAULT, pdispID);

        COMUtils.checkRC(hr);

        return this
View Full Code Here

            // write 'DISPPARAMS' structure to memory
            dp.write();
        }

        // Make the call!
        HRESULT hr = pDisp.Invoke(dispId, Guid.IID_NULL, LOCALE_SYSTEM_DEFAULT,
                new DISPID(nType), dp, pvResult, pExcepInfo, puArgErr);

        COMUtils.checkRC(hr, pExcepInfo, puArgErr);
        return hr;
    }
View Full Code Here

   * @return
   *  A GUID.
   */
  public static GUID getGUIDFromString(String guidString) {
    GUID.ByReference lpiid = new GUID.ByReference();
      HRESULT hr = Ole32.INSTANCE.IIDFromString(guidString, lpiid);
      if (! hr.equals(W32Errors.S_OK)) {
        throw new RuntimeException(hr.toString());
      }
      return lpiid;
  }
View Full Code Here

   * @return
   *  New GUID.
   */
  public static GUID generateGUID() {
    GUID.ByReference pguid = new GUID.ByReference();
      HRESULT hr = Ole32.INSTANCE.CoCreateGuid(pguid);
      if (! hr.equals(W32Errors.S_OK)) {
        throw new RuntimeException(hr.toString());
      }
      return pguid;
  }
View Full Code Here

  public static final int FACILITY_NT_BIT = 0x10000000;

  public static final HRESULT HRESULT_FROM_WIN32(int x) {
    int f = FACILITY_WIN32;
    return new HRESULT(x <= 0 ? x : ((x) & 0x0000FFFF) | (f <<= 16) | 0x80000000);
  }
View Full Code Here

   * @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);
  }
View Full Code Here

      lpsz[len - 1] = 0;     
      assertEquals("{00000000-0000-0000-0000-000000000000}", Native.toString(lpsz));
    }

    public void testCoInitializeEx() {
        HRESULT hr = Ole32.INSTANCE.CoInitializeEx(null, 0);
        assertTrue(W32Errors.SUCCEEDED(hr.intValue()) || hr.intValue() == W32Errors.RPC_E_CHANGED_MODE);
        if (W32Errors.SUCCEEDED(hr.intValue()))
            Ole32.INSTANCE.CoUninitialize();
    }
View Full Code Here

        if (W32Errors.SUCCEEDED(hr.intValue()))
            Ole32.INSTANCE.CoUninitialize();
    }

    public void testCoCreateInstance() {
        HRESULT hrCI = Ole32.INSTANCE.CoInitializeEx(null, 0);

        GUID guid = Ole32Util.getGUIDFromString("{13709620-C279-11CE-A49E-444553540000}"); //Shell object
        GUID riid = Ole32Util.getGUIDFromString("{D8F015C0-C278-11CE-A49E-444553540000}"); //IShellDispatch

        PointerByReference iUnknown = new PointerByReference();

        HRESULT hr = Ole32.INSTANCE.CoCreateInstance(
                guid,
                null, // pOuter = null, no aggregation
                ObjBase.CLSCTX_ALL,
                riid,
                iUnknown);
        assertTrue(W32Errors.SUCCEEDED(hr.intValue()));
        assertTrue(!iUnknown.getValue().equals(Pointer.NULL));
        // We leak this iUnknown reference because we don't have the JNACOM lib
        // here to wrap the native iUnknown pointer and call iUnknown.release()
        if (W32Errors.SUCCEEDED(hrCI.intValue()))
            Ole32.INSTANCE.CoUninitialize();
View Full Code Here

TOP

Related Classes of com.sun.jna.examples.win32.WinNT.HRESULT

Copyright © 2018 www.massapicom. 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.