Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to free a Interface?

Tags:

delphi

i'm new with this thing named interface and DirectX. I'm hooking a DirectX Interface from a certain game and i'm using the DirectX to Draw My Own stuff,like textures and Fonts. My problem are that: When the program call the Hooked Reset Function of the Device,i need to clear all my things from the memory,the Com Interfaces.If i not clear,after the Reset event are called,the Game just try to create a new surface calling d3dDierctx9Create but its fail and just make a error and close the game.

I think that i just need to clear all the things before the Reset Event,its is explained on Msdn.

like image 427
Cristofer Martins Avatar asked Oct 30 '10 22:10

Cristofer Martins


1 Answers

You don't free an interface. It's reference-counted and managed by the compiler. Let it go out of scope, assign a different interface to the variable, or assign nil to it, and the compiler will generate a call to its _Release method automatically so it can clean itself up when its reference count drops to 0.

like image 123
Mason Wheeler Avatar answered Sep 28 '22 08:09

Mason Wheeler