請問StarTeam如何使用 |
|
tony115722
一般會員 發表:53 回覆:63 積分:23 註冊:2002-07-09 發送簡訊給我 |
|
paradise
初階會員 發表:60 回覆:115 積分:40 註冊:2004-05-03 發送簡訊給我 |
如果你真的要找中文說明,現階段應該比較少.但是如果要找說明文件的話,在你的安裝目錄下%StarTeam 6.0%/User Manuals內有不少PDF可供參考,其中有一個檔名為alldoc.pdf有所有StarTeam的文件的link,你可以先從此文件下手..
若還是不清楚,你可以先看看StarTeam Getting Started Guide這份文件,先看看StarTeam Overview與StarTeam for Users這兩個Chapter,這樣你會對StarTeam比較有感覺一點... 若還有疑問歡迎提出討論...
|
_CCH_
一般會員 發表:10 回覆:29 積分:7 註冊:2004-04-20 發送簡訊給我 |
|
paradise
初階會員 發表:60 回覆:115 積分:40 註冊:2004-05-03 發送簡訊給我 |
引言: >但是如果要找說明文件的話, >在你的安裝目錄下%StarTeam 6.0%/User Manuals內有不少PDF可供參考 請問一下; 在哪裡啊! 我的BCB60 和 DELPHI70 都沒有看到有 StarTeam 的目錄。 秉燭夜遊,大塊文章。 文章是案頭之山水,山水是地上之文章。基本上前一篇,我是假設你有安裝StarTeam 6.0或 5.4 Server在您的pc上, 若你沒有安裝可以下列網址下載與安裝StarTeam 6.0 或StarTeam 5.4 http://bdn.borland.com/cgi-bin/surveys/thanx.cgi?st60_kdown http://bdn.borland.com/cgi-bin/surveys/thanx.cgi?st54_kdown 若是BCB 6.0與DELPHI 70,您需要額外安裝 StarTeam Plug-in,你可以到下列網址下載安裝. http://bdn.borland.com/cgi-bin/surveys/thanx.cgi?st54_Int_kdown 安裝完後,就會有上述的PDF檔案可供參考... 若還有不清楚之處歡迎提出討論... |
szu
一般會員 發表:0 回覆:2 積分:0 註冊:2003-04-07 發送簡訊給我 |
|
paradise
初階會員 發表:60 回覆:115 積分:40 註冊:2004-05-03 發送簡訊給我 |
引言: 不知道有沒有多一點的使用StarTeam SDK的文件呢? 最好是擁有C 的範例程式...^_^..請安裝StarTeam SDK for windows即會有完整的StarTeam COM API or Jave API ,C 範例程式比較少! VB與Java的比較多! 若未安裝StarTeam SDK(not StarTeam SDK Runtime),請到下列網址下載 StarTeam 2005 SDK http://altd.borland.com/download/starteam/st2005/2005StarTeamSDK.exe 下列有一些使用方式讓您參考一下,詳細請看SDK User Guide,或請洽詢Borland StarTeam SDK 的訓練課程 Using the SDK from C -------------------------------------------------------------------------------- This section provides a few simple examples that demonstrate how to use the StarTeam COM interfaces in C . Note that when using the COM interfaces from C , you must include the following header file: #include "StarTeamSDK.h" This header contains the declarations of the StarTeam COM interfaces. It should be located in the lib subfolder of the StarTeam SDK installation folder. In addition, you will need to compile the file StarTeamSDK_i.c and link it into your project. This file defines the various class IDs (CLSIDs) and Interface IDs (IIDs) for the StarTeam COM APIs. This file is also located in the SDK? lib subfolder. Getting Started The following example shows how to create a Server object, and establish a connection to a StarTeam Server, using the StarTeam COM interfaces in C . int main(int argc, char *argv[ ], char *envp[ ]) { USES_CONVERSION; CoInitialize(NULL); const char* strAddress = "localhost"; int nPort = 49201; const char* strUser = "SampleUser"; const char* strPassword = "MyPassword"; HRESULT hr = S_OK; IStServerFactory* Factory = NULL; IStServer* Server = NULL; try { // Instantiate an StServerFactory object. hr = CoCreateInstance( CLSID_StServerFactory, NULL, CLSCTX_SERVER, IID_IStServerFactory, (void**)&Factory); // Use it to create an StServer object. if (SUCCEEDED(hr)) { hr = Factory->Create( T2OLE(strAddress), nPort, &Server); } // Establish a connection to the server. // Optional - logOn() connects if necessary. if (SUCCEEDED(hr)) { hr = Server->connect(); } // LogOn as a specific user. if (SUCCEEDED(hr)) { long userID = -1; hr = Server->logOn( T2OLE(strUser), T2OLE(strPassword), &userID); } // Use the Server object to enumerate // Projects, Views, etc. // . . . // Disconnect when finished. if (SUCCEEDED(hr)) { hr = Server->disconnect(); } // Clean up. if (Server != NULL) { Server->Release(); Server = NULL; } if (Factory != NULL) { Factory->Release(); Factory = NULL; } } // Error handling. catch(...) { if (Server != NULL) { Server->Release(); } if (Factory != NULL) { Factory->Release(); } } CoUninitialize(); return(0); } As you can see, using the StarTeam interfaces from C is much more complex than using them from other programming environments. This is not really due to any added complexity in the StarTeam APIs themselves, but is the nature of using COM from C . Describing COM functions such as CoInitialize(), CoCreateInstance(), and CoUninitialize() is beyond the scope of this document. Consult the reference documentation in the Win32 platform SDK. The examples above use T2OLE() to enhance readability. T2OLE and USES_CONVERSION are macros, defined by the Microsoft Foundation Classes (MFC), that simplify the conversion of ASCII text to Unicode, which is required by COM. If you are not programming natively in Unicode, and you are not using MFC, then you can convert to Unicode using the Win32 APIs. For example: int nLen = MultiByteToWideChar( CP_ACP, 0, strAddress, strlen(strAddress), NULL, 0); if (SysReAllocStringLen(&bstrAddress, NULL, nLen)) { MultiByteToWideChar( CP_ACP, 0, strAddress, strlen(strAddress), bstrAddress, nLen); hr = Factory->Create(bstrAddress, nPort, &Server); SysFreeString(bstrAddress); bstrAddress = NULL; } When using the COM interfaces from C , be sure that you use AddRef() and Release() to maintain the proper reference counts on the various StarTeam objects. The most common problems encountered while using the COM interfaces are a result of releasing an object prematurely or leaving an outstanding reference to an object when it is no longer needed. You can simplify the management of object references in C by using smart pointers. Smart pointers are essentially C wrappers that maintain reference counts as the objects go in and out of scope. Microsoft Visual C supports an implementation of smart pointers that is easy to use. Consult your Visual C documentation for further details. Collections and Enumeration The following example shows how to enumerate the projects that are available on a given server, searching for the project with a given name. IStProject* FindProject(IStServer* pServer, LPCTSTR szName) { HRESULT hr = S_OK; IStProject* pProject = NULL; IStCollection* pCollect = NULL; LPDISPATCH pDispatch = NULL; IEnumVARIANT* pEnum = NULL; LPUNKNOWN pUnknown = NULL; IStProject* pNext = NULL; BSTR bstrName = NULL; try { // Get the value of the Projects property. hr = pServer->get_Projects(&pCollect); // The value is a StarTeam collection object, // which supports the standard get__NewEnum() // method of an automation collection. if (SUCCEEDED(hr)) { hr = pCollect->get__NewEnum(&pDispatch); pCollect->Release(); pCollect = NULL; } // Now that we have an automation collection, // query for the IEnumVARIANT interface. if (SUCCEEDED(hr)) { hr = pDispatch->QueryInterface( IID_IEnumVARIANT, (void**)&pEnum); pDispatch->Release(); pDispatch = NULL; } // Use IEnumVARIANT to iterate over // the members of the collection. while (SUCCEEDED(hr) && (pProject == NULL)) { USES_CONVERSION; // Retrieve the next element. VARIANT v; VariantInit(&v); hr = pEnum->Next(1, &v, NULL); // Are we at the end of the collection? if (hr == S_FALSE) break; // Get the project object from // the VARIANT record. pUnknown = NULL; hr = VariantChangeType(&v, &v, 0, VT_UNKNOWN); if (SUCCEEDED(hr)) { pUnknown = v.punkVal; } if (pUnknown == NULL) { hr = E_INVALIDARG; } // Query for the IStProject interface. if (SUCCEEDED(hr)) { hr = pUnknown->QueryInterface( IID_IStProject, (void**)&pNext); } if (pUnknown != NULL) { pUnknown->Release(); pUnknown = NULL; } // Get the value of the Name property. if (SUCCEEDED(hr)) { hr = pNext->get_Name(&bstrName); } // See if the project name matches // the one we're looking for. if (SUCCEEDED(hr)) { LPCTSTR szNext = OLE2T(bstrName); SysFreeString(bstrName); bstrName = NULL; if (strcmp(szName, szNext) == 0) { // It's a match; save a reference to the // project object, since we'll be returning // it to the caller. pProject = pNext; pProject->AddRef(); } } if (pNext != NULL) { pNext->Release(); pNext = NULL; } } if (pEnum != NULL) { pEnum->Release(); pEnum = NULL; } } catch(...) { if (bstrName != NULL) { SysFreeString(bstrName); } if (pUnknown != NULL) { pUnknown->Release(); } if (pNext != NULL) { pNext->Release(); } if (pEnum != NULL) { pEnum->Release(); } if (pDispatch != NULL) { pDispatch->Release(); } if (pCollect != NULL) { pCollect->Release(); } throw; } return(pProject); } Once again, using the StarTeam interfaces from C is much more complex than using them from other programming environments. In Visual Basic, this same example required about a dozen lines of code! Although the code required to manipulate a collection is extensive, the concepts involved are reasonably straightforward. Remember to keep the following points in mind: A collection in the StarTeam object model is implemented using IStCollection. IStCollection implements the standard get__NewEnum() method. get__NewEnum() returns an object that supports the standard IEnumVARIANT interface. Use the Next() method of the IEnumVARIANT interface to iterate over the members of the collection. The type of the VARIANT members of the collection depends on which collection is being examined. In most cases, the members will be IDispatch interfaces to some StarTeam-specific object. Use QueryInterface() to obtain the interface appropriate for the specific collection. For example, query for IStProject in a Projects collection, IStView in a View collection, and so on. Handle reference counting with care. In particular, remember that when the Next() method of IEnumVARIANT returns a variant of type VT_DISPATCH or VT_UNKOWN, there is an outstanding reference to the enclosed interface pointer that must be released by the caller. Error Handling The StarTeam COM APIs support rich error messages through the use of the standard IErrorInfo interface. The following example demonstrates how to get a descriptive error message when one of the StarTeam APIs fails. BSTR GetErrorMessage(HRESULT hr, REFIID riid, LPUNKNOWN p) { BSTR pErrorMessage = NULL; // If the return code indicates an error ... if (!SUCCEEDED(hr)) { // If the object that generated the error supports // the standard ISupportErrorInfo interface ... ISupportErrorInfo* pSEI = NULL; if (SUCCEEDED(p->QueryInterface( IID_ISupportErrorInfo, (void**)&pSEI))) { // And supports error information on the // interface that generated the error ... if (pSEI->InterfaceSupportsErrorInfo(riid) == S_OK) { // Get the IErrorInfo interface. IErrorInfo* pEI = NULL; if (GetErrorInfo(0, &pEI) == S_OK) { // Get the error message. pEI->GetDescription(&pErrorMessage); pEI->Release(); } } pSEI->Release(); } } return(pErrorMessage); } Borland Taiwan SE |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |