Can I use the Win32 API from a .NET Framework program?
Submitted by: AdministratorYes. Using platform invoke, .NET Framework programs can access native code libraries by means of static DLL entry points.
Here is an example of C# calling the Win32 Message Box 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, "Hello, this is PInvoke in operation!", ".NET", 0 );
}
}
Submitted by: Administrator
Here is an example of C# calling the Win32 Message Box 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, "Hello, this is PInvoke in operation!", ".NET", 0 );
}
}
Submitted by: Administrator
Read Online ASP Programming Job Interview Questions And Answers
Top ASP Programming Questions
☺ | What is application Object in ASP? |
☺ | What is the difference between Querystring collection and Form collection? |
☺ | Should user input data validation occur server-side or client-side? Why? |
☺ | Where is the value-type variables allocated in the computer RAM? |
☺ | What is the difference between Server.Transfer and Response.Redirect? Why would I choose one over the other? |
Top Dot Net Technologies Categories
☺ | MSF Interview Questions. |
☺ | .Net Architecture Interview Questions. |
☺ | ASP.Net MVC Interview Questions. |
☺ | Entity Framework Interview Questions. |
☺ | C# (Sharp) Programming Language Interview Questions. |