Questions of mcsd(vc 70-15)

rorbine 2001-05-09 10:52:00
1. You write an out-of-process COM component that manages a database. You want the COM component to limit to five the number of database connections at any one time. When all five of the allocated connections are being used, any client application that requests a database connection must wait for a database connection to become available. Otherwise, that client application should time out after fiwe seconds. Which mechanism should you use to ensure that only five database connections are used at any one time?

A CSemaphore objSemaphore;
. . .
if (objSemaphore.Lock(5000))
{
GetDatabaseConnection(lpvDBConn);
}

B CSemaphore objSemaphore(5, 5, lpszName, lpSecurity);
. . .
if (objSemaphore.Lock(5000))
{
GetDatabaseConnection(lpvDBConn);
}

C int iCount = 0;
CMutex objMutex(FALSE, lpszName, lpSecurity)
. . .
if (iCount < 5 && objMutex.Lock(5000))
{
GetDatabaseConnection(lpvDBConn);
iCount++;
}

D int iCount = 0;
. . .
if (iCount < 5 )
{
GetDatabaseConnection(lpvDBConn);
iCount++;
}
else
{
Sleep(5000);
if (iCount < 5)
{
GetDatabaseConnection(lpvDBConn);
iCount++;
}
}

E int iCount = 0;
CEvent objEvent;
objEvent.SetEvent();
. . .
if (objEvent.PulseEvent())
{
GetDatabaseConnection(lpvDBConn);
iCount++;
if (iCount ==5 )
{
objEvent.ResetEvent();
}
}

2. You are writing a Win32 MFC based client application. You want to write the application settings to the registry on a per-user basis so that, the next time the application is started, it can read all of the previous settings and initialize itself appropriately. Which code fragment should you use?

A WritePrivateProfileSection(lpszSection, lpszSubKey, NULL);
WritePrivateProfileString(lpszSection, lpszSubKey, lpszData,NULL);
B SetRegistryKey(lpszRegKey);
WriteProfileString(lpszAppName, lpszSectionName, lpszData);
C RegConnectRegistry(lpszMachine, HKEY_LOCAL_MACHINE, pHKey);
RegCreateKey(*pHKey, lpszSubKey, pHKeyNew);
RegSaveKey(*pHKeyNew, lpszKeyName, lpSecurity);
D RegConnectRegistry(lpszMachine, HKEY_LOCAL_MACHINE,pHKey);
RegLoadKey(*pHKey, lpszSubKey, NULL);

10. You implement a Microsoft Transaction Server (MTS) component. You add the component to an MTS package named Reports. You must ensure that the component can be accessed by remote client applications at all times. How must you accomplish this?

AX Specify an account other than "Interactive user- the current logged on user" under which the component will run.
B Install the component in the System package.
C Set the Server Process Shutdown property of the MTS package to "Leave running when idle".
D Set the Package Activation type to "Library Package"

14. You are implementing a COM component by using the ATL Wizard. Your component will be hosted in Microsoft Transaction Server (MTS). When you debug your component, the component raises an exception on this line of code:
m_spObjectContext->SetComplete();

When you examine the "m_spObjectContext" variable, you see that it has the value "NULL". What can you do so that your component does not raise this exception?

A Import the MTS Type Library.
BX Install your component in an MTS package.
C Use the MTS Explorer to mark your component as "Requires a transaction".
D Call the "CoCreateInstance" function and request a pointer to the "IObjectContext" interface. Then, store the pointer in "m_spObjectContext" before you call the "SetComplete" function.

16. You are implementing a COM component by using ATL. When an error occurs in a method of your component, you want to notify the application that are using your component. As part of the notification, you want a string to be passed back to the client applications that describes the error. This is a fragment of your class definition:
class ATL_NO_VTABLE CErrorTest :
public CComObjectRootEx,
public CComCoClass,
public IDispatchImpl<IERRORTEST,&IID_IERRORTEST, &LIBID_ERRORATLLib>
}
Which two modifications must you make to your class implementation to achieve the required functionality?(Choose two)

A Derive your class from the "IErrorInfo" interface, and implement the "IErrorInfo" interface.
B Derive your class from the "IErrorLookup" interface, and implement the "IErrorLookup" interface.
CX Derive your class from the "ISupportErrorInfo" interface, and implement the "ISupportErrorInfo" interface.
DX Call the "AtlReportError" method when an error is detected.
E Fill in the "EXCEPINFO" structure with the required error information when an error is detected.

22. You write a business component for a Microsoft Transaction Server(MTS) package that is in a distributed database application. The business component is named Bus_User. The Bus_User business component contains a method named UpdateUser. The UpdateUser Method must verify that the user who is calling this method has sufficient security rights to make the modification. If the user has sufficient security rights, then the Bus_User business component must call a method in a data component named Db_User. The Db_User data component attempts to update a table in the Microsoft SQL Server database. The table has constraints and triggers. You configure the transaction property of the Bus_User business component as "Requires a transaction". You configure the transaction propperty of the Db_User data component as "Supports transactions". You are implementing the UpdateUser method for the Bus_User business component. You must create aninstance of the Db_User data component.How must you write the code to create the instance of the Db_User data component?

