Jump to content

Recommended Posts

Posted

So I'm messing with this god damned COM stuff again. This time I'm trying to implement DirectShow in autoit, but as usual when I deal with this kind of stuff I meet tons of problems. ^_^

However since DirectShow implements IDispatch I thought that maybe this could work without too much problems.

The code I'm translating is a C++ example found on this page.

This is the code I have at the moment:

CODE

Global Const $CLSCTX_INPROC = 3

Global Const $tagGUID = "long Data1;short Data2;short Data3;char Data4[8]"

DllCall("ole32.dll", "long", "CoInitialize", "ptr", "")

$clsidfilter = CLSID_FilterGraph()

$iidgraphbuilder = IID_IGraphBuilder()

$call = DllCall("ole32.dll", "int", "CoCreateInstance", "ptr", DllStructGetPtr($clsidfilter), "ptr", 0, "dword", $CLSCTX_INPROC, "ptr", DllStructGetPtr($iidgraphbuilder), "idispatch*", "")

MsgBox(0,"Did we get an object?",1=IsObj($call[5]))

$iidimediacontrol = IID_IMediaControl()

$ptr = DllStructCreate("ptr")

$ptr2 = DllStructCreate("ptr")

DllStructSetData($ptr2, 1, DllStructGetPtr($ptr))

$oGraphBuilder = $call[5]

;~ $oGraphBuilder.QueryInterface(DllStructGetPtr($iidimediacontrol), DllStructGetPtr($ptr))

$oGraphBuilder.Release()

Func CLSID_FilterGraph()

$guid = DllStructCreate($tagGUID)

DllStructSetData($guid, "Data1", 0xe436ebb3)

DllStructSetData($guid, "Data2", 0x524f)

DllStructSetData($guid, "Data3", 0x11ce)

DllStructSetData($guid, "Data4", 0x9f, 1)

DllStructSetData($guid, "Data4", 0x53, 2)

DllStructSetData($guid, "Data4", 0x00, 3)

DllStructSetData($guid, "Data4", 0x20, 4)

DllStructSetData($guid, "Data4", 0xaf, 5)

DllStructSetData($guid, "Data4", 0x0b, 6)

DllStructSetData($guid, "Data4", 0xa7, 7)

DllStructSetData($guid, "Data4", 0x70, 8)

Return $guid

EndFunc ;==>CLSID_FilterGraph

Func IID_IMediaControl()

$guid = DllStructCreate($tagGUID)

DllStructSetData($guid, "Data1", 0x56a868b1)

DllStructSetData($guid, "Data2", 0x0ad4)

DllStructSetData($guid, "Data3", 0x11ce)

DllStructSetData($guid, "Data4", 0xB0, 1)

DllStructSetData($guid, "Data4", 0x3A, 2)

DllStructSetData($guid, "Data4", 0x00, 3)

DllStructSetData($guid, "Data4", 0x20, 4)

DllStructSetData($guid, "Data4", 0xAF, 5)

DllStructSetData($guid, "Data4", 0x0B, 6)

DllStructSetData($guid, "Data4", 0xA7, 7)

DllStructSetData($guid, "Data4", 0x70, 8)

Return $guid

EndFunc ;==>IID_IMediaControl

Func IID_IGraphBuilder()

$guid = DllStructCreate($tagGUID)

DllStructSetData($guid, "Data1", 0x56A868A9)

DllStructSetData($guid, "Data2", 0x0AD4)

DllStructSetData($guid, "Data3", 0x11CE)

DllStructSetData($guid, "Data4", 0xB0, 1)

DllStructSetData($guid, "Data4", 0x3A, 2)

DllStructSetData($guid, "Data4", 0x00, 3)

DllStructSetData($guid, "Data4", 0x20, 4)

DllStructSetData($guid, "Data4", 0xAF, 5)

DllStructSetData($guid, "Data4", 0x0B, 6)

DllStructSetData($guid, "Data4", 0xA7, 7)

DllStructSetData($guid, "Data4", 0x70, 8)

Return $guid

EndFunc ;==>IID_IGraphBuilder

As you can see if running the code the code crash when the QueryInterface method is called (The crash location is in quartz.dll so I think we have a valid object at least).

My first thought was then that this probably is AutoIt's limitation on ByRef params in method calls that begins to show up again. But then I tested calling the release method and it still crashed so smoething else is wrong.

Anyone with more COM knowledge than me that can give this a shot?

Broken link? PM me and I'll send you the file!

Posted

I created an objectbase.au3 wich simplifies the code a bit. It should be included in the DL here: http://www.autoitscript.com/forum/index.ph...c=90831&hl=

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

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
  • Recently Browsing   0 members

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