Sourcesafe api (IVSSItem)  in Delphi

KevinBadger used Ask the Experts™
Could some one tell me if it's possible/how to using to invoke the diff functionality in visual sourcesafe in delphi (version 4) ( preferably without usinf third party tools)?

Also how do i acess the version information/checking comments for an item please?

any sample source code would be appreciated


Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Self-employed developer
If I'm not mistaken, VSS has an automation interface. So all you would have to do is import this as a type library in your project and then check the functionality that it provides to you. Have you tried using that directly?


i've tried importing SourceSafeTypeLib_TLB which is where i get IVSSItem from but it soen't seem to have  much functionality
Wim ten BrinkSelf-employed developer
Well, if you have imported the type library then also look at for more information.
A Google search for is how I found that one, btw. :-)
PMI ACP® Project Management

Prepare for the PMI Agile Certified Practitioner (PMI-ACP)® exam, which formally recognizes your knowledge of agile principles and your skill with agile techniques.

Eddie ShipmanAll-around developer
In order to check the DIFF on an item, do something like this:
(loose translation of some VBS code I have)

procedure VSSCheckin(AVSSIniFile, AFileName, AVSSItemPath, AVSSUserName, AVSSPassword: String;
                     ACheckinIfDiff: Boolean; ACheckInComment: String; AExclusive: Boolean = True);
  oVSSItem: IVSSItem;
  oVSSDatabase: IVSSDatabase;
  iFlags: Integer;
  if AExclusive then
  // Create the Database object
  oVSSDatabase := CreateOleObject('SourceSafe') as IVSSDatabase;
    oVSSDatabase.Open(AVSSIniFile, AVSSUserName, AVSSPassword);
    oVSSItem := oVSSDatabase.VSSItem[AVSSItemPath, False];
    // Check it out
    oVSSItem.Checkout('Checked out by automated process', AFileName, iFlags);
    if (oVSSItem.IsDifferent[AFileName]) and (ACheckinIfDiff) then
      oVSSItem.Checkin(ACheckInComment, AFileName, iFlags);
    oVSSDatabase := nil;

I don't have the VSS TypeLib imported because I can't find it even though I have VSS Installed on
my system. Oh, wait, here it is... Let me double check that code before I finish this post...

Since I am going to begin working on a VSS project, I needed to know how to do that and I
posted code that works.
Eddie ShipmanAll-around developer

If you need more, llike how to get the individual version comments, let me know.
Eddie ShipmanAll-around developer

KevinBadger, have you tried any of our solutions?
Eddie ShipmanAll-around developer

Wow, a 'B' for that, huh? You may need to be a little more careful about your grading in the future if you
want expert help.


Sorry Eddie,
I didn't take time to read throught properly.
I was looking for a diff as in file comparison  (Sourcesafe "show differences") though. I suppose I could just launch the diff app if its available as aseperate executable
Eddie ShipmanAll-around developer

It was not clear what you wanted to do. I do not know if showing the diff from the VSSItem woul duse the external diff util or not. I will test that and get back with you.
Eddie ShipmanAll-around developer

From Alin Constantin at:


IVSS is an automation interface, therefore there is no UI associated with it.

If you use VSS 6.0 IVSS API, there is an unsupported Diff-Merge OCX control
providing the diff-merge UI. It is included with the SourceSafe Automation
Sample written by Tim Winter. It's available at:

If you use VSS 2005, the functionality of the unsupported control has been
replaced with command line invocation of SourceSafe Explorer. Syntax and
examples for Edit/View/Diff/Merge can be found at:

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial