mikeobrien.net Curriculum Vitae Blog Labs
Friday, January 29, 2010

The following is an implementation of a safe handle for a device info set:

type DeviceInfoSetSafeHandle() = 
    inherit SafeHandleMinusOneIsInvalid(true)
    [<DllImport("setupapi.dll")>]
    static extern bool SetupDiDestroyDeviceInfoList(IntPtr deviceInfoSet)
    override s.ReleaseHandle() = SetupDiDestroyDeviceInfoList(base.DangerousGetHandle())

It’s extremely trivial to set this up that it’s almost not worth blogging about but maybe someone can benefit from the example...

.NET | F#
Name
E-mail
(will show your gravatar icon)
Home page

Comment (Some html is allowed: a@href@title, b, i, strike, strong, u) where the @ means "attribute." For example, you can use <a href="" title=""> or <blockquote cite="Scott">.  

Enter the code shown (prevents robots):

Live Comment Preview
Creative Commons License