June 16, 2003

DisplayExceptionInfo – Displaying error information

‘ A reusable routine that displays error information’ Note: requires Imports System.ReflectionSub DisplayExceptionInfo(ByVal e As Exception) ‘ Display the error message. Console.WriteLine(e.Message) Dim st As New StackTrace(e, True) Dim i As Integer For i = 0 To st.FrameCount – 1 ‘ Get the i-th stack frame. Dim sf As StackFrame

ClipboardSetText – Copying or appending text to the clipboard

‘ copy or append text to the clipboardSub ClipboardSetText(ByVal text As String) ClipboardSetText(text, False)End SubSub ClipboardSetText(ByVal text As String, ByVal append As Boolean) If append Then text = ClipboardGetText() & Environment.NewLine & text End If Clipboard.SetDataObject(text)End Sub

IsAssembly – Check whether a specified file is a .NET assembly

‘ Check whether a specified file is a .NET assemblyFunction IsAssembly(ByVal filename As String) As Boolean Try Dim asm As [Assembly] = [Assembly].LoadFrom(filename) ‘ if no exception is thrown, this is an assembly Return True Catch e As Exception Return False End TryEnd Function

IsComDLL – Check whether a DLL is an COM self-registering server

Shared Function _ LoadLibrary(ByVal path As String) As IntegerEnd Function Shared Function _ GetProcAddress(ByVal hModule As Integer, ByVal procName As String) As _ IntegerEnd Function Shared Sub FreeLibrary _ (ByVal hModule As Integer)End Sub’ Check whether a DLL is an COM self-registering server Function IsComDLL(ByVal filename As String) As Boolean