require 'general/pcall/ole32'
coinsert 'pole32'
'IJ_'idef IJ=: IDispatch,;:;<;._2(0 : 0)
Do Show Log IsBusy Break Quit Get Set GetM SetM ErrorText
ErrorTextM Clear Transpose ErrorTextB GetB SetB DoR
)
ijDoR=: [:'ci3 > i i i *w *i *i' pcall IJ_DoR ; ;
CLSID_JDLLServer=: '{21EB05EC-1AB3-11CF-A2AC-8FF70874C460}'
h clsid=. 2{::'ole32 CLSIDFromProgID i *w *c'cd 'JDLLServer';1#GUID
h iid=. 2{::'ole32 CLSIDFromString i *w *c'cd CLSID_JDLLServer;1#GUID
h J=. {._1{::'ole32 CoCreateInstance i *c i i *c *i'cd clsid;0;CTX;iid;,_2
res=. i.4%~#VAR1 NB. alloc VARIANT for BSTR
'ci3 > i i i *w *i *i' pcall IJ_DoR;J;'9!:14$0';res;,_2
VariantStr res NB. BSTR string value
'oleaut32 VariantClear > i *i' cd <res NB. free BSTR, 'cause we own it
h IT=. {._1{::'ci3 i i i i i *i' pcall IJ_GetTypeInfo;J;0;0;,_2
pta=. ,_2
'ci1 > i i i *i' pcall IT_GetTypeAttr;IT;pta
] cf=. (TYPEATTR si 'Cf') mS pta NB. count of functions in J interface
#IJ
pfd=. ,_2
'ci2 > i i i i *i' pcall IT_GetFuncDesc;IT;IJ_IsBusy;pfd
h mid=. 0 mI pfd
res=. ,_2
h 'ci5 > i i i i *i i i i' pcall IT_GetDocumentation;IT;mid;res;0;0;0
GetStr res NB. name of function
'oleaut32 SysFreeString > i i' cd res
'ci0 > i i i' pcall IT_Release;IT
'ci0 > i i i' pcall IJ_Release;J NB. destroys J object, RefCount=0