C # Problems in referencing ins | Csharp cite the plugin problem,

Source: Internet
Author: User

C # Problems in referencing ins | Csharp cite the plugin problem,

Background: use C # To manipulate the mouse for repetitive work

Background: using Csharp to handle the keyboard or mouse to do the repetitive work.

Problem: the attribute "DllImport" is invalid in this Declaration type. It is valid only in the "method" declaration. Error 1 attribute "DllImport" in this Declaration class

Question: attribution "DllImport" is invalid in the declaration, it is just valid in the "method" declaration

Solution: use external call Methods

Solution: Use the external method

Code example:

Private static extern int mouse_event (
Int dwFlags, // One of the following table flags or their combination
Int dx,
Int dy, // specifies the absolute or relative position of the x and y directions.
Int cButtons, // not used
Int dwExtraInfo // not used
);

Extern is used to declare the method implemented externally, it is often used in the situation that interop (using System. runtime. interopServices) to call unmanaged code in and DllImport is used at the same time. at that time the method shoshould declard as static.

Reference page: http://qingqingquege.cnblogs.com/p/5933752.html

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.