Windows API

Windows API

This multi Windows operating system in addition to performing, memory allocation, resource coordination management applications, it is also a great service center, call the service center's various services (each service is a function), can help app reaches open windows, drawing pattern, using peripheral equipment such purposes, since the service functions of these objects is the application (the application), so they called the application Programming Interface, API functions referred to. WIN32 API application is Microsoft Windows 32-bit platform programming interface.

C # Windows API calls

C # Windows API call format of the call, the .Net Framework SDK documentation is more fragmented. But the most common way of Windows API in C # is DllImport for processing and use C # keyword static method and the extern declaration.


[DllImport("kernel32")]
public static extern void GetWindowsDirectory(StringBuilder WinDir,int count);  

In the above code, the DllImport attribute code is used to call a method never controllable, which specifies the location of the DLL, the DLL contains method calls outside:

  • kernel32 set library name
  • Access Type public function is specified in the public domain
  • static modifier to declare a static element, the element is of the type itself rather than the specified object
  • extern indicates that the method will be executed in external works, while use DllImport extern modifier must be introduced

Guess you like

Origin www.cnblogs.com/bedfly/p/12154056.html