gpt4 book ai didi

c++ - 应用程序重新启动,提升 "runas",在 ITaskbarList 使用之前不捕获 TaskbarButtonCreated Msg?

转载 作者:塔克拉玛干 更新时间:2023-11-03 07:48:09 34 4
gpt4 key购买 nike

使用 Borland C++ Builder。

在使用 ITaskbarList3 之前,我会按照 Windows 的要求进行操作:

https://msdn.microsoft.com/en-us/library/windows/desktop/dd391692.aspx

Your application should call RegisterWindowMessage(L"TaskbarButtonCreated") and handle that message in its wndproc. That message must be received by your application before it calls any ITaskbarList3 method.

然而这似乎并不总是对我有用,我等待的消息永远不会出现,即使 RegisterWindowMessage() 成功了。

经过一些挖掘后,我发现问题与我的应用程序何时使用“runas”重新启动有关,启动后立即,根据用户设置,应用程序需要运行提升。

第二次(现在已提升)运行,我等待的消息从未出现。

假设这是因为 Windows 已经发送了这条消息并且它不会再发送一次,即使创建了一个新实例也是如此??

假设消息必须已经在第二次(提升的)运行中发送,并继续使用 ITaskbarList3 是否安全?

最佳答案

您的应用程序代码必须调用 ChangeWindowMessageFilterEx创建顶部窗口并注册“TaskbarButtonCreated”消息后的功能。这将允许第二个(提升的)实例接收“TaskbarButtonCreated”消息。

UINT nTaskbarButtonCreatedMessage = RegisterWindowMessage(TEXT("TaskbarButtonCreated"));
HWND hWnd = {create the top main window and get handle to it}.
ChangeWindowMessageFilterEx(hWnd, nTaskbarButtonCreated, MSGFLT_ALLOW, nullptr);

(这是 VC++ 的代码,但我相信它也适用于 Borland C++ Builder)

关于c++ - 应用程序重新启动,提升 "runas",在 ITaskbarList 使用之前不捕获 TaskbarButtonCreated Msg?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34303104/

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com