/**
   * Initializes COM and gets an instance of the IShellLink interface.
   *
   * @exception Exception if problems are encountered
   */
  private void initialize() throws Exception {
    try {
      Librarian.getInstance().loadLibrary("ShellLink", this);
    } catch (UnsatisfiedLinkError exception) {
      throw (new Exception("could not locate native library"));
    }

    try {
      if (initializeCOM() != SL_OK) {
        throw (new Exception("could not initialize COM"));
      } else {
        initializeSucceeded = true;
      }
    } catch (Throwable exception) {
      throw (new Exception("unidentified problem initializing COM\n" + exception.toString()));
    }

    int successCode = getInterface();
    if (successCode != SL_OK) {
      releaseCOM();
      initializeSucceeded = false;

      if (successCode == SL_OUT_OF_HANDLES) {
        throw (new Exception("could not get an instance of IShellLink, no more handles available"));
      } else {
        throw (new Exception(
            "could not get an instance of IShellLink, failed to co-create instance"));
      }
    }
  }
  /** Destructor, releases COM and frees native resources. */
  protected void finalize() throws Throwable {
    releaseInterface();

    if (initializeSucceeded) {
      releaseCOM();
      initializeSucceeded = false;
    }
    super.finalize();
  }