Code Review FUN!

Legacy code can be fun!
How many wrongs make a right? The more the merrier?

Public Function ConvertSDToStringSD(ByVal securityDescriptor() As Byte, ByVal securityInfo As Integer) As String

Dim pStringSD As IntPtr
Dim stringSDLen As Integer
Dim success As Boolean = ConvertSecurityDescriptorToStringSecurityDescriptor(securityDescriptor, 1, securityInfo, pStringSD, stringSDLen)
‘ The following ensures that the memory allocated to pStringSD by the unmanaged
‘ Win32 API is freed.

If Not success Then

Throw New System.ComponentModel.Win32Exception(Marshal.GetLastWin32Error)

End If
Return Marshal.PtrToStringAuto(pStringSD, stringSDLen)


If (pStringSD IntPtr.Zero) Then


End If
pStringSD = IntPtr.Zero

End Try

End Function

TOM ANGRY, can you guess why?

One thought on “Code Review FUN!

Leave a Reply

Your email address will not be published. Required fields are marked *

Solve this: Time limit is exhausted. Please reload CAPTCHA.

This site uses Akismet to reduce spam. Learn how your comment data is processed.