Skip to main content

Posts

Showing posts from May, 2008

Explain Condition's for deadlock occurrence?

Deadlock can arise if four conditions hold simultaneously. Mutual exclusion: only one process at a time can use a resource. Hold and wait: a process holding at least one resource is waiting to acquire additional resources held by other processes. No preemption: a resource can be released only voluntarily by the process holding it, after that process has completed its task. Circular wait: there exists a set {P0, P1, …, P0} of waiting processes such that P0 is waiting for a resource that is held by P1, P1 is waiting for a resource that is held by P 2, …, Pn–1 is waiting for a resource that is held by Pn, and P0 is waiting for a resource that is held by P0.

19. What is a multi-threaded apartment (MTA)? Single-threaded apartment (STA)?

This is pretty difficult question to describe shortly. Anyway, apartments were introduced by Microsoft in NT 3.51 and late Windows 95 to isolate the problem of running legacy non-thread safe code into multithreaded environment. Each thread was “encapsulated” into so called single-threaded apartment. The reason to create an object in apartment is thread-safety. COM is responsible synchronize access to the object even if the object inside of the apartment is not thread-safe. Multithreaded apartments (MTA, or free threading apartment) were introduced in NT 4.0. Idea behind MTA is that COM is not responsible to synchronize object calls between threads. In MTA the developer is responsible for that. See “Professional DCOM Programming” of Dr. Grimes et al. or “Essential COM” of Don Box for the further discussion on this topic.

What is Message Reflection ? How could you accomplish the above task using message reflection?

Usually, message is handled in the parent class that means you have to override message handler for each parent. Sometimes it is nice to handle a message in the control itself, without parent invocation. Such handling mechanism is called message reflection. Control "reflects" message to itself and then processes it. Use ON_ _REFLECT macro to create a reflected message.

What is CArchive class does?

Originally Posted by MSDN The CArchive class allows you to save a complex network of objects in a permanent binary form (usually disk storage) that persists after those objects are deleted. Later you can load the objects from persistent storage, reconstituting them in memory. This process of making data persistent is called “serialization.”

Explain the difference between the following... public, private, protected and mutable type.

- public - These members can be accessed any where, inside class outside class in derived class. - protected – can be used within the class and inside derived classes. - private - can be used only inside the class, - mutable – if a const method is declared which ensure that the state of object or member variable will not be modified inside such const method . one can declare the variable as mutable and it modified by const method. Basically used for const ojbects.

How many problems can you spot in the following class definition?

class MyString() { MyString() { } ~MyString() { delete m_pText; } void Set( char * pText) { size_t length = strlen(pText); m_pText = new char [length]; } private : m_pText; } int _tmain( int argc, _TCHAR* argv[]) { return 0; } Answers: Class declaration is wrong ended with (). Type for m_pText is not specified. Class declaration closing brace is not ended with semicolon m_pText should be deleted as delete[] and not just delete. you cant take the strlen of pointer as if it is not null terminated one it will give wrong results.

What is difference between GetWindowRect and GetClientRect? How do you find the client rect of child window inside another window relative to parent?

GetWindowRect - It gives the rectangle of window frame including he client area (working area excluding windows framem , menu etc). GetClientRect()- working area excluding windows frame , menu etc Get the handle to the child window by using the item resource id And call GetClientRect() on that.

What is thread and process in windows ?

Windows thread is the basic unit of execution, rather than a process A process can contain one or more threads Each process has its own code and data address space Threads share the process address space Threads are “lightweight” and more efficient than processes Used for servers, asynchronous I/O, ...

Explain Windows Handle?

In windows operating system Every resource is an “object” identified and referenced by a “handle” of type HANDLE. In 32 bit Windows its a 32 bit value. Kernel objects must be manipulated by WindowsAPIs HANDLE datatype objects include: files pipes processes memory mapping threads events, mutexes, semaphores

What is Message Maps ?

Message Maps MFC uses message maps to get around a fundamental problem with virtual functions. Look at the CWnd class in the MFC help file. It contains over 200 member functions, all of which would have to be virtual if message maps were not used. Now look at all of the classes that subclass the CWnd class. For example, go to the contents page of the MFC help file and look at the visual object hierarchy. 30 or so classes in MFC use CWnd as their base class. This set includes all of the visual controls such as buttons, static labels, and lists. Now imagine that MFC used virtual functions, and you created an application that contained 20 controls. Each of the 200 virtual functions in CWnd would require its own virtual function table, and each instance of a control would therefore have a set of 200 virtual function tables associated with it. The program would have roughly 4,000 virtual function tables floating around in memory, and this is a problem on machines that have memory limitation

Explain Pipes for IPC

There are two types of pipes for two-way communication: anonymous pipes named pipes. Anonymous pipes enable related processes to transfer information to each other. An anonymous pipe is used for redirecting the standard input or output of a child process so that it can exchange data with its parent process. To exchange data in both directions (duplex operation), you must create two anonymous pipes. The parent process writes data to one pipe using its write handle, while the child process reads the data from that pipe using its read handle. Similarly, the child process writes data to the other pipe and the parent process reads from it. Anonymous pipes cannot be used over a network, nor can they be used between unrelated processes. Named pipes are used to transfer data between processes that are not related processes and between processes on different computers. A named-pipe server process creates a named pipe with a well-known name or a name that is to be communicated to its clien

Explain RPC for IPC

RPC enables applications to call functions remotely. Therefore, RPC makes IPC as easy as calling a function. RPC operates between processes on a single computer or on different computers on a network. The RPC provided by Windows is compliant with the Open Software Foundation (OSF) Distributed Computing Environment (DCE). This means that applications that use RPC are able to communicate with applications running with other operating systems that support DCE. RPC automatically supports data conversion to account for different hardware architectures and for byte-ordering between dissimilar environments. RPC clients and servers are tightly coupled but still maintain high performance. The system makes extensive use of RPC to facilitate a client-server relationship between different parts of the operating system. Key Point: RPC is a function-level interface, with support for automatic data conversion and for communications with other operating systems. Using RPC, you can create high-perform

Explain Windows Sockets for IPC

Windows Sockets is an protocol-independent interface. It takes advantage of the communication capabilities of the underlying protocols. In Windows Sockets 2, a socket handle can optionally be used as a file handle with the standard file I/O functions. Windows Sockets are based on the sockets first popularized by Berkeley Software Distribution (BSD). An application that uses Windows Sockets can communicate with other socket implementation on other types of systems. However, not all transport service providers support all available options. Windows Sockets is a protocol-independent interface capable of supporting current and emerging networking capabilities.

Explain Mailslot for IPC

Mailslots provide one-way communication. Any process that creates a mailslot is a mailslot server. Other processes, called mailslot clients, send messages to the mailslot server by writing a message to its mailslot. Incoming messages are always appended to the mailslot. The mailslot saves the messages until the mailslot server has read them. A process can be both a mailslot server and a mailslot client, so two-way communication is possible using multiple mailslots. A mailslot client can send a message to a mailslot on its local computer, to a mailslot on another computer, or to all mailslots with the same name on all computers in a specified network domain. Messages broadcast to all mailslots on a domain can be no longer than 400 bytes, whereas messages sent to a single mailslot are limited only by the maximum message size specified by the mailslot server when it created the mailslot. Mailslots offer an easy way for applications to send and receive short messages. They also provide t

Using a File Mapping for IPC

File mapping enables a process to treat the contents of a file as if they were a block of memory in the process's address space. The process can use simple pointer operations to examine and modify the contents of the file. When two or more processes access the same file mapping, each process receives a pointer to memory in its own address space that it can use to read or modify the contents of the file. The processes must use a synchronization object, such as a semaphore, to prevent data corruption in a multitasking environment. You can use a special case of file mapping to provide named shared memory between processes. If you specify the system swapping file when creating a file-mapping object, the file-mapping object is treated as a shared memory block. Other processes can access the same block of memory by opening the same file-mapping object. File mapping is quite efficient and also provides operating-system–supported security attributes that can help prevent unauthorized data

Explain DDE for IPC

DDE is a protocol that enables applications to exchange data in a variety of formats. Applications can use DDE for one-time data exchanges or for ongoing exchanges in which the applications update one another as new data becomes available. The data formats used by DDE are the same as those used by the clipboard. DDE can be thought of as an extension of the clipboard mechanism. The clipboard is almost always used for a one-time response to a user command, such as choosing the Paste command from a menu. DDE is also usually initiated by a user command, but it often continues to function without further user interaction. You can also define custom DDE data formats for special-purpose IPC between applications with more tightly coupled communications requirements. DDE exchanges can occur between applications running on the same computer or on different computers on a network. DDE is not as efficient as newer technologies. However, you can still use DDE if other IPC mechanisms are not suitabl

