71
Problems & Solutions / Re: COM OLE
« Last post by JRS on March 22, 2021, 12:32:05 PM »I'll give that a try.
Thanks for the reply!
Thanks for the reply!
'09:33 21/03/2021
' O2 Sage BOI
$filename "t.exe"
uses COM/COMutil
function CallByNameSV(IDispatch *vi, word flag, BSTR name, BSTR *sa=null, int c=0, VARIANT *vr=null) as int
===========================================================================================================
int i
VARIANT va[8] 'up to 8 params
indexbase 1
'
for i=1 to c
va[i].vt=VT_BSTR
?va[i].bstrVal=?sa[i] 'direct coupling
next
'
err=CallByNameV(vi, flag, name, va, c, vr) 'VARIANT morph
'
for i=1 to c
frees sa[i]
next
return err
end function
macro ObjectByName(vi,fl,nf,sa,sr, rv)
========================================
idispatch *sr
VARIANT rv
CallByNameSV(vi, fl, nf, sa, countof, rv)
@sr=@rv.ppdispVal
end macro
CoInitialize null
CreateInterfaceByName "ProvideX.Script" oscript
CallByName(oscript, "Init", BSTR {"C:\Sage\Sage 100 Standard\MAS90\Home"})
'SB>>
'osession = COM::CBN(oscript, "NewObject", :SET, "SY_Session")
'longhand:
'idispatch *osession
'VARIANT rv
'CallByNameSV(oscript, SET, "NewObject", BSTR {"SY_Session"}, countof, rv)
'@osession=@rv.ppdispVal
ObjectByName(oscript, SET, "NewObject", BSTR {"SY_Session"},osession)
print @osession 'check pointer
oscript.Release
CoUninitialize