Me and five of my friends are working on a project. We use Visual Source Safe for our code. Last week, an unfortunate incident happened with us, just a day before our project release. I found that the code which I checked in VSS a day before was missing. When I asked my friends about this, we found that, one of them had unknowingly overwritten that piece of code in VSS with the one that he was working on.
Then we thought it would be better if in future we can auto-notify each other about our code add/checking in VSS through some way. Then I read an article in MSDN written in VC++ describing how we can intercept VSS events, while we perform any operation on them. Moreover I learnt about Outlook Redemption Library which helps us to send emails programmatically bypassing security alert dialog boxes. With the help of this all, I developed this simple VSS addin in Visual Basic.
After installing (which is as simple as this addin) this addin, whenever you perform any operation on VSS, an email will be sent to all your friends. The email will be sent when you logout from VSS and will consist of a summary of operations you have performed during that VSS session. The email will be sent using the default email account configured in your Outlook. Moreover no security check dialog boxes will be shown during all these operations.
- Outlook Redemption Library
- Copy the VSSVBAddin.dll into the %SystemRoot%\System32 folder.
- From a command prompt, register VSSVBAddin.dll with the following command:
- Create a file named Ssaddin.ini in the VSS\Win32 folder where the Ssapi.dll file is registered (in other words, the folder where you installed Visual SourceSafe). This folder should also be the folder that the following registry key points to:
- Open the Ssaddin.ini file and add the following line to it:
VSSVBAddin.AddinClass = 1
- Create a file named maillist.txt in the folder where your Visual Source Safe Database srcsafe.ini is placed.
- Open the file and write the email id of all your team members, one on each new line. e.g.<
Using the Code
Visual source safe provides a method to trap and control its various events such as
BeforeAdd, BeforeCheckIn, .... through the use of addins. This code implements these events and whenever a operation is performed on VSS, it adds the details related to those operations to a global string variable
Sub VSSHandler_AfterAdd(ByVal Item As IVSSItem, ByVal LocalSpec As _
String, ByVal Comment As String)
If Comment <> "" Then
str = str & vbCrLf & "Added: " & _
Item.Parent.Spec & "/" & Item.Name & _
" at : " & Now & ", Commented : " & Comment
str = str & vbCrLf & "Added: " & _
Item.Parent.Spec & "/" & _
Item.Name & " at : " & Now
Later on, when user exits the VSS,
Class_Terminate is called. Here we read the mail id of all the recipients from maillist.txt file placed on the same path as srcsafe.ini file of VSS database itself. Then we send a mail to all those recipients using Redemption Library (which uses your default email account configured on Outlook).
Private Sub Class_Terminate()
On Error GoTo Mailing_Error
If str <> "" Then
Dim SafeItem, oItem
Set Application = CreateObject("Outlook.Application")
Set Namespace = Application.GetNamespace("MAPI")
Set SafeItem = CreateObject("Redemption.SafeMailItem")
Set oItem = Application.CreateItem(0)
SafeItem.Item = oItem
Dim nFileNum As Integer, sNextLine As String
nFileNum = FreeFile
Open Left$(VSSHandler.VSSDatabase.SrcSafeIni, _
Len(VSSHandler.VSSDatabase.SrcSafeIni) - 11) _
& "maillist.txt" For Input As nFileNum
Do While Not EOF(nFileNum)
Line Input #nFileNum, sNextLine
SafeItem.Subject = "VSS Notification - " & _
str = "This is an auto generated message." & vbCrLf & _
"User :" & VSSHandler.VSSDatabase.Username & _
", performed the following operations on VSS Database " _
& vbCrLf & str
SafeItem.Body = str
to immediately deliver mail
Set Utils = CreateObject("Redemption.MAPIUtils")
MsgBox "Error " & Err.Number & " while sending mail" & vbCrLf & Err.Description
- 20th January, 2006: Initial post
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.