Re: Another basic question



Michael C <nospam@xxxxxxxxxx> wrote:
"Karl E. Peterson" <karl@xxxxxxxx> wrote ...
I think I've used Debug.Print CloseHandle (or DestoryWindow or similar) in
a few cases, to diagnose oddities, but I've certainly never found the need
to worry about passing 0 to that function. That's pretty harmless in the
grand scheme of things.

You missed the point though. Quite often we get straight VB code and VB code
using APIs that work very differently. Many developers don't check the
return codes from APIs and if there is a fault they ignore it. The results
in one lot of code that raises errors and another lot that ignores errors.
I'm sure some VB code will ignore errors closing handles so in this case it
might be ok to ignore the error but it's a *very* good idea to at least use
a debug.assert on it. If that is being done it's a good idea to check if the
handle is zero beforehand in case it gives an invalid handle error.

In general, yeah, I agree. In *this* specific case -- CloseHandle -- I've yet to
see it matter. YMMV.
--
..NET: It's About Trust!
http://vfred.mvps.org


.



Relevant Pages

  • Re: Texture clamping
    ... transformations. ... worry any more about handedness differences. ... restrictions on matrix conventions, not the APIs:) ...
    (comp.graphics.api.opengl)
  • RE: Getting the Windows Groups for the Logged On User
    ... Use PInvoke to call Win32 GetTokenInformation API to TOKEN_INFORMATION_CLASS.TokenGroups, passing in the HttpContext.Current.User.Identity.Token as the parameter as the token handle. ... (More extensive support for Win32 APIs, ...
    (microsoft.public.dotnet.security)
  • RE: Getting the Windows Groups for the Logged On User
    ... Use PInvoke to call Win32 GetTokenInformation API to TOKEN_INFORMATION_CLASS.TokenGroups, passing in the HttpContext.Current.User.Identity.Token as the parameter as the token handle. ... (More extensive support for Win32 APIs, ...
    (microsoft.public.dotnet.framework.aspnet.security)