Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
mikazakov
290 Views, 0 Replies

WriteDataToStream not return IStream*

Hi,

I can't get IStream pointer from AttributeSets.

Method WriteDataToFile work correctly.

Any Idea?

 

 

The native C++ code:

 

 

#include "stdafx.h"
#include <atlbase.h>
#import <RxInventor.tlb> \
rename_namespace("InventorNative") \
named_guids raw_dispinterfaces \
high_method_prefix("Method") \
rename("DeleteFile", "APIDeleteFile") \
rename("CopyFile", "APICopyFile") \
rename("MoveFile", "APIMoveFile") \
rename("SetEnvironmentVariable", "APISetEnvironmentVariable") \
rename("GetObject", "APIGetObject") \
exclude("_FILETIME", "IStream","ISequentialStream", \
"_LARGE_INTEGER", "_ULARGE_INTEGER", "tagSTATSTG", \
"IEnumUnknown","IPersistFile", "IPersist", "IPictureDisp")

using namespace InventorNative;

int main()
{
	::CoInitialize(NULL);

	HRESULT Result = NOERROR;
	//Получение идентификатора Inventor
	CLSID InvAppClsid;
	Result = CLSIDFromProgID(L"Inventor.Application", &InvAppClsid);
	//Получение смарт-указателя на IUnknown
	CComPtr<IUnknown> pInvAppUnk;
	Result = ::GetActiveObject(InvAppClsid, __nullptr, &pInvAppUnk);

	CComPtr<Application> pInvApp;
	//Запрос интерфейса Inventor
	Result = pInvAppUnk->QueryInterface(__uuidof(Application), (void **)&pInvApp);


	IStream *IS = nullptr;

	_bstr_t xml("XML");
	//Result = pInvApp->ActiveDocument->AttributeSets->DataIO->MethodWriteDataToFile(xml, L"D:\\1.txt");
	Result = pInvApp->ActiveDocument->AttributeSets->DataIO->raw_WriteDataToStream(xml, reinterpret_cast<IUnknown**>( &IS));
	::CoUninitialize();
	return 0;
}