Skip to main content

Windows Programming Interview Questions

1.

How would you find the brushes or fonts used by the system to draw menus, dialog boxes and text?

GetStockObjct

2.

How would you start a new thread?

Afxbeginthread – for worker thread only global fuction passed as parameter

For ui thread , a class derived from CWinThread passed as parameter

3.

When should an application call _beginthread rather than CreateThread?

If apliation is using C run-time library (CRT) then.

4.

How would you check if a process has terminated?

GetexitCode()

5.

Why would you use a critical section instead of a mutex? Are there any situations when a mutex would have to be used?

Mutexes are slower thatn CS.

If we want to synchronise two thread across different processes then

6.

Name five IPC mechanisms supported by Window XP. What about Windows CE?

7.

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

Static linking which loads automatically.- loaded throughout life of program

Explicit – can use loadlibrary – take the fuction ptr use and unload library.

8.

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

9.

How would you declare a string which could be used in an ANSI or UNICODE build? Which header would you include to support functions which could use either version of this string?

Enclosed inside _T() macro for unicoade for ansi normal one (Without)

10.

What are BSTRs and when are they used?

They double byte strings used for COM.

11.

What is the difference between a variable of type INT and a variable of type INT_PTR?

One is the varialbe, another is pointer to some location

12.

How would you determine the correct size of icons for fitting into a standard windows caption?

13.

Why is it bad to call FindWindow based on a Window Title?

14.

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

Window - It’s the size of window frame.

Clients- working area.

Get the handle to the child window. And call getclientrect

15.

What form of Unicode encoding is standard on Windows? What other character encoding formats are you likely to encounter?

16.

You find yourself drawing a string where letters appear as box characters on the screen. Why might this happen, and what would you do about it? What if the string contains characters from different code pages?

It’s a different character set.

17.

What interface do all COM classes implement and what is its purpose?

Interface is the way of communicating with com.

18.

What do you do if you have a pointer to a COM object implementing one interface but need to use another?

19.

What is the difference between a SendMessage and a PostMessage?

One sent to window never returns until handler is executed.

Posted to message queue. Returns immediately Later on picked up and proccessed

20.

Why do windows have class names and window names?

It is registered to widows database to keep track of the activities.

21.

We are building using a "Pocket PC 2003" SDK, for compatibility, but also running on "Mobile 5 Pocket PC" devices. On the Mobile 5 devices we need to make an API call that was not available in PPC 2003. That is, we will get a link error if we try to reference the function. How can we do it? FYI, the function is ExitWindowsEx.

22.

Describe the different approaches you can use to synchronise threads/processes in win32.

1. Critcal section – user for syncroinising threads from same process

. Mutexes – user for syncroinising threads from different process

. Semaphore – maintains resource counting against process use.

23.

Describe the basics of the WNDPROC architecture.

Its call back . having switch statement for proceeding messages.

24.

What is a GUID and where is it used?

Globally uniq id to identify a com distinctly.

Comments

Popular posts from this blog

MFC - Microsoft Foundation Classes Design Patterns

1 Introduction This paper describes the use of object-oriented software design patterns, as presented in Design Patterns: Elements of Reusable Object-Oriented Software by Gamma et al., within the Microsoft Foundation Class Library (MFC). MFC is used for implementing applications for Microsoft Windows operating systems. Because of the size of the MFC library, a complete analysis would have been beyond the scope of this assignment. Instead, we identified various possible locations for design patterns, using the class hierachy diagram of MFC, and studied the source carefully at these locations. When we did not find a pattern where we expected one, we have documented it anyway, with examples of how the particular problem could have been solved differently, perhaps more elegantly, using design patterns. We have included a brief introduction to MFC in Section 2 , as background information. The analysis has been split into three parts, with one section for each major design pattern ca...

Explain Polymorphism and Flavors of Polymorphism...

Polymorphism is the ability of different objects to react in an individual manner to the same message. This notion was imported from natural languages. For example, the verb "to close" means different things when applied to different objects. Closing a door, closing a bank account, or closing a program's window are all different actions; their exact meaning is determined by the object on which the action is performed. Most object-oriented languages implement polymorphism only in the form of virtual functions. But C++ has two more mechanisms of static (meaning: compile-time) polymorphism: Operator overloading. Applying the += operator to integers or string objects, for example, is interpreted by each of these objects in an individual manner. Obviously, the underlying implementation of += differs in every type. Yet, intuitively, we can predict what results are. Templates. A vector of integers, for example, reacts differently from a vector of string objects when it receives ...

• Why might you need exception handling be used in the constructor when memory allocation is involved?

Your first reaction should be: "Never use memory allocation in the constructor." Create a separate initialization function to do the job. You cannot return from the constructor and this is the reason you may have to use exception handling mechanism to process the memory allocation errors. You should clean up whatever objects and memory allocations you have made prior to throwing the exception, but throwing an exception from constructor may be tricky, because memory has already been allocated and there is no simple way to clean up the memory within the constructor.