December 2, 2002

COM+, ErrObject, and Co.

am sure you have already found out why you should be wary of static, application-global and module-global variables in COM+ components written in VB. As for me, one wonderful day I was a bit surprised at the ungrateful behavior of static variables while testing VB COM+ components under pressure. Anyway

MK? And CV? – Convert numbers to strings and back

The following routines convert a numeric value into a string that represents the number, and vice versa. They are useful for reading data written by QuickBasic programs, because the QuickBasic language functions that did the conversions were not ported to Visual Basic. Points to note: 1. These routines are a

Be careful when installing SHLWAPI.DLL with Visual Installer

I happened to come across a serious problem when installing my own software with Visual Installer 1.1: the installation of my product on Windows 98 computers caused a system crash during the next Windows start-up. The only way to fix things was to reinstall Windows from CD, over the existent

Retrieving (from a VB6 program) the installed versions of the .NET Framework

‘ Return a collection of strings that identify the installed versions of the ‘ .NET Framework’ Note: this function require the EnumRegistryKeys and EnumRegistryValues ‘ functions’ Example:’ Dim version As Variant’ For Each version In GetDotNetFrameworkVersions’ Debug.Print version’ NextFunction GetDotNetFrameworkVersions() As Collection Const HKEY_LOCAL_MACHINE = &H80000002 Dim keyName As String

Checking (from a VB6 program) whether the .NET Framework is present

‘ Return a Boolean value indicating whether the .NET Framework is installed’ Note: this function require the CheckRegistryKey functionsFunction IsDotNetFrameworkPresent() As Boolean Const HKEY_LOCAL_MACHINE = &H80000002 IsDotNetFrameworkPresent = CheckRegistryKey(HKEY_LOCAL_MACHINE, _ “SoftwareMicrosoft.NETFramework”)End Function

Be careful in using CreateObject with two arguments

If you install a COM+ application proxy on a client and open its Properties dialog, you’ll see that the field “Remote Server Name” is set to the server where you created and exported the application. Before you export the component, you can also change the server name by setting the

Dynamically setting an event handler for a class’ event via reflection

Here it is some code that shows how to use reflection to dynamically set an event handler for a class’ event. Sub TestSub() ‘ create a Person Dim pe As New Person() ‘ get a reference to the EventInfo for this object Dim peEv As EventInfo = pe.GetType.GetEvent(“PropertyChanged”) ‘ create

Get Mouse Position Anywhere, Anytime

Some control events provide the mouse pointer’s current position within the control’s client area; others provide only the screen coordinates of the mouse pointer (the same as returned by Cursor.Position). Is there a function that tells you where the mouse is positioned within a specific control? Well, no… Cursor.Position is