Friday, January 21, 2011

Windows API Programming Basics

Windows Programming is very much different from the C programming.To begin Windows API you should have an appropriate compiler.To develop software that utilizes the Windows API, a compiler must be able to handle and import the Microsoft-specific DLLs and COM-objects. The compiler must either handle the header files that expose the interior API function names, or supply such files by itself. For certain classes of applications, the compiler system should also be able to handle IDL (interface definition language) files. Collectively, these prerequisites (compilers, tools, libraries, and headers) are known as the Microsoft Platform SDK. For a long time, the Microsoft Visual Studio family of compilers and tools and Borland's compilers were the only tools that could provide this (although at least in the case of Windows, the SDK itself is downloadable for free separately from the entire IDE suite, from Microsoft Platform SDK Update). Nowadays, the MinGW and Cygwin projects also provide such an environment based on the GNU Compiler Collection, using a stand-alone header file collection to make linking against Microsoft DLLs possible. LCC-Win32 is a "free for non-commercial use" C compiler maintained by Jacob Navia. Pelles C is another freeware C compiler maintained by Pelle Orinius. Free Pascal is a free software Object Pascal compiler capable of writing software based on the Windows API. MASM32 is a mature project by Microsoft to provide support for the Windows API under MASM-syntax x86 assembly by using custom made or converted headers and libraries from the Platform SDK.

Simple Windows Program

Let's start windows programming.Here we are assuming that you are familier with c programming language.
If you dont know how to program in c then it's not the right place for starting windows programming using c.
Another assumption made by us is that your using Visual C++ 2008 with Visual Studio 2008.Programming using another compilers will be discussed later.

Let's code our first windows program.If your new to Visual Studio then following Video will help you to start new project in Visual C++ 2008


#include<windows.h>
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nShowCmd)
{
MessageBox(NULL,"Hello WIN32 API!","HELLO MSG",0);
return 0;
}

If you have any problem in running the program plz see the following video.

As you see Window API program is different from the regular c program. Windows have its own datatypes for windows programming.

Saturday, January 15, 2011

What is Win32 API.................. continue

 Web

The Internet Explorer web browser also exposes many APIs that are often used by applications, and as such could be considered a part of the Windows API. Internet Explorer has been included with the operating system since Windows 98 Second Edition, and has provided web related services to applications since Windows 98. Specifically, it is used to provide:
  • An embeddable web browser control, contained in shdocvw.dll and mshtml.dll.
  • The URL monitor service, held in urlmon.dll, which provides COM objects to applications for resolving URLs. Applications can also provide their own URL handlers for others to use.
  • A library for assisting with multi-language and international text support (mlang.dll).
  • DirectX Transforms, a set of image filter components.
  • XML support (the MSXML components, held in msxml*.dll).
  • Access to the Windows Address Book.
Multimedia
Microsoft has provided the DirectX set of APIs as part of every Windows installation since Windows 95 OSR2. DirectX provides a loosely related set of multimedia and gaming services, including:
  • Direct3D for access to 3D hardware accelerated graphics.
  • DirectDraw for hardware accelerated access to the 2D framebuffer. As of DirectX 8, this component has been deprecated in favor of Direct3D, which provides more general high-performance graphics functionality (as 2D rendering is a subset of 3D rendering).
  • DirectSound for low level hardware accelerated sound card access.
  • DirectInput for communication with input devices such as joysticks and gamepads.
  • DirectPlay as a multiplayer gaming infrastructure. This component has been deprecated as of DirectX 9 and Microsoft no longer recommends its use for game development.
  • DirectShow which builds and runs generic multimedia pipelines. It is comparable to the GStreamer framework and is often used to render in-game videos and build media players (Windows Media Player is based upon it). DirectShow is no longer recommended for game development.
  • DirectMusic - allows playing of MIDI files, deprecated.
Program interaction
The Windows API mostly concerns itself with the interaction between the operating system and an application. For communication between the different Windows applications among themselves, Microsoft has developed a series of technologies alongside the main Windows API. This started out with Dynamic Data Exchange (DDE), which was superseded by Object Linking and Embedding (OLE) and later by the Component Object Model (COM), Automation Objects, ActiveX controls, and the .NET Framework. There is not always a clear distinction between these technologies, and there is quite a lot of overlap.
The variety of terms is basically the result of grouping software mechanisms that relate to a particular aspect of software development. Automation specifically relates to exporting the functionality of an application or component (as an API) so that it can be controlled by another application instead of just by a human user, .NET is a self-contained general methodology and technology for developing Desktop and Web applications written in a variety of "Just in Time" compiled languages.

