Search the Community
Showing results for tags 'ocx'.
-
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?
-
Hi all, My programming knowledge is very basic. I have an old script that creates shares and assign permissions. It normally registers SetAcl.ocx if necessary and creates an object to assign permissions. The command that registers SetAcl was apparently working fine under Windows 7 but is not working under Windows 10. RunWait("regsvr32.exe path\to\setacl.ocx /s", "", @SW_HIDE) As I'm logged in as admin, I changed this command to : RunAsWait(@UserName, "", "", 0, "regsvr32.exe path\to\setacl.ocx /s", "", @SW_HIDE) It seems to terminate correctly but the script still doesn't work as expected. To check that, I've created that small script : Local $objSetAcl = ObjCreate("SETACL.SetACLCtrl.1") If IsObj($objSetAcl) Then ConsoleWrite("Object successfully created." & @CRLF) Else ConsoleWrite("Object not created. Registering SetAcl.ocx" & @CRLF) Local $result = RunAsWait(@UserName, "", "", 0, "regsvr32.exe path\to\setacl.ocx /s", "", @SW_HIDE); Use of my admin username to elevate CMD ConsoleWrite("Return code : " & $result & @CRLF) ConsoleWrite("Creating object" & @CRLF) $objSetAcl = ObjCreate("SETACL.SetACLCtrl.1") If IsObj($objSetAcl) Then ConsoleWrite("Object successfully created." & @CRLF) Else ConsoleWrite("Object creation failed." & @CRLF) EndIf EndIf It tries to register SetAcl.ocx, return code 0 seems to be fine but still can't use SetAcl. But if I go to CMD as admin, run the regsvr32 command and restart my script, it can create the object without issue. I know my poor knowledge makes me miss something. Anyone can help me figure this out ?