C# 如何了解 Win32 API?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10054653/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-09 12:16:14  来源:igfitidea点击:

How can I learn about the Win32 API?

c#windowswinapi

提问by MasterMastic

I want to learn how to be able to use the Win32 API, since recently I've got a lot of tasks I need to do which requires functions from user32.dll, so I'm trying to learn and I Googled but the thing is: every tutorial there is about it, just tells you how to do a certain thing. like show a MessageBoxthrough the Win32 API, but you can't actually learn Win32 framework.

我想学习如何使用 Win32 API,因为最近我有很多需要做的任务,这些任务需要来自 的函数user32.dll,所以我正在尝试学习并使用 Google 搜索,但问题是:每个教程有关于它,只是告诉你如何做某事。就像MessageBox通过 Win32 API展示一个,但你不能真正学习 Win32 框架。

So how do you actually learn it? How do you know all the functions? with managed libraries it's quite easy, especially with Visual Studio which provides IntelliSense, the Object Browser etc. but the Win32 API is so messy (at least from a C# developer standpoint).

那么你是如何真正学习它的呢?你怎么知道所有的功能?使用托管库很容易,尤其是使用提供 IntelliSense、对象浏览器等的 Visual Studio,但 Win32 API 非常混乱(至少从 C# 开发人员的角度来看)。

The way I've been using it until now is just searching on Google for a task and seeing that it can be done with the Win32 API (I had no idea) and just copy the function and use it (and it's horrible for me, I feel I'm missing a lot of "power").

到目前为止,我一直使用它的方式只是在 Google 上搜索一项任务,然后看到它可以用 Win32 API 完成(我不知道),然后复制函数并使用它(这对我来说太可怕了,我觉得我错过了很多“权力”)。

So, how can I learn it?

那么,我该如何学习呢?

To be clear: I'm not interested in a book. as bad as it sounds I need this knowledge for a project and I just don't have the time to invest in a book. I did get my answer although.
Thank you all.

明确地说:我对一本书不感兴趣。听起来很糟糕,我需要这些知识来进行项目,而我只是没有时间投资一本书。虽然我确实得到了答案。
谢谢你们。

采纳答案by Carlos Quintanilla

From MSDN you can find the WinAPI list: The following is a list of the reference content for the Windows application programming interface (API). http://msdn.microsoft.com/en-us/library/ff818516(v=vs.85).aspx

从 MSDN 可以找到 WinAPI 列表: 以下是 Windows 应用程序编程接口 (API) 的参考内容列表。 http://msdn.microsoft.com/en-us/library/ff818516(v=vs.85).aspx

You can learn some stuff via Visual Basic Win API functions. Examples are very easy to follow and understand. Then you can translate the code to C#.

您可以通过 Visual Basic Win API 函数学习一些东西。示例非常易于遵循和理解。然后您可以将代码转换为 C#。

There Are 598 Visual Basic Windows API Functions in 55 Category http://www.ex-designz.net/api.asp

55 个类别中有 598 个 Visual Basic Windows API 函数 http://www.ex-designz.net/api.asp

回答by Wiktor Zychla

First, Win32 is a set of subsystems. You possibly can't learn them all easily. You just have to prioritize.

首先,Win32 是一组子系统。您可能无法轻松地全部学习。你只需要优先考虑。

But then, to be able to say what you'd like to learn, you probably need a big picture. I believe the best way to approach Win32 is through "Programming Windows" by Charles Petzold. It's very clear to read and easy to understand. There are a lot of examples you can pick up and experiment on your own.

但是,为了能够说出您想学习的内容,您可能需要一个大局。我相信接近 Win32 的最佳方法是通过 Charles Petzold 的“Programming Windows”。它非常清晰易读且易于理解。有很多例子你可以自己挑选和试验。

After you learn the basic stuff, I recommend "Microsoft Windows Internals" by Mark Russinovich. It's rather advanced but lets you understand what's inside Windows core.

在你学习了基本的东西之后,我推荐 Mark Russinovich 的“Microsoft Windows Internals”。它相当先进,但可以让您了解 Windows 核心内部的内容。

回答by Min Min

Win32 API - help documents and samples should be in Windows SDK download. http://www.microsoft.com/download/en/details.aspx?id=8279

Win32 API - 帮助文档和示例应在 Windows SDK 下载中。 http://www.microsoft.com/download/en/details.aspx?id=8279

回答by Chibueze Opata

I personally feel you should start with Calling Win32 DLLs in C# with P/Invoke

我个人觉得你应该从Calling Win32 DLLs in C# with P/Invoke 开始

This will provide you with most of the basic knowledge you need to know about the WINAPI using pinvoke in c#. I also had the offline version of the WINAPI functions provided by MSDN but I can't remember where I downloaded it from.

这将为您提供在 c# 中使用 pinvoke 了解 WINAPI 所需的大部分基本知识。我也有 MSDN 提供的 WINAPI 函数的离线版本,但我不记得从哪里下载的。

Lastly, get your hands on some basic easy to understand WINAPI code, there's http://mwinapi.sourceforge.net/for this.

最后,让您掌握一些简单易懂的 WINAPI 代码,这里有http://mwinapi.sourceforge.net/

EDIT:You can download the offline version of the documentation from phatocde.

编辑:您可以从 phatocde下载文档离线版本

回答by Bill

Take a look at theForger's Win32 API Programming Tutorialas well, which:

也看看theForger 的 Win32 API 编程教程,其中:

attempts to get you started developing with the Win32 API as quickly and clearly as possible`.

试图让您尽可能快速和清晰地开始使用 Win32 API 进行开发。