有人可以告诉我如何在c#中声明winapi?我有这个错误:
Error 1 The name 'WinApi' does not exist in the current context bla bla bla...
Run Code Online (Sandbox Code Playgroud)
排队:
WinApi.OpenProcess(WinApi.PROCESS_ALL_ACCESS, 0, (uint)aProc[0]);
Run Code Online (Sandbox Code Playgroud)
如果您没有使用提供这些方法和常量的库,则需要使用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);
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1236 次 |
| 最近记录: |