This same question has been asked several times within the past 48 hours... search the boards (it was either NogDog or Installer posting code samples... don't remember which).
EDIT: Actually, I didn't even have to search - just browsed the first page of the General Help forum and found this.