Using Data Copy for IPC

Data copy enables an application to send information to another application using the WM_COPYDATA message. This method requires cooperation between the sending application and the receiving application. The receiving application must know the format of the information and be able to identify the sender. The sending application cannot modify the memory referenced by any pointers. Data copy can be used to quickly send information to another application using Windows messaging. For more information, see Data Copy.

Using COM for IPC

Applications that use OLE manage compound documents— that is, documents made up of data from a variety of different applications. OLE provides services that make it easy for applications to call on other applications for data editing. For example, a word processor that uses OLE could embed a graph from a spreadsheet. The user could start the spreadsheet automatically from within the word processor by choosing the embedded chart for editing. OLE takes care of starting the spreadsheet and presenting the graph for editing. When the user quit the spreadsheet, the graph would be updated in the original word processor document. The spreadsheet appears to be an extension of the word processor. The foundation of OLE is the Component Object Model (COM). A software component that uses COM can communicate with a wide variety of other components, even those that have not yet been written. The components interact as objects and clients. Distributed COM extends the COM programming model so that it w

Explain ClipBoard -IPC.

Using the Clipboard for IPC The clipboard acts as a central depository for data sharing among applications. When a user performs a cut or copy operation in an application, the application puts the selected data on the clipboard in one or more standard or application-defined formats. Any other application can then retrieve the data from the clipboard, choosing from the available formats that it understands. The clipboard is a very loosely coupled exchange medium, where applications need only agree on the data format. The applications can reside on the same computer or on different computers on a network. Key Point: All applications should support the clipboard for those data formats that they understand. For example, a text editor or word processor should at least be able to produce and accept clipboard data in pure text format. For more information, see Clipboard.

Explain IPC - Interprocess communication.

The communications and data sharing between applications( different processes) are called as interprocess communications (IPC). Some IPC allows the communications and data sharing among several specialized processes. Other IPC communications and data sharing among computers on a network. Applications can use IPC categorized as clients or servers. A client is an application or a process that requests a service from some other application or process. A server is an application or a process that responds to a client request. Many applications act as both a client and a server, depending on the situation. For example, a word processing application might act as a client in requesting a summary table of manufacturing costs from a spreadsheet application acting as a server. The spreadsheet application, in turn, might act as a client in requesting the latest inventory levels from an automated inventory control application. an application can use several IPC mechanisms. Based on applications ru

Explain the flow of a simple win32 based application.

1. Global Variable are created. 2. Program execution starts at Winmain() 3. Create WndProc (switch cases for different messages) 4. Creates WndClass by specify window styles, properties and WndProc. 5. Registered WndClass created previously. 6. Create Window for this win32 application and display it. 7. Start the application message loop. 8. A message queue is associated with win32 application. 8. Loop seeks for messages from messages queues associated. 9. retrieves the messages and enter into WndProc. 10. executes appropriate Message handler.

Explain DEBUG_NEW or what is the use of DEBUG_NEW ?

#define new DEBUG_NEW Within each module of your application before you use the new operator to get more precise information. This step will cause your program to use DEBUG_NEW, a special version of the MFC new operator, which will also record line number and file name information for each allocation as it occurs. With this #define in place, any memory leak dumps will also include line number and source module name information for the allocation that caused the leak, thus helping you to pinpoint problems in your code. In the release build, DEBUG_NEW reverts back to the normal new operator. Also note that, as of MFC 4.0, it uses the heap management from the C run-time library. This means that you can use the same debugging features in non-MFC applications.

Explain Property, Property page and Property sheet.

property The data associated with an object. property page A grouping of properties presented as a tabbed page of a property sheet. property sheet A type of dialog box that is generally used to modify the attributes of an external object, such as the current selection in a view. A property sheet has three main elements: the containing dialog box, one or more property pages shown one at a time, and a tab at the top of each page that the user clicks to select that page. An example of a property sheet is the Project Settings dialog box in Visual C++

Explain dialog data exchange (DDX) and dialog data validation (DDV)

