Jump to content

!Help - Return Value From a COM object


Recommended Posts

Problem Description:

The $retVal variable below is not returning any value. It should return an encrypted value of the $passwordToEnrypt.

The same code in VB works.

I have tried the following with no luck as well...

$retValue = $test1.EncryptPassword ($passwordToEncrypt, $retVal)

I'm hoping that someone has called a function and needed a return value similar to what I'm trying to do. I don't get any error message. The messagebox is simply blank.

I appreciate any help that you can offer.

$oMyError = ObjEvent("AutoIt.Error","MyErrFunc")
dim $retVal
dim $passwordToEncrypt= "test"
$test = ObjCreate("Session")
$test1 = $test.CreateInstance("Instance.UserName")

$test1.EncryptPassword ($passwordToEncrypt, $retVal)

Msgbox(0,"Encrypted Password", $retVal)

Func MyErrFunc()
  $HexNumber=hex($oMyError.number,8)
  Msgbox(0,"AutoItCOM Test","We intercepted a COM Error !"       & @CRLF  & @CRLF & _
             "err.description is: "    & @TAB & $oMyError.description    & @CRLF & _
             "err.windescription:"     & @TAB & $oMyError.windescription & @CRLF & _
             "err.number is: "         & @TAB & $HexNumber              & @CRLF & _
             "err.lastdllerror is: "   & @TAB & $oMyError.lastdllerror   & @CRLF & _
             "err.scriptline is: "     & @TAB & $oMyError.scriptline     & @CRLF & _
             "err.source is: "         & @TAB & $oMyError.source         & @CRLF & _
             "err.helpfile is: "       & @TAB & $oMyError.helpfile       & @CRLF & _
             "err.helpcontext is: "    & @TAB & $oMyError.helpcontext _
            )
  SetError(1)  ; to check for after this function returns
  Exit
Endfunc
Link to comment
Share on other sites

  • Moderators

Do you have the actual function from VB, because this does return an error for me (ObjCreate).

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

  • 1 year later...

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...