monoceres Posted April 22, 2009 Share Posted April 22, 2009 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:CODEGlobal Const $CLSCTX_INPROC = 3Global 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 $guidEndFunc ;==>CLSID_FilterGraphFunc 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 $guidEndFunc ;==>IID_IMediaControlFunc 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 $guidEndFunc ;==>IID_IGraphBuilderAs 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! Link to comment Share on other sites More sharing options...
monoceres Posted April 22, 2009 Author Share Posted April 22, 2009 (edited) Meh, I just realized QueryInterface is the same crap as last time.http://www.autoitscript.com/forum/index.ph...=QueryInterfaceGuess I know how to solve it then. Edited April 22, 2009 by monoceres Broken link? PM me and I'll send you the file! Link to comment Share on other sites More sharing options...
ProgAndy Posted April 22, 2009 Share Posted April 22, 2009 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 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