dialog data exchange (DDX) In MFC , a method for transferring data between the controls of a dialog box and their associated variables. DDX is an easy way to initialize dialog box controls and gather user data input. dialog data validation (DDV) In MFC , a method for checking data as it is transferred from the controls in a dialog box. DDV is an easy way to validate data entry in a dialog box.

What is assertion?

assertion A Boolean statement in a program's debug version that tests a condition that should evaluate as true, provided the program is operating correctly. If the condition is false, an error has occurred; thus, the program will typically issue an error message that gives a user the option to abort the program, activate the debugger, or ignore the error.

Explain application framework Or framework?

application framework Or framework. A group of C ++ classes in the MFC Library that provides the essential components of a Windows application. The application framework defines the basic operational structure of an application, and supplies standard user-interface implementations that can be incorporated into the application.

What is an ActiveX control?

ActiveX control An embeddable, reusable COM object that supports, at a minimum, the IOleControl interface. ActiveX controls are typically created for the user interface, but they also support communication with a control container. Multiple clients can reuse these controls, depending upon licensing restrictions.

You have created a licensed ActiveX control and have sold a copy to a development company. Should you provide them with a copy of the control's licens

as well? Why or why not? Yes, you should provide a copy of the license along with the product itself. ActiveX controls are sold to other developers, who in turn use them to create applications or Web pages designed for users. Licensing code prevents a developer from using an ActiveX control except in the presence of a valid license. When a developer adds an ActiveX control to an application project, the control confirms the existence of the license; only upon confirmation that the license exists can the control then be used.

What is the main advantage ATL offers over MFC when used to develop ActiveX controls?

The main advantage ATL offers ActiveX development is that ATL can create controls that have no dependencies. Properly written, an ActiveX control created from ATL requires neither MFC nor the C run-time library, ensuring that only the control's executable file needs to be downloaded from a Web page. ActiveX controls created usinng MFC can execute only when MFC42.dll and MSVCRT.dll are present on a system.

Must ActiveX controls be registered on a system before they can operate? If so, what examples can you give of a control's registry information?

ActiveX controls must be registered on a system before they can be used. Usually, this process is hidden from the user because it is performed automatically by a Web browser or by installation programs. The registry information must include the control's class identifier and its location on the system's hard disk.

What is the purpose of the InstallShield tool?

Given a Visual C++ project, InstallShield creates an installation package consisting of a Setup program, cabinet files, and miscellaneous information files. When run on another computer, the installation package installs the application and automatically configures the computer to run it.

What is regression testing?

In regression testing, an application is re-submitted to the same battery of tests it has already gone through. Regression testing is applied after changes are made to an application, and ensures that the changes do not introduce new bugs or unexpected behavior.

What is a dependency?

A dependency is an executable module, usually a DLL or an ActiveX control, that an application requires to execute. Dependencies can themselves have dependencies, forming a hierarchy of modules. For example, an MFC application might make no direct use of the C run-time library; nevertheless, the application is dependent on the library because MFC itself requires the C run-time library.

How does a debugger cause a running program to interrupt itself?

You can place debug breakpoints at designated locations in the program. When the program you are debugging encounters a breakpoint, execution freezes and the debugger gains control. Two types of breakpoints exist: location and data. Visual C++ also provides conditional and message breakpoints, but these are simply special cases of location breakpoints.

Describe MFC's ASSERT, VERIFY, and DEBUG_NEW macros.

ASSERT and VERIFY are very similar, differing in only one respect. Both macros take an expression as a parameter and cause an exception if the expression evaluates to FALSE. The only difference is that ASSERT does nothing in release builds, whereas VERIFY works in both debug and release code. DEBUG_NEW replaces calls to the new operator, performing the same service but also recording the file name and line number where each new statement occurs. This can help locate the cause of memory leaks resulting from a failure to match a new statement with a delete statement.

How does a debug version of a program differ from its release build?

Debug and release builds differ in two main characteristics. First, a program's debug build contains symbol information placed in the object code by the compiler, whereas the release code does not. Second, code in a debug build is not optimized, ensuring that the generated object code closely matches the original source code. Release code is almost always optimized.

What is an HRESULT?

In COM programming, an HRESULT is a defined type for a 32-bit-long integer containing an error code. COM components such as ActiveX controls export functions (or methods) that return HRESULT codes. An HRESULT integer contains bit fields that specify severity, facility, and a code descriptor. HRESULTs are signed integers; zero or a positive value indicates success, whereas a negative HRESULT indicates failure and usually causes an exception to occur.

