Ejemplo n.º 1
0
JNIEXPORT jstring JNICALL Java_jmtp_PortableDeviceContentImplWin32_createObjectWithPropertiesOnly
	(JNIEnv* env, jobject obj, jobject jobjValues)
{
	//variabelen
	HRESULT hr;
	IPortableDeviceContent* pDeviceContent;
	IPortableDeviceValues* pValues;
	LPWSTR wszObjectID;
	jstring jsObjectID;

	
	//Methode implementatie
	if(jobjValues != NULL)
	{
		pDeviceContent = GetPortableDeviceContent(env, obj);
		pValues = (IPortableDeviceValues*)GetComReferencePointerFromComReferenceable(env, jobjValues);
		hr = pDeviceContent->CreateObjectWithPropertiesOnly(pValues, &wszObjectID);

		if(SUCCEEDED(hr))
		{
			jsObjectID = (jstring)env->NewString((jchar*)wszObjectID, wcslen(wszObjectID));
			CoTaskMemFree(wszObjectID);
			return jsObjectID;
		}
		else
		{
			ThrowCOMException(env, L"Couldn't create the file", hr);
			return NULL;
		}
	}
	else
	{
		env->ThrowNew(env->FindClass("java/lang/NullPointerException"), "values can't be null");
		return NULL;
	}
}