Solved

DirectShow Interface releasing

Posted on 2004-04-25
2
475 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Technology Partners: 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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
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…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses
Course of the Month11 days, 18 hours left to enroll

623 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