Reputation: 63
Somebody could tell me how to declare winapi in c#? I'm having this error:
Error 1 The name 'WinApi' does not exist in the current context bla bla bla...
in line:
WinApi.OpenProcess(WinApi.PROCESS_ALL_ACCESS, 0, (uint)aProc[0]);
Upvotes: 0
Views: 1466
Reputation: 36269
If you're not using a library that provides those methods and constants, you'll need to implement them yourself using Platform Invocation Services (P/Invoke).
For example:
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);
}
Upvotes: 7