Jump to content
Sign in to follow this  
Colyn1337

Help to Understand <ie.au3> UDF and DllStructCreate() Issue

Recommended Posts

Colyn1337

I've been working on a problem using the IE udf and have delved into its code.  Part of what I'm trying to do is get an object from an embedded IE control using it's handle.  In the IE udf there's an internal function which does this:

Func __IEControlGetObjFromHWND(ByRef $hWin)
    ; The code assumes CoInitialize() succeeded due to the number of different
    ; yet successful return values it has.
    DllCall("ole32.dll", "long", "CoInitialize", "ptr", 0)
    If @error Then Return SetError(2, @error, 0)

    Local Const $WM_HTML_GETOBJECT = __IERegisterWindowMessage("WM_HTML_GETOBJECT")
    Local Const $SMTO_ABORTIFHUNG = 0x0002
    Local $lResult

    __IESendMessageTimeout($hWin, $WM_HTML_GETOBJECT, 0, 0, $SMTO_ABORTIFHUNG, 1000, $lResult)

    Local $typUUID = DllStructCreate("int;short;short;byte[8]")
    DllStructSetData($typUUID, 1, 0x626FC520)
    DllStructSetData($typUUID, 2, 0xA41E)
    DllStructSetData($typUUID, 3, 0x11CF)
    DllStructSetData($typUUID, 4, 0xA7, 1)
    DllStructSetData($typUUID, 4, 0x31, 2)
    DllStructSetData($typUUID, 4, 0x0, 3)
    DllStructSetData($typUUID, 4, 0xA0, 4)
    DllStructSetData($typUUID, 4, 0xC9, 5)
    DllStructSetData($typUUID, 4, 0x8, 6)
    DllStructSetData($typUUID, 4, 0x26, 7)
    DllStructSetData($typUUID, 4, 0x37, 8)

    Local $aRet = DllCall("oleacc.dll", "long", "ObjectFromLresult", "lresult", $lResult, "struct*", $typUUID, _
            "wparam", 0, "idispatch*", 0)
    If @error Then Return SetError(3, @error, 0)

    If IsObj($aRet[4]) Then
       _arraydisplay($aRet)
        Local $oIE = $aRet[4] .Script()
        ; $oIE is now a valid IDispatch object
        Return $oIE.Document.parentwindow
    Else
        Return SetError(1, $aRet[0], 0)
    EndIf
EndFunc

The problem I'm experiencing with the UDF is that I get this error:

Return $oIE.Document.parentwindow
Return $oIE.Document^ ERROR
 
Which I tracked down to that section of code up above.  Since the script values the data in $aRet[4] I decided to see what that array has in it.  After the DllCall I added an _arraydisplay($aRet) so I could see what was there.  Much to my chagrin it was blank.  No zero or any kind of data, just white space.  This led me to the DllCall itself and I wanted to see the values being passed to oleacc.dll.  I added a console write to the code just before the DllCall like this:
 
ConsoleWrite("oleacc.dll " & " long " & " ObjectFromLresult " & " lresult " & $lResult & " struct* " & $typUUID  & " wparam " & " 0 " & " idispatch* " & " 0 ")

And got the following output:

oleacc.dll  long  ObjectFromLresult  lresult 49267 struct*  wparam  0  idispatch*  0 49267

 

$1Result is populated with 49267

$typUUID is null

 

The contents of the $aRet array are as follows:

[0]    0

[1]    49267

[2]    

[3]    0

[4]    

Position 4 in the array is what's valued to create the $oIE.Document.parentwindow object to return.  As noted above, position 4 is empty.  This leads me to investigate the $typUUID variable as it is empty as well, after the DllStructCreate().  This leads me to believe that something is wrong with that part of the code, I just don't know what.  

Any suggestions?

Edited by Colyn1337

Share this post


Link to post
Share on other sites
BrewManNH

Are you using this internal function directly, or is it erroring when you use it correctly?


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites
Colyn1337

Both.  I kept getting that error I referenced with using the _IExxx udf which led me to investigate.

Edited by Colyn1337

Share this post


Link to post
Share on other sites
Colyn1337
This is the error info from the error handler.  
 
--> COM Error Encountered in asdf.au3
----> $IEComErrorScriptline = 3633
----> $IEComErrorNumberHex = 80020009
----> $IEComErrorNumber = -2147352567
----> $IEComErrorWinDescription = Access is denied.
----> $IEComErrorDescription = Access is denied.
----> $IEComErrorSource = 
----> $IEComErrorHelpFile = C:WindowsSysWOW64mshtml.hlp
----> $IEComErrorHelpContext = 0
----> $IEComErrorLastDllError = 0
 
Does anyone know if the error is from oleacc.dll or from the application?
Edited by Colyn1337

Share this post


Link to post
Share on other sites

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
Sign in to follow this  

×