Exemplo n.º 1
0
	/**
	 * Accepts a dispatch object and sets the type to VT_DISPATCH.
	 * There is currently no way to pass NULL into this method
	 * to create something like "NOTHING" from VB
	 * */
	JNIEXPORT void JNICALL Java_com_tangram_Variant_putVariantDispatch(JNIEnv *env, jobject _this, jobject _that)
	{
		VARIANT *v = extractVariant(env, _this);
		IDispatch *disp = extractDispatch(env, _that);
		if (v) {
			VariantClear(v); // whatever was there before
			V_VT(v) = VT_DISPATCH;
			V_DISPATCH(v) = disp;
			// I am handing the pointer to COM
			// SF 3435567 support null dispatch pointer
			if (disp)
				disp->AddRef();
		}
		else ThrowComFail(env, "putObject failed", -1);
	}
Exemplo n.º 2
0
JNIEXPORT void JNICALL Java_com_jacob_com_DispatchProxy_MarshalIntoStream
  (JNIEnv *env, jobject _this, jobject disp)
{
  IDispatch *pIDispatch = extractDispatch(env, disp);
  if (!pIDispatch) return;
  IStream *ps; // this is the stream we will marshall into
  HRESULT hr = CoMarshalInterThreadInterfaceInStream(
                 IID_IDispatch, pIDispatch, &ps);
  if (!SUCCEEDED(hr))
  {
    ThrowComFail(env, "Could not Marshal Dispatch into IStream", hr);
    return;
  }
  // store the stream pointer on the object
  jclass argClass = env->GetObjectClass(_this);
  jfieldID ajf = env->GetFieldID( argClass, "m_pStream", "I");
  env->SetIntField(_this, ajf, (jint)ps);
}