Sign in to follow this  
hkBattousai

Win32 in C# - Is that possible?

Recommended Posts

I have just started to learn C#. Before I thought it would be something like CPP and Visual Basic combined, but it seems more likely to be Java and VB. Anyway, i'll to ask something else, I want to use Win32 API functions embeded in my C# code. Like :
private void button1_Click(object sender, EventArgs e)
{
	// C# code
	MessageBox.Show("If you can read this text, it means my program works...",
			"SUCCESS!",
			MessageBoxButtons.OK,
			MessageBoxIcon.Information,
			MessageBoxDefaultButton.Button1,
			MessageBoxOptions.DefaultDesktopOnly);

	// A Win32 function
	HANDLE hFile = CreateFile((LPCTSTR)               "Input.txt",
        	                  (DWORD)                 GENERIC_READ,
                	          (DWORD)                 FILE_SHARE_READ,
                        	  (LPSECURITY_ATTRIBUTES) NULL,
				  (DWORD)                 OPEN_EXISTING,
        	                  (DWORD)                 FILE_ATTRIBUTE_NORMAL,
                	          (HANDLE)                NULL);
}
How can I do that?

Share this post


Link to post
Share on other sites
Also, I would generally make sure that the functionality you are looking for isn't already in the .Net framework (like file handling).

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this