[英]winapi declaration in c#
有人可以告诉我如何在C#中声明winapi? 我遇到这个错误:
Error 1 The name 'WinApi' does not exist in the current context bla bla bla...
排队:
WinApi.OpenProcess(WinApi.PROCESS_ALL_ACCESS, 0, (uint)aProc[0]);
如果您未使用提供这些方法和常量的库,则需要使用Platform Invocation Services(P / Invoke)自己实现它们。
例如:
public static class WinApi {
public const int PROCESS_ALL_ACCESS = /* whatever the value is */;
[DllImport("kernel32.dll")]
public static extern IntPtr OpenProcess(int dwDesiredAccess,
bool bInheritHandle, int dwProcessId);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.