Know a good article or link that we're missing? Submit it!
*/

Other Views

corner
*/

Uses Of Win32 API from a .NET Framework Program

Can I use the Win32 API from a .NET Framework program?

Using platform invoke it's possible. .NET Framework programs can access native code libraries by means of static DLL entry points.

Here is an example of C# calling the Win32 MessageBox function:

 
using System; 
using System.Runtime.InteropServices; 
 
class MainApp 
{ 
    [DllImport("user32.dll", EntryPoint="MessageBox")] 
    public static extern int MessageBox(int hWnd, String 
strMessage, String strCaption, uint uiType); 
 
    public static void Main() 
    { 
        MessageBox(0, "This is PInvoke in operation!", 
".NET", 0 ); 
    } 
}


Written by Sandeep Mogulla, Webmaster at www.startvbdotnet.com

Index
corner
© 1996-2008 CommunityHeaven LLC. All rights reserved. Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
North American business development: Nicolai Wadstrom. Publisher: Lars Hagelin.
Resource Listings