Posts tagged ‘API’

Marshaling with C# – Chapter 3: Marshaling Compound Types

Marshaling with C# Pocket Reference
Chapter 3: Marshaling Compound Types (structures, unions, etc.)

Marshaling with C# – Chapter 2: Marshaling Simple Types

Marshaling with C# Pocket Reference
Chapter 2: Marshaling Simple Types (primitives, booleans, strings, etc.)

Marshaling with C# – Chapter 1: Introducing Marshaling

Marshaling with C# Pocket Reference
Chapter 1: Introducing Marshaling

Marshaling with C# Pocket Reference

Marshaling with C# Pocket Reference (online version + direct download links)

Learn how to marshal between managed types and unmanaged types.

BeginPaint/EndPaint or GetDC/ReleaseDC?

Which is better, to use BeginPaint/EndPaint, or to use GetDC/ReleaseDC?

How To: Refer a Resource

This article teaches you how to refer to resources, to use Resource IDs, and to use Resource Names. It doesn’t talk about resource, how to define them, or how to load them. It assumes previous knowledge of ABCs of handling resources in an IDE like Microsoft Visual Studio or Microsoft Visual C++.

Marshaling Unions

If this is your first time you hear about unions or you need to know more about them, please refer to our article “A short speech about Unions” first.

You can marshal a union the same way you marshal structures. However, because of the way that unions laid-out into memory, you will need to explicitly set variable positions inside the type.

BOOL or BOOLEAN?

Windows comes with two types that represent a Boolean variable (TRUE or FALSE.) Both represent FALSE if 0 and TRUE if non-zero.

Microsoft Win32 to Microsoft .NET Framework API Map

This MSDN article identifies the .NET Framework APIs that provide similar functionality to those of Microsoft Win32 API.

Moving a Form without the Title Bar

Today, we are talking about how to move a form without its title bar.

You might have noticed that some applications with fancy UIs do not allow the user to move the window from its title bar. Honestly, some hide the overall title bar from the user. An example of these applications is Microsoft Windows Media Player -when in skin mode,- and Microsoft Windows Live Messenger. Both applications allow you to drag their windows using the client area not the title bar.

In this lesson, you will learn how to do this trick to move the form without its title bar.

Changing Display Settings Programmatically

Previously, we have talked about how to change screen resolution and color system via DirectX. Today, we are talking about how to change all display settings -not the resolution and color system only- via API. We will change screen resolution (bounds,) color system (bit count,) rotation (orientation,) and refresh rate (frequency) via API with C# and the .NET Framework.

Programmatically Turning on the Screen Saver

This lesson focuses on how to programmatically turn on the screen saver.

Clearing the Console Screen using API

In addition to clearing the console screen, this lesson teaches you some about PInvoking, marshaling, and memory management. Also you will learn additional techniques like clearing a specific portion of the screen, and changing the cursor position. Moreover, you will dig into IL and see how System.Console.Clear() method do it. More than that you will learn how to reverse-engineer a .NET assembly and discover the code inside.

In addition, the example shows how to perform I/O operations on console using Win32 API calls, and how to show/hide the console cursor. In addition, it demonstrates how to move a text around the console screen.

Programmatically Swapping Mouse Buttons

Swapping mouse buttons means swapping the two buttons, making the right button acts like the left one and vice versa. This is done -for normal users of course- using the Mouse properties dialog in the control panel. See the next figure.

Creating Transacted Files

Lastly but not last, and after a long while, Windows Vista introduced a way to create transacted files or even to write to registry.

While market grows remarkably in the last years, its requirements increase as well. And every day you face a new problem that you must overcome to accommodate market requirements.

Transacted operations are one of the commonly demanded requirements by market.