Pointers in extern DLL functions

Xavi __nospam at nospam.com
Sun Dec 23 09:25:12 PST 2007


Xavi Wrote:

> Hi all, 
> 
> I have a doubt, for example; is safe to send the pointer returned by toUTF16z() to a DLL extern function like in this code? 
> Can the GC delete it while the extern function is running? Do I need to keep it in a variable to avoid its deletion?
> 
> capCreateCaptureWindowW(toUTF16z(title), 0, 0, 0, 0, 0, hwnd, 0); 
> 
> 
> And in this code using a cast? Is there any possible problem here? 
> 
> SendMessageW(hwnd, 0, 0, cast(uint)toUTF16z(file)); 
> 
> 
> Or do I need to code it this way keeping it in "wfile"? 
> 
> wchar *wfile = toUTF16z(file); 
> SendMessageW(hwnd, 0, 0, cast(uint)wfile); 
> 
> Thank you, cheers, 
> 
> Xavi
> 


Thanks for your replies Jarrett, BCS and bearophile ; )

Cheers, 
Xavi


More information about the Digitalmars-d-learn mailing list