DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

VC++ application to link to Diadem via OLE

Hello,
 
I wrote a script in Diadem and now I want to call this script out of a VC++ application. 
I'm not so familiar with the VC++ environment and how to implement the diadem .tlb (OLE) in it.
 
Can someone give me an advice about this proceeding and the creation of the diadem-object to work on it, with the
methods CMDExecuteSync, IntegerVarGet / IntegerVarSet, e.g.
Some lines of program in C++ will help me understand the access. 
 
Thanks,
JB
 
 
 
 
0 Kudos
Message 1 of 5
(3,546 Views)
Hi JB,
 
below there is an example to link to DIAdem via OLE.
I've written the code with Visual Studio 2005.
Copy the DIAdem.tlb from the DIAdem program directory into the source directory or modify the import path.
Alternatively to the #import mechanism you can generate an MFC class from the type library.

#include

<Windows.h>

#import

"DIAdem.tlb" no_namespace

int

_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;

}

I hope that helps,
 
Christian
0 Kudos
Message 2 of 5
(3,536 Views)

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;

}

I hope that helps,
 
Christian
0 Kudos
Message 3 of 5
(3,530 Views)

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

0 Kudos
Message 4 of 5
(3,524 Views)

Thanx a lot Christian,

it worksSmiley Very Happy

 

0 Kudos
Message 5 of 5
(3,512 Views)