Skip to content

Latest commit

 

History

History
26 lines (20 loc) · 1.1 KB

README.en-US.md

File metadata and controls

26 lines (20 loc) · 1.1 KB

WinAPI Importer

zh-CN | en-US

Provide a simple declaration method for WinAPI to C# programmers.

(The extension is currently in the preview version)

Usage

  1. Declare a Attribute class to mark the class that loads WinAPI functions, and the name of the attribute class should be WindowsAPIAttribute.
  2. Declare a class and label it with a [WindowsAPI] annotation. The access modifier of the class will determine the access modifier of the generated function, for example:
    [WindowsAPI]
    internal static class WindowsNative
    {
        static WindowsNative()
        {
            if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
                throw new PlatformNotSupportedException(ET("The current module only supports working on Windows"));
        }
    }
  3. Type className.functionName anywhere in the current project, press Alt+Enter(quick operation), select <Search WinAPI 'functionName'> from the pop-up menu, and then you can preview the generated API function, as shown in the figure: Sample image