Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Need a source safe expert

Need a source safe expert

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialquestion
6 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Y Offline
    Y Offline
    YaronNir
    wrote on last edited by
    #1

    Hi all, I know i can communicate with the visual source safe using command lines.... I want like to do via code the following : check if a certain file is checked out or not do this by performing the proper command line..... can any1 show me how to? thanks in advanced Yaron Nir Ask not what your application can do for you, Ask what you can do for your application

    A D 2 Replies Last reply
    0
    • Y YaronNir

      Hi all, I know i can communicate with the visual source safe using command lines.... I want like to do via code the following : check if a certain file is checked out or not do this by performing the proper command line..... can any1 show me how to? thanks in advanced Yaron Nir Ask not what your application can do for you, Ask what you can do for your application

      A Offline
      A Offline
      Alexander Ruscle
      wrote on last edited by
      #2

      SourceSafe provides a COM interface with which you can perform all the functions that you can from the command line, complete with the entire object model. There are several good help files in MSDN about it, particularly one entitled Microsoft Visual SourceSafe OLE Automation. Here's some sample code that will get a file out of SourceSafe if it's not checked out:

      #include "ssapi.h"
      
      /*--------------------------------------------------------------------
      void GetWritableFileFromSourceSafe (CString sSourceSafeFile, CString sOnDiskTargetFile)
        DESCRIPTION:
          Opens SourceSafe, using the default username with no password and
          attempts to get the specified file to a location on the local disk
          for modification.
      
        PARAMETERS:
          CString sSourceSafeFile
            The file in SourceSafe to retrieve.
      
          CString sOnDiskTargetFile
            The filename to write the SourceSafe file to.
      @x.-----------------------------------------------------------------*/
      void CSourceSafeWrapper::GetWritableFileFromSourceSafe (CString sSourceSafeFile, CString sOnDiskTargetFile)
      {
        IVSSDatabase db;
      
        if (db.CreateDispatch ("SourceSafe")) {
      
          CString sSSDatabase, sUsername, sPassword;
          // This is a function that gets the name of the database (like
          // "\\SourceMachine\Sources\srcsafe.ini"), the username and
          // password to use.
          ReadSSLoginSettings (sSSDatabase, sUsername, sPassword);
      
          try {
      			
            db.Open (sSSDatabase, sUsername, sPassword);
      
            // Note that if this fails, there is some memory inside the COM
            // object that leaks, but there's nothing I know to do about it.
            LPDISPATCH pDisp = db.GetVSSItem (sSourceSafeFile, FALSE);
            IVSSItem item (pDisp);
      
            // Make sure the item is not already checked out.
            if (item.GetIsCheckedOut ()) 
              throw (new CMyAppException ("The file in SourceSafe you specified is already checked out by someone. Make sure it is not checked out before proceeding."));
      
            CComBSTR bstrPath (sOnDiskTargetFile);
      		
            item.Get (&bstrPath, VSSFLAG_USERRONO | VSSFLAG_REPREPLACE | VSSFLAG_FORCEDIRNO);
          }
          catch (COleDispatchException * pE)  {
      		
            // Pass this error on to the user.  We transform the exception 
            // into one of our so that we can report it and respond just 
            // like one of our own errors.
            CString sMsg;
            pE->GetErrorMessage (sMsg.GetBuffer (MAX_
      
      Y 1 Reply Last reply
      0
      • Y YaronNir

        Hi all, I know i can communicate with the visual source safe using command lines.... I want like to do via code the following : check if a certain file is checked out or not do this by performing the proper command line..... can any1 show me how to? thanks in advanced Yaron Nir Ask not what your application can do for you, Ask what you can do for your application

        D Offline
        D Offline
        David Crow
        wrote on last edited by
        #3

        YaronNir wrote: I know i can communicate with the visual source safe using command lines.... I want like to do via code the following So which is it? Do you want command-line syntax, or code?

        Y 1 Reply Last reply
        0
        • D David Crow

          YaronNir wrote: I know i can communicate with the visual source safe using command lines.... I want like to do via code the following So which is it? Do you want command-line syntax, or code?

          Y Offline
          Y Offline
          YaronNir
          wrote on last edited by
          #4

          sorry, i guess my request was a lit ambiguous...... i need to communitcate with the source safe api meaning i want to use code... can u help? thanks Yaron Ask not what your application can do for you, Ask what you can do for your application

          D 1 Reply Last reply
          0
          • A Alexander Ruscle

            SourceSafe provides a COM interface with which you can perform all the functions that you can from the command line, complete with the entire object model. There are several good help files in MSDN about it, particularly one entitled Microsoft Visual SourceSafe OLE Automation. Here's some sample code that will get a file out of SourceSafe if it's not checked out:

            #include "ssapi.h"
            
            /*--------------------------------------------------------------------
            void GetWritableFileFromSourceSafe (CString sSourceSafeFile, CString sOnDiskTargetFile)
              DESCRIPTION:
                Opens SourceSafe, using the default username with no password and
                attempts to get the specified file to a location on the local disk
                for modification.
            
              PARAMETERS:
                CString sSourceSafeFile
                  The file in SourceSafe to retrieve.
            
                CString sOnDiskTargetFile
                  The filename to write the SourceSafe file to.
            @x.-----------------------------------------------------------------*/
            void CSourceSafeWrapper::GetWritableFileFromSourceSafe (CString sSourceSafeFile, CString sOnDiskTargetFile)
            {
              IVSSDatabase db;
            
              if (db.CreateDispatch ("SourceSafe")) {
            
                CString sSSDatabase, sUsername, sPassword;
                // This is a function that gets the name of the database (like
                // "\\SourceMachine\Sources\srcsafe.ini"), the username and
                // password to use.
                ReadSSLoginSettings (sSSDatabase, sUsername, sPassword);
            
                try {
            			
                  db.Open (sSSDatabase, sUsername, sPassword);
            
                  // Note that if this fails, there is some memory inside the COM
                  // object that leaks, but there's nothing I know to do about it.
                  LPDISPATCH pDisp = db.GetVSSItem (sSourceSafeFile, FALSE);
                  IVSSItem item (pDisp);
            
                  // Make sure the item is not already checked out.
                  if (item.GetIsCheckedOut ()) 
                    throw (new CMyAppException ("The file in SourceSafe you specified is already checked out by someone. Make sure it is not checked out before proceeding."));
            
                  CComBSTR bstrPath (sOnDiskTargetFile);
            		
                  item.Get (&bstrPath, VSSFLAG_USERRONO | VSSFLAG_REPREPLACE | VSSFLAG_FORCEDIRNO);
                }
                catch (COleDispatchException * pE)  {
            		
                  // Pass this error on to the user.  We transform the exception 
                  // into one of our so that we can report it and respond just 
                  // like one of our own errors.
                  CString sMsg;
                  pE->GetErrorMessage (sMsg.GetBuffer (MAX_
            
            Y Offline
            Y Offline
            YaronNir
            wrote on last edited by
            #5

            thanks man, that was exactly what i needed! cheers Yaron Ask not what your application can do for you, Ask what you can do for your application

            1 Reply Last reply
            0
            • Y YaronNir

              sorry, i guess my request was a lit ambiguous...... i need to communitcate with the source safe api meaning i want to use code... can u help? thanks Yaron Ask not what your application can do for you, Ask what you can do for your application

              D Offline
              D Offline
              David Crow
              wrote on last edited by
              #6

              Alexander's suggestion is the way to go.

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups