Код ошибки CS0246 при импорте "user32.dll" - C#
Формулировка задачи:
Основная задача - найти окно другой программы.
Нашёл код для импорта функции FindWindow из библиотеки "user32.dll" http://pinvoke.net/default.aspx/user32/FindWindow.html
И этот код (строчки с DllImport) выдаёт у меня ошибки.
Сама программа
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace programma
{
static class Program
{
[DllImport("user32.dll", SetLastError = true)]
static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
// Find window by Caption only. Note you must pass IntPtr.Zero as the first parameter.
[DllImport("user32.dll", EntryPoint = "FindWindow", SetLastError = true)]
static extern IntPtr FindWindowByCaption(IntPtr ZeroOnly, string lpWindowName);
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
FindWindow(null, "Калькулятор");
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
}Решение задачи: «Код ошибки CS0246 при импорте "user32.dll"»
textual
Листинг программы
using System.Runtime.InteropServices;