Article ID: 175758
Article Last Modified on 4/28/2004
Private Sub DriveVss()
Set oSSafe = CreateObject("SourceSafe") 'assume this succeeds
On Error GoTo errlabel
inipath = "c:\vss\srcsafe.ini"
user = "FredA"
pwrd = "TopHat"
oSSafe.Open SrcSafeIni:= inipath, Username:= user, Password:= pwrd
Set oProject = oSSafe.VSSItem("$/myproj")
Exit Sub
errlabel:
errmsg = "Source: " & Err.Source & vbCrLf & _
"Error Number: " & Err.HelpContext & vbCrLf & _
"Please inform your SourceSafe Admin"
MsgBox (errmsg)
End Sub
169928 How to open a SourceSafe database with OLE Automation in C++
#include <winerror.h> //for HRESULT_CODE #include <string.h> //for strcpy, strcat #include <stdlib.h> // for itoaPaste the code in the header files that are listed in 169928.
void DriveVSS()
{
void ErrHand(HRESULT hr);
IVSSItem *pIVSSItem;
HRESULT hr;
BSTR bstrPath = SysAllocString(L"c:\\vss\\srcsafe.ini");
BSTR bstrUName = SysAllocString(L"FredA");
BSTR bstrUPass = SysAllocString(L"TopHat");
BSTR bstrVSSSpec = SysAllocString(L"$/myproj");
if(!SUCCEEDED(hr = pVdb->Open(bstrPath,bstrUName, bstrUPass)))
ErrHand(hr);
else if(!SUCCEEDED(hr = pVdb->get_VSSItem(bstrVSSSpec,0,&pIVSSItem)))
ErrHand(hr);
}
void ErrHand(HRESULT hr)
{
short sErrCode = HRESULT_CODE(hr);
char cErrCode[6];
char strMessage[50];
strcpy(strMessage,"Error #: ");
itoa(sErrCode, cErrCode, 10);
strcat(strMessage, cErrCode);
strcat(strMessage, "\n\n Please inform your SourceSafe Administrator");
MessageBox(NULL, strMessage, NULL, MB_OK);
}
(c) Microsoft Corporation 1997, All Rights Reserved. Contributions by David
de Groot, Microsoft Corporation
Keywords: kbhowto kbinterop KB175758