Package com.sun.jna.platform.win32.Winsvc

Examples of com.sun.jna.platform.win32.Winsvc.SERVICE_STATUS_PROCESS


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

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

    GUID guid = Ole32Util
        .getGUIDFromString("{00021401-0000-0000-C000-000000000046}"); // Shell object
    GUID riid = Ole32Util
        .getGUIDFromString("{000214EE-0000-0000-C000-000000000046}"); // IShellLinkA

    PointerByReference pDispatch = new PointerByReference();

    HRESULT hr = Ole32.INSTANCE.CoCreateInstance(guid, null, // pOuter =
                                  // null, no
                                  // aggregation
        WTypes.CLSCTX_LOCAL_SERVER, riid, pDispatch);
    assertTrue(W32Errors.SUCCEEDED(hr.intValue()));
    assertTrue(!pDispatch.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


   * @return
   *  A GUID.
   */
  public static GUID getGUIDFromString(String guidString) {
    GUID lpiid = new GUID();
      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 pguid = new GUID();
      HRESULT hr = Ole32.INSTANCE.CoCreateGuid(pguid);
      if (! hr.equals(W32Errors.S_OK)) {
        throw new RuntimeException(hr.toString());
      }
      return pguid;
  }
View Full Code Here

                null, 1, null, 0, pcbNeeded, pcReturned);
        if (pcbNeeded.getValue() <= 0) {
            return new PRINTER_INFO_1[0];
        }

        PRINTER_INFO_1 pPrinterEnum = new PRINTER_INFO_1(pcbNeeded.getValue());
        if (!Winspool.INSTANCE.EnumPrinters(Winspool.PRINTER_ENUM_LOCAL,
                null, 1, pPrinterEnum.getPointer(), pcbNeeded.getValue(), pcbNeeded, pcReturned)) {
            throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
        }

        pPrinterEnum.read();

        return (PRINTER_INFO_1[]) pPrinterEnum.toArray(pcReturned.getValue());
    }
View Full Code Here

                null, 4, null, 0, pcbNeeded, pcReturned);
        if (pcbNeeded.getValue() <= 0) {
            return new PRINTER_INFO_4[0];
        }

        PRINTER_INFO_4 pPrinterEnum = new PRINTER_INFO_4(pcbNeeded.getValue());
        if (!Winspool.INSTANCE.EnumPrinters(Winspool.PRINTER_ENUM_LOCAL,
                null, 4, pPrinterEnum.getPointer(), pcbNeeded.getValue(), pcbNeeded, pcReturned)) {
            throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
        }

        pPrinterEnum.read();

        return (PRINTER_INFO_4[]) pPrinterEnum.toArray(pcReturned.getValue());
    }
View Full Code Here

          null, 0, pcbBytesNeeded));
      assertEquals(W32Errors.ERROR_INSUFFICIENT_BUFFER, Kernel32.INSTANCE.GetLastError());
     
      assertTrue(pcbBytesNeeded.getValue() > 0);

      SERVICE_STATUS_PROCESS status = new SERVICE_STATUS_PROCESS(pcbBytesNeeded.getValue());

      assertTrue(Advapi32.INSTANCE.QueryServiceStatusEx(serviceHandle, SC_STATUS_TYPE.SC_STATUS_PROCESS_INFO,
          status, status.size(), pcbBytesNeeded));

      assertTrue(status.dwCurrentState == Winsvc.SERVICE_STOPPED ||
          status.dwCurrentState == Winsvc.SERVICE_RUNNING);

      assertTrue(Advapi32.INSTANCE.CloseServiceHandle(serviceHandle));
View Full Code Here

    IntByReference size = new IntByReference();
   
    Advapi32.INSTANCE.QueryServiceStatusEx(_handle, SC_STATUS_TYPE.SC_STATUS_PROCESS_INFO,
        null, 0, size);
   
    SERVICE_STATUS_PROCESS status = new SERVICE_STATUS_PROCESS(size.getValue());
    if(! Advapi32.INSTANCE.QueryServiceStatusEx(_handle, SC_STATUS_TYPE.SC_STATUS_PROCESS_INFO,
        status, status.size(), size)) {
      throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
    }
   
    return status;
  }
View Full Code Here

    /**
     * Wait for the state to change to something other than a pending state.
     */
  public void waitForNonPendingState() {

    SERVICE_STATUS_PROCESS status = queryStatus();

    int previousCheckPoint = status.dwCheckPoint;
    int checkpointStartTickCount = Kernel32.INSTANCE.GetTickCount();;

    while (isPendingState(status.dwCurrentState)) {
View Full Code Here

          null, 0, pcbBytesNeeded));
      assertEquals(W32Errors.ERROR_INSUFFICIENT_BUFFER, Kernel32.INSTANCE.GetLastError());
     
      assertTrue(pcbBytesNeeded.getValue() > 0);

      SERVICE_STATUS_PROCESS status = new SERVICE_STATUS_PROCESS(pcbBytesNeeded.getValue());

      assertTrue(Advapi32.INSTANCE.QueryServiceStatusEx(serviceHandle, SC_STATUS_TYPE.SC_STATUS_PROCESS_INFO,
          status, status.size(), pcbBytesNeeded));

      assertTrue(status.dwCurrentState == Winsvc.SERVICE_STOPPED ||
          status.dwCurrentState == Winsvc.SERVICE_RUNNING);

      assertTrue(Advapi32.INSTANCE.CloseServiceHandle(serviceHandle));
View Full Code Here

//    service.close();
  }
 
  public void testQueryStatus() {
    W32Service service = _serviceManager.openService("eventlog", Winsvc.SERVICE_QUERY_STATUS);
    SERVICE_STATUS_PROCESS status = service.queryStatus();
    assertTrue(status.dwCurrentState == Winsvc.SERVICE_RUNNING ||
        status.dwCurrentState == Winsvc.SERVICE_STOPPED);
    service.close();
  }
View Full Code Here

TOP

Related Classes of com.sun.jna.platform.win32.Winsvc.SERVICE_STATUS_PROCESS

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.