What is Structured Exception Handling?

Structured Exception Handling is a service of the Windows operating system responsible for locating and calling handler code in an application when an error occurs. The application encloses code within a __try block and identifies its error handler code by placing it within an __except block.

In an ATL HTML control, how do you define methods to be accessible to the HTML source code of the

In an ATL HTML control, you define methods to be accessible to the HTML source code of the document displayed by the control by adding the methods to the UI dispatch interface that is created for your ATL HTML control project. This UI dispatch interface is used to communicate between the C++ code and the HTML UI. Script in the HTML page displayed by your control can access properties and methods defined for this interface via the DHTML window.external object.

What situations are best suited to using MFC to implement your ActiveX control?

MFC greatly simplifies the process of creating an ActiveX control. Using the MFC ActiveX ControlWizard, you can quickly and easily create a fully featured ActiveX control. ActiveX controls written in ATL are smaller than their MFC counterparts, and if written properly will perform better. Use MFC where ease and speed of development are more important to you than the size and performance of the control.

What is a connection point?

A connection point is an interface that helps to manage the connection of source interfaces to a corresponding client object, or sink. Through the connection point mechanism, a pointer to the sink interface is passed to the source object. This pointer provides the source with access to the sink's implementation of its interface methods.

What is the purpose of the second argument to CoCreateInstance()?

When an outer object creates an aggregated inner object, it uses the second argument of the CoCreateInstance() function to pass the address of its IUnknown pointer (the controlling unknown) to the inner object's class factory. If this address is not NULL, the inner object knows that it is being aggregated, and delegates IUnknown method calls from external clients to the controlling unknown.

How does a _com_ptr_t object help you control the lifetime of a COM server?

A _com_ptr_t object helps manage the lifetime of your COM server object by calling the IUnknown::AddRef() and IUnknown::Release() methods of the encapsulated interface on your behalf. AddRef() is called automatically when a _com_ptr_t object is created as a copy from an existing interface pointer, and Release() is called automatically when a _com_ptr_t object goes out of scope.

How are the keywords interface, coclass, and library used in IDL, and how do they relate to each

In an IDL file each COM object definition is identified by a separate coclass section, and each interface definition by a separate interface section. The server's type library is defined within the library section. The coclass definitions that are to be exposed through the type library are nested within the library definition.

What is an object map and how is it used?

An object map is a table that maintains information used by the framework to instantiate objects through a class factory, establish communication between a client and the root object in the component, perform lifetime management of class objects, and enter and remove object descriptions in the system registry. You can add an entry to the object map by using the OBJECT_ENTRY macro.

What is a COM map and how is it used?

A COM map is an element of your class declaration that contains a list of the interfaces that your COM object supports. Add an entry to the COM map by using the COM_INTERFACE_ENTRY macro. Whenever a client application executes QueryInterface(), the object searches this map for a matching interface GUID. If a match is found, the corresponding interface pointer is returned to the client.

Describe the features provided by the templated base class CComObjectRootEx.

The templated base class CComObjectRootEx provides a default implementation for the IUnknown interface methods QueryInterface(), AddRef(), and Release(). When you derive from this class, your client can use QueryInterface() to acquire an interface pointer to any interface that your COM object supports. CComObjectRootEx also provides implementations of the IUnknown methods AddRef() and Release() to perform reference counting for your object.

What issues must you consider when implementing an ActiveX control?

When implementing an ActiveX control, you must take into consideration that, although the definition of ActiveX controls requires only that the control support the IUnknown interface, different containers have different requirements. Some containers require certain interfaces for a control to work, while others do not. If you want your control to work with a particular container, your control must implement the interfaces required by the container.

What is a type library, and how is it used?

A type library is a binary description that includes interface properties and methods, and method arguments. Type libraries are used in situations when high-performance development languages, such as Visual Basic 6.0, need to be able to access interface methods directly, through the vtable. To make this possible, type libraries provide the Visual Basic client with information on which data types are required by the interface methods.

What are the differences among in-process, local, and remote server COM objects?

