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.
 
Back
Top