There is a simple question: Looking for Windows API definitions is generally asking: C # Is there any windows. h file similar to that used in C ++?
This is really a silly question. It's a C #ProgramMembers will know that C # does not have any header file. So the answer is too simple: No -_-.
Yes, this is the answer that C # programmers know. But how can someone still ask this question? So either the person who asks the question is an idiot or you don't understand the problem.
The real purpose of this problem is that he wants to call Native Windows APIs in C #, but he feels that it is cumbersome to declare windows APIs one by one and their data structures. In C ++, windows. h can be directly called.
Of course more people understand this question and give some reliable answers: With http://pinvoke.net/
Further think ,. net Framework itself must also use a lot of windows APIs, if decompile is a few. net Framework DLL, you will find that what you want is in Microsoft. under Win32, unfortunately, all are internal. We have to re-create the wheel.
Why does. NET Framework not publish these things? I guess it may be because the. NET Framework itself should be platform-independent. If you make these public, use these ApisCodeObviously, it cannot run on Linux. As for writing pinvoke code by yourself, although the Code cannot be cross-platform, this is user behavior, and Microsoft is not responsible.
Using pinvoke is not just as simple as writing a declaration. You must also consider whether the current operating system does not support or does not support workaround. You also need to consider the parameter encoding/decoding. Every time you use pinvoke, it makes no sense to repeat these tasks.
Therefore, there is a garbage in http://pinvoke.net. Http://pinvoke.codeplex.com/is a better choice.
No silly questions, only stupid answers.