Calling unmanaged code from managed code

  • Thread starter Thread starter Guest
  • Start date Start date
Hi KL,

You use P/Invoke (Platform Invoke) with DllImport (found in
system.Runtime.InteropServices).

Win 32 API code

HWND FindWindow( LPCTSTR lpClassName, LPCTSTR lpWindowName);

To call this method put something like this in your code (C#)

[DllImport("user32.dll")]
public static extern int FindWindow(string lpClassName, string
lpWindowName);

There is more to DllImport that lets you rename the methodname and specify
unicode etc, but this is the basic way.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top