我想创建一个 DeskBand.我必须使用 C++ 吗?

问题描述:

我想创建一个 DeskBand 来在我的 Windows 任务栏上显示一些信息,但我正在努力实现我需要的 C++ 功能.我接触 C++ 大约有 10-15 年了.在过去的 7 年里,我一直在完全使用 .NET 工作.

I want to create a DeskBand to display some information on my Windows task bar, but I am struggling with implementing the functionality I need in C++. It's been about 10-15 years since I touched C++. I've been working entirely in .NET for the past 7 years.

在你说出来之前 - 我知道 DeskBands 已被弃用.但是建议的替换 UI 元素 - 缩略图工具栏 - 不能满足我的需求.我需要一个 UI 元素,无论用户切换到哪个应用程序,它都始终可见,并且提供足够的空间来显示一行文本 - 我可以留出 30 个字符左右的空间.

Before you say it - I know that DeskBands are deprecated. But the suggested replacement UI element - thumbnail toolbars - don't meet my needs. I need a UI element that is constantly visible to the user no matter which application they switch to, and also that provides enough room to display a line of text - I could get by with room for 30 characters or so.

我已经能够从 Windows SDK 示例中获取 DeskBand 以进行编译和运行,但现在我需要实现一些真正的功能 - 特别是...

I've been able to get the DeskBand from the Windows SDK sample to compile and run, but now I need to implement some real functionality - specifically...

  • 定位 AppData\Local 文件夹 (SHGetKnownFolderPath(FOLDERID_LocalAppData...)
  • 查看 XML 文件以进行修改.每当文件更改时,我都需要解析和重新绘制.
  • 解析 XML 文件(我找到了 pugixml)
  • 在我的 DeskBand 中显示 XML 文件中的一些数据
  • 设置计时器以每分钟重绘一次 DeskBand

... 我意识到我对 C++ 知之甚少,以及我对 .NET 的基类库的依赖程度.如果我用 C# 编写这个任务对我来说会非常容易.但我在别处了解到 你不应该写 shell.NET 中的扩展.

... and I am realizing how little I know about C++, and how much I've come to depend on .NET's Base Class Library. This task would be super easy for me if I was writing it in C#. But I've learned elsewhere that you shouldn't write shell extensions in .NET.

我有哪些选择?有没有一种更简单的语言来实现这一点——也许是 Python?还是我必须硬着头皮在 C++ 中做到这一点?如果是这样,对于尝试用 C++ 实现 WinAPI shell 扩展的 .NET 开发人员有什么建议吗?

What are my options? Is there an easier language to accomplish this in - maybe Python? Or do I have to just bite the bullet and do this in C++? If so, any advice for a .NET developer trying to implement a WinAPI shell extension in C++?

提前致谢.

Shell Extensions 是 COM 对象,C++ 通常是开发 COM 对象时使用的最佳语言,因为 COM 主要是为 C++ 设计的,但它不是唯一的语言可能.COM 具有标准化架构,因此您可以使用 .NET 之外的任何支持 COM 对象开发的语言(Delphi、VB 等)来开发 Shell 扩展(类似于 Win32 API 主要为 C 设计的方式,但任何与 C 兼容的语言可以访问它).

Shell Extensions are COM objects, and C++ is generally the best language to use when developing COM objects because COM was designed primarily for C++, but it is not the only language possible. COM has a standardized architecture, so you can use any language outside of .NET that supports COM object development (Delp VB, etc) to develop Shell Extensions (similar to how the Win32 API is primarily designed for C, but any C-compatible language can access it).