04-17-2007 03:59 AM
04-17-2007 07:46 AM
#include
<Windows.h>#import
"DIAdem.tlb" no_namespaceint
_tmain(int argc, _TCHAR* argv[]){
// Initialize OLE.::
CoInitialize(NULL); ITOCommandPtr pITOCommandT; pITOCommandT.CreateInstance("DIAdem.ToCommand"); pITOCommandT->CmdExecuteSync(_variant_t("RootPropSet(\"Author\", \"Test\")")); pITOCommandT->CmdExecuteSync(_variant_t("MsgBoxDisp(RootPropGet(\"Author\"))")); _variant_t ValueT; pITOCommandT->TextVarGet("RootPropGet(\"Author\")", &ValueT);::
MessageBox(NULL, _bstr_t(ValueT), L"MyTitle", MB_OK); return 0;}
04-17-2007 09:30 AM
Thanx Christian,
I was trying to understand your code, but there are still some problems.
"ITOCommandPtr pITOCommandT" I read as "ITOCommand *pITOCommandT" is this correct?
But then I wondered about "pITOCommandT.CreateInstance("DIAdem.ToCommand");"
Do you want to call a method in the way :"pITOCommandT->..." or what does it mean, because the specific method does'nt exist.
Is this the instruction after that the DIADEM-application will be started or how does this proceed?
The following lines are clear.
Kind regards,
JB
::CoInitialize(NULL);
ITOCommandPtr pITOCommandT;
pITOCommandT.CreateInstance("DIAdem.ToCommand");
pITOCommandT->CmdExecuteSync(_variant_t("RootPropSet(\"Author\", \"Test\")"));
pITOCommandT->CmdExecuteSync(_variant_t("MsgBoxDisp(RootPropGet(\"Author\"))"));
_variant_t ValueT;
pITOCommandT->TextVarGet("RootPropGet(\"Author\")", &ValueT);
::MessageBox(NULL, _bstr_t(ValueT), L"MyTitle", MB_OK);
return 0;
}
04-17-2007 10:00 AM
Hi JB,
pITOCommandT is smart pointer. ITOCommandPtr itself has a method CreateInstance and an overloaded operator -> to behave like a pointer.
Follow this link to learn more about using #import: http://support.microsoft.com/kb/169496/en-us
As I mentioned you can alternatively use the MFC class wizard to generate a class from the tlb file.
When having created such a class the syntax is:
ITOCommand ITOCommandT;
ITOCommandT.CreateDispatch("DIAdem.ToCommand");
ITOCommandT.CmdExecuteSync(COleVariant("RootPropSet('Author', 'Test')"));
Christian
04-18-2007 05:45 AM
Thanx a lot Christian,
it works