[英]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.