Solved

DirectShow Interface releasing

Posted on 2004-04-25
2
473 Views
Last Modified: 2012-08-13
Hi.

I have a probblem releasing the DirectShow Interfaces previously allocated. Example:

var
  gb: IGraphBuilder;
  mc: IMediaControl;

...
CoCreateInstance(CLSID_FilterGraph, nil, CLSCTX_INPROC_SERVER, IID_IGraphBuilder, gb);
gb.QueryInterface(IID_IMediaControl, mc);
...
if(mc<>nil) then
begin
  mc._Release;
  mc:=nil;
end;
if(gb<>nil) then
begin
  gb._Release;
  gb:=nil;
end;

I always receive a Access violation. Do you know what may be causing this?

PS:
I'm using the DirectShow header from www.progdigy.com.
Thanks.
0
Comment
Question by:BlueAlien
2 Comments
 
LVL 26

Accepted Solution

by:
Russell Libby earned 125 total points
ID: 10913471

Delphi's interface pointers are considered smart pointers, meaning this: versions since Delphi3 provide automatic management of interface variables, so calling

mc:=nil;

will handle calling the interface Release for you, thus you should *never* (almost never) call Release yourself. As well, if the variable is local in scope, the interface will be released for you at the end of the function/procedure if the variable is non nil. So, as a general rule of thumb, you will almost never need to call AddRef/Release on interface pointers. (The only exceptions would be in rare cases where the interface is cast and held as a generic pointer type.)

Regards,
Russell
0
 

Author Comment

by:BlueAlien
ID: 10917518
Thanks.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
oracle global variables 4 79
Making delphi communicate with a c# service 16 119
Dev Express grid collapse 2 47
can't find the executable in Simulator 1 111
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

679 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question