Jeffoo Posted November 16, 2010 Share Posted November 16, 2010 I am trying to create a COM object in my code however it can't seem to find the class path. I am using (libraryname).(classname) like I have in visual basic applications that use this same object. I am pretty sure I have the name right. Anyways. There are actually two dll's one I believe is a com dll (since it has a LIBOCX.dll and I find it in the OLE/COM viewer) and the other is not. Now when I open the OLE/COM Object Viewer I do not see the library anywhere under Object Classes however I do see it under Type Libraries. What is the difference or is there any? Or is there any way I can specifically register this com library for my application? Link to comment Share on other sites More sharing options...
Jeffoo Posted November 16, 2010 Author Share Posted November 16, 2010 Should I have put this in a different forum category? Link to comment Share on other sites More sharing options...
JohnOne Posted November 16, 2010 Share Posted November 16, 2010 What you should do, is post your fail code. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Jeffoo Posted November 16, 2010 Author Share Posted November 16, 2010 $dll = DllOpen("C:\ACVSDK\ACVSDK.dll") Global $g_eventerror = 0 $oMyError = ObjEvent("AutoIt.Error","MyErrFunc") ; $oShell = ObjCreate("ACVOCXLib.TxtrCtl") MsgBox(0, "", @error) $oShell.Init MsgBox(0, "", @error) $oShell.Term DllClose($dll) Func MyErrFunc() $HexNumber=hex($oMyError.number,8) Msgbox(0,"","We intercepted a COM Error !" & @CRLF & _ "Number is: " & $HexNumber & @CRLF & _ "Windescription is: " & $oMyError.windescription ) $g_eventerror = 1 ; something to check for when this function returns Endfunc The first error it encounters is an invalid class string, then the next is "variable must be of type object" but I can understand that if the object is never created. I have tried putting the DLL in the same directory as the autoit script but it still does not work. Link to comment Share on other sites More sharing options...
trancexx Posted November 16, 2010 Share Posted November 16, 2010 $dll = DllOpen("C:\ACVSDK\ACVSDK.dll") Global $g_eventerror = 0 $oMyError = ObjEvent("AutoIt.Error","MyErrFunc") ; $oShell = ObjCreate("ACVOCXLib.TxtrCtl") MsgBox(0, "", @error) $oShell.Init MsgBox(0, "", @error) $oShell.Term DllClose($dll) Func MyErrFunc() $HexNumber=hex($oMyError.number,8) Msgbox(0,"","We intercepted a COM Error !" & @CRLF & _ "Number is: " & $HexNumber & @CRLF & _ "Windescription is: " & $oMyError.windescription ) $g_eventerror = 1 ; something to check for when this function returns Endfunc The first error it encounters is an invalid class string, then the next is "variable must be of type object" but I can understand that if the object is never created. I have tried putting the DLL in the same directory as the autoit script but it still does not work. You have to register that server (COM server, that is). There are two ways; regsvr.exe or this function:Func _RegisterServer($sDll) Local $fInit, $fError Local $aCall = DllCall("ole32.dll", "long", "OleInitialize", "ptr", 0) If Not @error Then $fInit = $aCall[0] <> 1 ; The COM library is already initialized $aCall = DllCall($sDll, "long", "DllRegisterServer") If @error Then $fError = True If $fInit Then DllCall("ole32.dll", "none", "OleUninitialize") If $fError Then Return SetError(2, 0, False) Return SetError($aCall[0] <> 0, $aCall[0], $aCall[0] = 0) EndFunc In both cases admin privileges are needed. Another way that's much more simpler and yet much more advanced is using AutoItObject and function _AutoItObject_ObjCreateEx. In this case you don't need admin privileges. Dll is accessed just as with DllCall. Every method is exported function. In the help file for AutoItObject you have an example for this function. ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now