Rewrite application from VB to C++ and get error 0070
See the question and my original answer on StackOverflowYou'll have to learn a bit of C++ to be able to do this.
Also just have a look at the .tlh
(and possibly .tli
) file that was generated in the output folder by Visual Studio.
So, here is how to instantiate and call the COM object (for example using the Windows SDK tools/wrappers from comdef.h like _bstr_t
):
#include <windows.h>
#import "COM.tlb" raw_interfaces_only, raw_native_types, no_namespace, named_guids
int main()
{
CoInitialize(NULL);
{
IPersonPtr per(__uuidof(Person)); // equivalent of CoCreateInstance(CLSID_Person,..., IID_IPerson, &person)
per->put_FirstName(_bstr_t(L"Maxim"));
per->put_LastName(_bstr_t(L"Donax"));
per->Persist(_bstr_t(L"c:\\myFile.xml"));
}
CoUninitialize();
return 0;
}
Or a bit more simple (use convenient wrappers automagically generated):
#include <windows.h>
#import "COM.tlb"
using namespace COM; // your namespace, COM is probably not a good namespace name
int main()
{
CoInitialize(NULL);
{
IPersonPtr per(__uuidof(Person));
per->PutFirstName(L"Maxim");
per->PutLastName(L"Donax");
per->Persist(L"c:\\myFile.xml");
}
CoUninitialize();
return 0;
}