In-process servers, implemented as DLLs, execute within the same process as the object's client application. Local (or out-of-process) servers, implemented as .exe files, reside on the same computer as the client application, but execute in a different process. Remote servers execute on a computer remote from the clients that they are serving.

What steps are necessary to make a class serializable?

 Derive the class from CObject or a class that was derived from CObject.  Provide a default constructor for your class.  Add the MFC macro DECLARE_SERIAL to the class definition.  Add the IMPLEMENT_SERIAL macro to your class implementation file.  Provide an override of the C Object::Serialize() function for your class.

How do you create a hyperlink in a Help project .rtf file?

To create a hyperlink in a Help project .rtf file, you would format the links as double-underlined text and follow the links immediately by the link destinations formatted as hidden text. A pound (#) footnote mark signifies the link destinations. The footnote text contains the context name, which can either be a name internal to the Help file, or one of the Help context IDs specified in the Help project's .hm file.

What is the recommended way to update a status bar indicator?

The recommended method for updating a status bar indicator is to set up an array of status bar indicators associated with string IDs in the application's string table. The recommended way to update text in a status bar pane is to use an ON_UPDATE_COMMAND_UI entry in a message map to associate a user-interface update handler function with an indicator's string ID.

When developing an MFC application, under what circumstances might you need to call the Win32 API

When developing an MFC application, you might need to call the Win32 API directly when you need to access system functionality at a fairly low level. For example, if you were developing a utility to modify user accounts on a network, you would be required to use the Win32 networking functions because no MFC classes that provide access to Windows NT network management functions exist.

You are writing an MFC application that will allow your network administrator to manage user

You should install the MFC libraries for Unicode (either shared or static, according to how the application will be distributed). Internal strings used by Windows NT, such as user account names and device names, are Unicode strings, so you will need to install the Unicode libraries if you are planning to write programs that retrieve and manipulate these strings directly.

What are some of the benefits that MFC offers to developers?

Some such benefits include the ability for developers to quickly and easily generate applications, libraries, and software components. MFC enables rapid development in all aspects of Windows programming including user interface, Internet, component technology, and database access development—all without sacrificing programming freedom and flexibility. In addition, MFC provides the AppWizard, a step-by-step visual tool that allows developers to quickly and easily generate frameworks to set up a basic application structure, and to generate code to implement fundamental application behaviors.

What is the Message Compiler and when would it be used?

he manifest that contains the event definitions is compiled by the Message Compiler (MC.exe) tool. The Message Compiler is run before the source files compiler because it produces files required to compile the source files that raise events. It also generates the template and message resources to be added to the binary at link time. The Message Compiler is included in the Windows SDK The Message Compiler accepts a message file (.mc) as input and generates the following files: a C/C++ header file that contains definitions for the symbolic names, one binary resource file per supported language (Msg00001.bin, Msg00002.bin, and so on), and a resource file (.rc) that contains the appropriate statements to include each .bin file as a resource. Most manifests will use standard Windows-defined constants and the path to Winmeta.xml file that contains the definitions of these constants must be included. In many cases, this invocation is sufficient. Commonly, -h and –r switches are used to direct

What is the difference between implicit and explicit loading of a dll?

Implicit linking – this is loads automatically at the application startup itself and loaded throughout life of program. Consuming the memory which can be made available to other applications while not in use. Explicit – Explicitely loading dlls into memory by calling fuctions such as loadlibrary. Then user can take the fuction pointers of exported funcions calls the funcitons and afte use and unload library, freeing memmory consumed by dll , so that it can be available to other use.

What is a GUID and where is it used?

Represents a globally unique identifier (GUID). A GUID is a 128-bit integer (16 bytes) that can be used across all computers and networks wherever a unique identifier is required. Such an identifier has a very low probability of being duplicated. he GUID data type is a text string representing a Class identifier (ID). COM must be able to convert the string to a valid Class ID. All GUIDs must be authored in uppercase. The valid format for a GUID is {XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX} where X is a hex digit (0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F). Note that utilities such as GUIDGEN can generate GUIDs containing lowercase letters. These must all be changed to uppercase letters before the GUID can be used by the installer as a valid product code, package code, or component code.

Describe MFC's ASSERT, VERIFY, and DEBUG_NEW macros.

ASSERT and VERIFY are very similar, differing in only one respect. Both macros take an expression as a parameter and cause an exception if the expression evaluates to FALSE. The only difference is that ASSERT does nothing in release builds, whereas VERIFY works in both debug and release code. DEBUG_NEW replaces calls to the new operator, performing the same service but also recording the file name and line number where each new statement occurs. This can help locate the cause of memory leaks resulting from a failure to match a new statement with a delete statement.

What is an HRESULT?

In COM programming, an HRESULT is a defined type for a 32-bit-long integer containing an error code. COM components such as ActiveX controls export functions (or methods) that return HRESULT codes. An HRESULT integer contains bit fields that specify severity, facility, and a code descriptor. HRESULTs are signed integers; zero or a positive value indicates success, whereas a negative HRESULT indicates failure and usually causes an exception to occur

What is Structured Exception Handling?

Structured Exception Handling is a service of the Windows operating system responsible for locating and calling handler code in an application when an error occurs. The application encloses code within a __try block and identifies its error handler code by placing it within an __except block.

What is regression testing?

In regression testing, an application is re-submitted to the same battery of tests it has already gone through. Regression testing is applied after changes are made to an application, and ensures that the changes do not introduce new bugs or unexpected behavior.

What is the main advantage ATL offers over MFC when used to develop ActiveX controls?

The main advantage ATL offers ActiveX development is that ATL can create controls that have no dependencies. Properly written, an ActiveX control created from ATL requires neither MFC nor the C run-time library, ensuring that only the control's executable file needs to be downloaded from a Web page. ActiveX controls created using MFC can execute only when MFC42.dll and MSVCRT.dll are present on a system.

What are some of the benefits that MFC offers to developers?

Some such benefits include the ability for developers to quickly and easily generate applications, libraries, and software components. MFC enables rapid development in all aspects of Windows programming including user interface, Internet, component technology, and database access development—all without sacrificing programming freedom and flexibility. In addition, MFC provides the AppWizard, a step-by-step visual tool that allows developers to quickly and easily generate frameworks to set up a basic application structure, and to generate code to implement fundamental application behaviors.

Explain Visual C++ Project types.

Visual C++ Project Types The Visual C++ New Project dialog box gives you the option of creating a project for the development of applications, components, or libraries using the following methods:  MFC development The MFC development option generates a framework based on MFC , which you can use to develop applications, DLLs, or ActiveX controls. Other project types, such as those generated by the Internet Server API (ISAPI) Extension Wizard, are also based on an MFC framework. Although MFC saves you time and effort in the creation of Windows programs, simple programs might not justify the code size and performance overhead of MFC . To use MFC in an application, you need to link the MFC static libraries to your code or ensure that the MFC DLLs are installed on each computer that will run your application. C onsider whether your application needs the types of application framework created by the MFC project options.  Win32 development The Win32 options allow you to create simple Window

Compare ATL vs. MFC

In a way, ATL is to COM what MFC is to the Windows API. The goal of ATL is to provide a thin but effective wrapper around the most common COM interfaces without sacrificing component performance. Despite this similarity, however, the designs of MFC and ATL differ in several key ways: MFC contains an interconnected hierarchy of classes, whereas ATL is a set of disjoint templates. This difference means that with ATL you don't pay the size/speed penalty for a given feature unless your component actually uses it. MFC is linked to a project as a static library or a DLL, but ATL is compiled as source code. Because there are no OBJ files to link to, ATL requires no run-time DLL redistribution.1 MFC supports a single-inheritance model, whereas the functionality of an ATL component depends entirely on the use of multiple inheritance. Specifically, a component that supports several different COM interfaces will inherit from several different associated ATL templates. Over time, MFC has grown

The Benefits and Drawbacks of MFC

The goal of MFC is to make it as easy as possible for C++ developers to create robust Windows applications without sacrificing application performance. For that reason, the MFC class wrappers around the Windows API are, by design, wide and shallow. In other words, although it encapsulates many different APIs, the abstraction layer between the MFC classes and the native Win32 functions under the hood is noticeably thin. For example, the CWnd::SendMessage function does nothing more than call the SendMessage function exposed by the Windows API. Although this approach is frustrating to some developers—especially those who want to develop Windows-based applications without having to invest the time to understand the ins and outs of the Windows programming model—it is most often a good trade-off. It simplifies application development without selling out on speed. Of course, applications built using MFC will suffer some performance penalty compared to those built with the raw Windows API, but