A IUser* pUser = NULL;
HRESULT hr;
hr = pObjectContext->CreateInstance( CLSID_DbUser, IID_IUser, (void**)&pUser);

B IUser* pUser = NULL;
HRESULT hr;
hr = CoCreateInstance(claidDbUser, NULL, CLSCTX_INPROC_HANDLER, IID_IUser, (void**)&pUser);

CX IObjectContext* pObjectContext = NULL;
IUser* pUser = NULL;
HRESULT hr;
hr = GetObjectContext(&pObjectContext);
hr = pObjectContext->CoCreateInstance(clsidDbUser,
NULL, CLSCTX_INPROC_HANDLER, IID_Iuser, (void**)&pUser);
. . .

D IObjectContext* pObjectContext = NULL;
IUser* pUser = NULL;
HRESULT hr;
hr = GetObjectContext(&pObjectContext);
hr = pObjectContext->CreateInstance(CLSID_DbUser, IID_IUser, (void*)&pUser);
33. You implement a COM component with a ProgID of Client.lnformation. This component will be used by applications on 2,000 client computers in your company. You notice that response time is unacceptable when all of the client computers communicate with one server. You want to deploy your application on eight servers, and spread the client load evenly across all eight servers. How should you do this?

A Configure the eight servers as four Microsoft Cluster Server (MSCS) failover clusters.
B Install a DNS round-robin router, and change the preferred Object-oriented Remote Procedure Calls (ORPC)protocol to SMTP.
C Implement a custom moniker. In the implementation of the BmdToObject method, select one of the eight servers.
DX Add an entry under the HKEY_CLASSES_ROOT\ApplD registry key for your COM component. Set the RemoteServer value name to the name of one of the eight application servers.

34. You are implementing an application by using MFC. You want to handle divide-by-zero exceptions, access violations, and MFC-generated exceptions.What should you do?

A Define the AFX_THROW_USEREXCEPTION preprocessor macro in the StdAfx.h file.
B Add catch blocks for both of the system exceptions to all of the try/catch statements where you want to handle two system exceptions.
CX Call the _set_se_translator function in your implementation of the CWinApp::lmtlnstance method. Define a Visual C++ class and, in the translator function, throw an instance of this class.
D Derive two classes from CException, one for each of the two system exceptions. Add a catch block for CUserException to all of the try/catch statements where you want to handle two system exceptions.

40. You display a splash screen as part of your application. You want to personalize this splash screen by adding the user name and company information. You want to save the user name and company information in the registry. Where in the registry should these items be saved?

A HKEY_CURRENT_CONFIG\
B HKEY_CLASSES_ROOT\
C HKEY_LOCAL_MACHINE\Software\\\
DX HKEY_CURRENT_USER\Software\\\

43. You are writing an MFC-based client application. You want to integrate a toolbar into the frame window of the client application. You want the toolbar to be resizable and able to support ToolTips. You must ensure that this toolbar support is available in the client application. Which three steps can you take? (Choose three.)

AX Call the SetSizes method of the CToolBar-derived class by passing the size of the buttons as a parameter.
BX Call the Create method of the CToolBar-derived class by passing a pointer to the CFrameWnd-derived class.
CX Call the LoadToolBar method of the CToolBar-derived class by passing the resource identifier for the toolbar resource.
D Call the SetButtonStyle method of the CToolBar-derived class by specifying ToolTip support, and by specifying dynamic resizing support.
E Call the SetBarStyle method of the CToolBar-derived class by specifying ToolTip support, and by specifying dynamic resizing support.

84. You are implementing an active document server by using MFC. You provide a mechanism to allow your objects to be rendered in fUll-size representations. You want to add support to allow your objects to be rendered in thumbnail representations by client applications. Which two actions should you perform? (Choose two.)
AX Override the COIeServerDoc::NotifyChanged method. Call the COIeServeritem::OnDraw method for the object that must be rendered in a thumbnail representation.
B Override the COIeServerltem::NotifyChanged method. Call the COIeCUentltem::OnChange method to notify the container that the aspect of the object has changed.
C Override the CDocObjectServerltem::OnDrawEx method.Examine the DVASPECT parameter, and render a thumbnail representationif that is the requested representation.
D Override the CDocObjectServeritem::OiiGetExtent method. Return the appropriate extent.
EX Override the CWnd::OnDrawltem method. Examine the DRAWITEMSTRUCT parameter, and render a thumbnail representation if that is the requested representation.

110. You develop an application that will run exclusively on Microsoft Windows NT Workstation computers. Your application uses strings extensively. You want to maximize the performance of the application. Which two actions can you perform? (Choose two.)
A Use the _T() macro when you use ASCII strings in your application.
BX Use the _TCHAR()macro when you use ASCII strings in your application.
CX Use the _MBCS preprocessor option.
D Use the _UNICODE preprocessor option.
E Use the _SBCS preprocessor option.

I've gotten some very deferent answers,and i think some of them r not correct.
so,if u know it,please give me ur answers and expland them.
thank u very much!
my email:myvrml@263.net
...全文
47 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

2,948

社区成员

发帖
与我相关
我的任务
社区描述
就计算机等级考试、软件初、中、高级不同级别资格考试相关话题交流经验,共享资源。
c1认证c4javac4前端 技术论坛(原bbs)
社区管理员
  • 软件水平考试社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