Need a source safe expert
-
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
-
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
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_
-
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
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?
-
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?
-
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_
-
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
Alexander's suggestion is the way to go.