Search the Community
Showing results for tags 'com variant* bstr*'.
-
Hi ~ I have a OCX file and its IDL like below: // Generated .IDL/C++ pseudo source equivalent of Win32 type library ..\CZEMApi.ocx [ uuid({71BD42C1-EBD3-11D0-AB3A-444553540000}), version(1.0), helpstring("CZ EM API OLE Control") ] library APILib { // Forward references and typedefs dispinterface _EMApi; dispinterface _EMApiEvents; [ uuid({71BD42C2-EBD3-11D0-AB3A-444553540000}), helpstring("Dispatch interface for CZ EM API Control") ] dispinterface _EMApi { properties: [id(0), bindable, requestedit] BSTR Caption; methods: [id(0)] long Set( BSTR lpszParam, VARIANT* vValue); [id(1)] long Get( BSTR lpszParam, VARIANT* vValue); [id(2)] long Execute(BSTR lpszCommand); [id(3)] long Initialise(BSTR lpszMachine); [id(4)] long Grab( short xoff, short yoff, short width, short height, short reduction, BSTR lpszFilename); [id(5)] long GetStagePosition( VARIANT* x, VARIANT* y, VARIANT* z, VARIANT* t, VARIANT* r, VARIANT* m); [id(6)] long MoveStage( single x, single y, single z, single t, single r, single m); [id(7)] long SetNotify( BSTR lpszParameter, long bNotify); [id(8)] long GetLastError(VARIANT* Error); [id(9)] long ClosingControl(); [id(10)] long GetLimits( BSTR lpszParam, VARIANT* vMinValue, VARIANT* vMaxValue); [id(11)] long GetMulti( BSTR lpszParam, VARIANT* vValues); [id(12)] long SetMulti( BSTR lpszParam, VARIANT* vValues); [id(13)] long GetVersion(short* Version); [id(14)] long InitialiseRemoting(); [id(15)] long GetCurrentUserName( BSTR* strServerUserName, BSTR* strNTUserName); [id(16)] long GetUserIsIdle(long* bUserIsIdle); [id(17)] long GetLastRemotingConnectionError(BSTR* strLastConnectionError); [id(18)] long SetSuppressRemotingConnectionErrors(); [id(19)] long LogonToEMServer( BSTR lpszUserName, BSTR lpszUserPassword); [id(20)] long StartEMServer(); [id(21)] long MoveStageDoubles( double x, double y, double z, double t, double r, double m); [id(22)] void AboutBox(); }; [ uuid({71BD42C3-EBD3-11D0-AB3A-444553540000}), helpstring("Event interface for CZ EM API Control") ] dispinterface _EMApiEvents { properties: methods: [id(0)] void Notify( BSTR lpszParameter, long Reason); [id(1)] void NotifyWithCurrentValue( BSTR lpszParameter, long Reason, long paramid, double dLastKnownValue); }; [ uuid({71BD42C4-EBD3-11D0-AB3A-444553540000}), helpstring("CZ EM API Control") ] coclass Api { [default] dispinterface _EMApi; [default, source] dispinterface _EMApiEvents; }; }; My autoit code like: ; CZ EM API OLE Control Local Const $CLSID_API = "{71BD42C4-EBD3-11D0-AB3A-444553540000}" Local $CZEMApi=ObjCreate($CLSID_API) If Not IsObj($CZEMApi) Then MsgBox(4096,"Failed to create APILib.Api object","You may need to run regsvr32 CZEMApi.ocx :error=" & Hex(@error,8)) Exit Else ;MsgBox(4096,"info","success") EndIf $Notify = ObjEvent($CZEMApi,"EMApiEvents_") Func EMApiEvents_Notify($parameter,$reason) MsgBox(4096,"Notify", "Event catchall for " & $parameter & @TAB & $reason & @CR) EndFunc $CZEMApi.Caption = "for test" MsgBox(4096,"caption",$CZEMApi.Caption) Local $long = $CZEMApi.InitialiseRemoting() Local $pVAR = "" Local $result = $CZEMApi.Get("AP_MAG",Ptr($pVAR)) But issue is: "G:\test.au3" (79) : ==> The requested action with this object has failed.: Local $result = $CZEMApi.Get("AP_MAG",Ptr($pVAR)) Local $result = $CZEMApi^ ERROR How to fixed this issue?