Microsoft 98-372 Exam Question 9

Microsoft 98-372 Exam Question 9

You want to access a native Win32 function from a .NET application. You import the function. Which two keywords should you use to define the function? (Each correct answer presents part of the solution. Choose
two.)

A. Extern
B. Static
C. Private
D. Public

Answer: A, D

Explanation:


Example:
using System.Runtime.InteropServices; using System.Windows.Interop; using System.Diagnostics; using System.Threading; public partial class MainWindow : Window { [DllImport("user32.dll", SetLastError = true)] static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndNewParent); [DllImport("user32.dll", SetLastError = true)] static extern IntPtr FindWindow(string lpClassName, string lpWindowName); public MainWindow() { InitializeComponent(); }private void btnHost_Click(object sender, outedEventArgs e) { WindowInteropHelper wndHelp = new WindowInteropHelper(this); Process.Start("Notepad.exe"); // Sleep the thread in order to let the Notepad start completely Thread.Sleep(50); SetParent(FindWindow("NotePad", "Untitled - Notepad"), wndHelp.Handle); } }

No comments:

Post a Comment