Wrapper libraries

Various wrappers were developed by Microsoft that took over some of the more low level functions of the Windows API, and allowed applications to interact with the API in a more abstract manner. Microsoft Foundation Class Library (MFC) wrapped Windows API functionality in C++ classes, and thus allows a more object oriented way of interacting with the API. The Active Template Library (ATL) is a template oriented wrapper for COM. The Windows Template Library (WTL) was developed as an extension to ATL, and intended as a lightweight alternative to MFC.
Also notable are some of Borland's offerings. Object Windows Library (OWL) was released to compete with MFC, and offered a similar object-oriented wrapper. Borland later deprecated it in favour of the Visual Component Library (VCL), which is written in Object Pascal and available in both Delphi and C++ Builder.
Most application frameworks for Windows (at least partially) wrap the Windows API. Thus, the .NET Framework and Java, likewise any other programming languages under Windows, are (or contain) Wrapper Libraries.
Windows API Code Pack for Microsoft .NET Framework is a .Net Wrapper Library for Windows API.

Friday, January 14, 2011

What is Win32 API

The WIndows API, informally WinAPI,is Microsoft's core set of application programming interfaces(API's) available in the Microsoft Windows
operating systems.It was formerly called the Win32 API;however,the name Windows API
more accurately reflects its roots in 16-bit Windows and its support on 64-bit Windows.Almost all
programs interact with the Windows API; a small number (such as programs started early in the windows startup process)
use the NATIVE API.

OVERVIEW
The functionality provided by the Windows API can be grouped into 8 categories.
1-Base Services
Provide access to the fundamental resources available to windows system.Including things like file systems,
devices,processes and threads and error handling.These function reside in kernel.exe krnl286.exe
or krnl386.exe files on 16-bit windows and kernel32.dll on 32-bit Windows.

2-Advanced Services
Provide access to the functionality additional to the kernel.Included are things like the
Windows Registry,shutdown/restart the system (or abort),start/stop/create a Windows Service
manage User accounts
.These functions reside in advapi32.dll on 32-bit WIndows.

3-Graphics Device Interface
Provide functionality for outputting graphical content to monitors, printers and other output
devices.It reside in gdi.exe on 16-bit WIndows and gdi32.dll on 32-bit Windows
in user-mode.Kernel-mode GDI support is provide by win32k.sys which communicates directly with the
graphics driver.

4-User Interface
Provide the functionality to create and manage screen windows and most basic controls
such as buttons and scrollbars,receive mouse and keyboard input, and other functionality associated with the GUI
part of Windows.The functional unit resides in user.exe on 16-bit Windows and user32.dll on 32-bit Windows
Since Window Xp versions,the basic controls resides in comctl32.dll together with
common controls(Common Control Library).
5-Common Dialog Box Library
Provide applications the standard dialog boxes for opening and saving files,choosing
color and font etc
.The library reside in a file commdlg.dll on 16-bit Windows
and comdlg32.dll on 32-bit Windows.It is grouped under User Interface Category of the API

6-Common Control Library
Gives Application to some advanced controls provided by the operating system.These includes
things like status bars,progress bars,toolbars and tabs. The library resides in a
in a dll file called commctrl.dll 0n 16-bit Windows and commctrl32.dll on 32-bit Windows.

7-Windows Shell
Component of the Windows API allows application to access the functionality provided by the
by the operating system shell, as we well change and enhance it.The component resides in
shell.dll on 16-bit Windows and shell32.dll on 32-bit Windows.The shell LightWeigth Utility
function are in shlwapi.dll.

8-Network Services
Give access to various networking capabilities of the operating system.Its sub-component include
NetBIOS,WinSock,NetDDE,RPC and many others..........
.........to be continue.

Welcome to pro-mania

Welcome friends to the pro-mania.Pro-mania is a programming blog,on which we will try to figure out the popular programming language and its related toturials.Our main interest will in windows api programming, visual c++,opencv and c programming language.