Thread overview
GC and win32
Apr 03, 2005
bobef
Apr 03, 2005
Stewart Gordon
Apr 03, 2005
Ben Hinkle
April 03, 2005
For some Win32 functions, like ImageList_GetIcon, msdn says:

It is the responsibility of the calling application to destroy the icon returned from this function using the DestroyIcon function.

But it is written for C. There is no GC. Do this apply to D also or the GC will take care of it?


April 03, 2005
bobef wrote:

> For some Win32 functions, like ImageList_GetIcon, msdn says:
> 
> It is the responsibility of the calling application to destroy the icon returned
> from this function using the DestroyIcon function. 
> 
> But it is written for C. There is no GC. Do this apply to D also or the GC will
> take care of it?

D knows nothing of Windows system objects.  As such, you have to delete them yourself.

Of course you can create a wrapper class with a destructor to do this work.

Stewart.

-- 
My e-mail is valid but not my primary mailbox.  Please keep replies on on the 'group where everyone may benefit.
April 03, 2005
In article <d2pegv$i1$1@digitaldaemon.com>, bobef says...
>
>For some Win32 functions, like ImageList_GetIcon, msdn says:
>
>It is the responsibility of the calling application to destroy the icon returned from this function using the DestroyIcon function.
>
>But it is written for C. There is no GC. Do this apply to D also or the GC will take care of it?

It depends on how you keep track of the icon. If you store it in an object then
you can use the object destructor to release the icon. Otherwise you have to
explicitly release the icon when you are done with it. See the section
http://www.digitalmars.com/d/class.html#destructors
and
http://www.digitalmars.com/d/garbage.html

-Ben