错误 1 属性“DllImport”在该声明类型中无效。它只在“method”声明中有效。
错误 1 属性“DllImport”在该声明类型中无效。它只在“method”声明中有效。 C:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\Projects\WindowsApplication13\WindowsApplication13\Form1.cs 14 10 WindowsApplication13
这是什么错误 得怎么改啊
顺便问下[DllImport("user32")] 这么写对吗
USER32需要自己下吗
------解决方案--------------------
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace WindowsApplication13
{
public partial class Form1 : Form
{
[DllImport("user32")]
public static extern void mouse_event(int dwFlags, int dx, int dy, int dwData, int dwExtraInfo);
private readonly int MOUSEEVENTF_LEFTDOWN = 0x2;
private readonly int MOUSEEVENTF_LEFTUP = 0x4;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
mouse_event(MOUSEEVENTF_LEFTDOWN, 10 * 65536 / 1024, 10 * 65536 / 768, 0, 0);
mouse_event(MOUSEEVENTF_LEFTUP, 10 * 65536 / 1024, 10 * 65536 / 768, 0, 0);
}