Download Visual Studio Tools

Siebel Object Interfaces Reference > Customizing Siebel Object Interfaces > Accessing a Siebel Object Interface >

Accessing the COM Data vps with Microsoft Visual Studio

This topic describes how to create a simple COM client in Microsoft Visual C++and the Microsoft Foundation Class (MFC) library that accesses the Siebel Data Server.

To access the COM Data hệ thống with Microsoft Visual Studio

In Microsoft Visual C++, choose the tệp tin menu, New, và then the Project menu item.Choose the MFC AppWizard (exe) project type.In the Project name field, enter SiebelCOM, and then click OK.In the MFC AppWizard, choose the Dialog-based option and then click Next.In the What Other tư vấn Would You like to Include frame, vị the following:Make sure the Automation option contains a kiểm tra mark.Make sure the ActiveX Controls does not contain a check mark.Click Next. Click Next.Click Finish, & then click OK.

Bạn đang xem: Download visual studio tools

The Application Wizard creates the MFC code that you use for this project, including the headers & libraries that COM automation requires. For more information about the MFC libraries, see the documentation for Microsoft MSDN Visual Studio.

Modify the new dialog box.

Microsoft Visual C++ displays a new dialog box. Khổng lồ resize và modify the text in this dialog box, right-click the label in the dialog box & edit the properties. Modify the dialog box so that it resembles the following illustration.


Choose the View menu, ClassWizard, & then the Automation menu item.Click địa chỉ cửa hàng Class, and then click From a Type Library.Navigate to lớn the SIEBSRVR_ROOTin folder, and then choose sobjsrv.tlb.In the Confirm Classes dialog box, make sure all Siebel classes are chosen, click OK, và then click OK again lớn close the Class Wizard.Add code to lớn communicate with the Siebel COM Server.In the workspace window, click the FileView tab.Expand the Source Files thư mục and the Header Files folder.Double-click the SiebelCOMDlg.h file.In the code window, địa chỉ the following code khổng lồ the SiebelCOMDlg.h file. địa chỉ cửa hàng only the code that uses bold typeface:

#if _MSC_VER > 1000#pragma once#endif // _MSC_VER > 1000

#include "sobjsrv.h" // Include Siebel wrapper classes

class CSiebelCOMDlgAutoProxy;

///////////////////////////////////////////////////////////// CSiebelCOMDlg dialog

class CSiebelCOMDlg : public CDialog{  DECLARE_DYNAMIC(CSiebelCOMDlg);  friend class CSiebelCOMDlgAutoProxy;  SiebelApplication sApp; // Declare Siebel object

//Constructionpublic:  CSiebelCOMDlg(CWnd* pParent = NULL); //standard constructor  virtual ~CSiebelCOMDlg();

Choose open from the file menu, and then choose the SiebelCOMDlg.cpp file.Add the following code to lớn the OnInitDialog procedure. địa chỉ only the code that uses bold typeface:



// TODO: add extra initialization here// Start the Siebel Data Serverif (!sApp.CreateDispatch(_T("SiebelDataServer.ApplicationObject)))  AfxMessageBox("Cannot start Siebel Data Server.");EndDialog(-1); // Fail else  AfxMessageBox("Siebel Data hệ thống initialized.");

return TRUE; // Return TRUE unless you make a control active...

In the same file, địa chỉ cửa hàng the following code khổng lồ the OnOK procedure.

Xem thêm: Soạn Sinh Học Lớp 8 Bài 3 Sinh 8: Tế Bào (Trang 11 13 Sgk), Lý Thuyết Sinh Học Lớp 8 Bài 3: Tế Bào

To showroom this code correctly, vị the following:

Make sure that the line that begins with sApp.LoadObjects references the location of the Siebel application configuration (CFG) file you intend lớn use. In the line that begins with sApp.Login, make sure you use a valid logon name và password.Add only the code that uses bold typeface.

  void CSiebelCOMDlg::OnOK()  

short sErr;

// Load configuration file// Make sure that the following line references the correct filesApp.LoadObjects(C:Siebel8.1ServerBINENUsiebel.cfg", &sErr);if(sErr)  AfxMessageBox("LoadObject failed.");  return; else  AfxMessageBox("CFG file loaded.");

// Log in as SADMINsApp.Login("SADMIN", "SADMIN", &sErr);if(sErr)  AfxMessageBox("Login failed.");  return; else  AfxMessageBox("Logged in khổng lồ Siebel database.");

// Get tài khoản business objectLPDISPATCH lpdBo;lpdBo = sApp.GetBusObject("Account", &sErr);if(sErr)  AfxMessageBox("GetBusObject failed.");  return; else  AfxMessageBox("Account business object returned.");SiebelBusObject Bo(lpdBo);

// Get account business componentLPDISPATCH lpdBc;lpdBc = Bo.GetBusComp("Account", &sErr);if(sErr)  AfxMessageBox("GetBusComp failed.");  return; else  AfxMessageBox("Account business component returned.");SiebelBusComp Bc(lpdBc);

// Get the name of the first accountif (sErr) return;Bc.ClearToQuery(&sErr);if (sErr) return;Bc.SetSearchSpe("Name", "*", &sErr);if (sErr) return;Bc.ExecuteQuery(ForwardOnly, &sErr);if (sErr) return;Bc.FirstRecord(&sErr);if (sErr) return;

// Display the trương mục name in a message boxCString csAcctName;csAcctName = Bc.GetFieldValue("Name", &sErr);AfxMessageBox(csAcctName);

Bc = null;lpdBc = null;Bo = null;lpdBo = null;


if (CanExit())  CDialog::OnOK();


Test your work:Start the Siebel client.

Make sure you use the same Siebel application configuration (CFG) file and login arguments that you specified in the code.

Navigate khổng lồ the Accounts screen, and then the All Accounts view.Verify that at least one trương mục is visible in the trương mục list applet.

If at least one tài khoản is not visible, then create one.

Exit the Siebel client.Open the Siebel application configuration (CFG) tệp tin you specified in the code và make sure the DataSource parameter indicates the correct Siebel database source.In Microsoft Visual C++, choose the Build menu, và then the SiebelCOM.exe thực đơn item.

If Microsoft Visual C++ displays an error or warning in the đầu ra window, then correct the error và repeat this step.

Choose the Build menu, and then the Execute SiebelCOM.exe thực đơn item.Wait for Microsoft Visual C++ to lớn display the following message:

Siebel Data server initialized.

Click OK.

The Siebel application displays the following series of messages:

CFG file loaded.Logged in to Siebel database.Account business object returned.Account business component returned.

The Siebel application displays the name of the first account in the All Accounts view.