Wednesday, July 30, 2008

Friday, July 25, 2008

Friday, July 18, 2008

Don't catch NullReferenceException

Consider the function:

private string GetObjectValue(object param)
                    return param.value.ToString();
                catch (NullReferenceException)
                    return "";

It would be much better to do this:

private string GetObjectValue(object param)
                if (param != null)
                    return param.ToString();
                    return "";

Exceptions are expensive. 
Handling the error adds an average of 16 ticks to the execution in my testing. This will add up.

Thursday, July 17, 2008

Installshield conditions

The condition for a first time install is:
Not Installed

For a complete uninstall:

For any maintenance operation (repair, modify, uninstall, anything except first time install):

The above came in handy when I ended up wrting this to not display a messagebox on a silent install:

function WarnUserIfNotSilent(hMSI)
  STRING szProperty;
  NUMBER iSize;
  iSize = 256;
  if (MsiGetProperty (ISMSI_HANDLE, "UILevel", szProperty, iSize) = ERROR_SUCCESS) then
    if (StrCompare(szProperty, "2") != 0) then
      MessageBox("A message.", WARNING);    

Wednesday, July 16, 2008

Why do I work in IT?

Because it affords me the opportunity to make things simpler and easier for people. Improving lives through technology.

It's also a relatively new industry and while this can sometimes be frustrating, it's also exciting and there's always something new to learn.

Monday, July 14, 2008

Friday, July 04, 2008