Home

Using a Win32 Function

 

Introduction

The Microsoft Windows operating system was originally written in C, the parent language of C++ and C# (also of Java and JavaScript). To allow programmers to create applications, the company released a library called Win32. This is a series of functions, classes, and objects that you previously had to use. As time has changed, you don't need to exclusively use Win32 anymore to create a Windows application. Nonetheless, Win32 is still everywhere and it is not completely avoidable because many or some of the actions you would want to perform in a a Windows application are still available only in Win32. Fortunately, in most cases, it is not always difficult to use some these functions in a C# applications, as long as you observe some rules.

using System;
using System.Runtime.InteropServices;

namespace Win32Applied
{
    class Program
    {
        [DllImport("Kernel32.dll")]
        public static extern bool SetConsoleTitle(string strMessage);

        static int Main()
        {
            SetConsoleTitle("C# Programming");

	    return 0;
        }
    }
}

 

 

Home Copyright 2006 FunctionX, Inc.