www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - GC and win32

reply bobef <bobef_member pathlink.com> writes:
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?
Apr 03 2005
next sibling parent Stewart Gordon <smjg_1998 yahoo.com> writes:
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.
Apr 03 2005
prev sibling parent Ben Hinkle <Ben_member pathlink.com> writes:
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
Apr 03 2005