写篇踩坑笔记吧

这个是最近一段时间遇到的各种花样别出的坑,这些坑只针对D7,不知道啥是D7的可以直接关闭窗口了。

坑1

D7在Win7及以上版本调试时,只有BuildWithRuntimePackage时才能正确获取Win32MajorVersion,Win32MinorVersion,Win32BuildVersion等值。
不带包编译后,运行时不存在该问题。如果存在,可能需要使用管理员运行,即在程序上右键RunWithAdministrator,该问题的具体原因未知。

坑2

D7程序启用UAC后,在Win10上无法接收WM_DROPFILE消息,即无法接收从资源管理器拖动到窗口上的文件消息。具体情况请参考:

https://www.vistax64.com/threads/changewindowmessagefilter-what-does-this-really-do.25586/

关键段是这段话:

Vista prohibits applications of different integrity levels from sending most
windows messages between each other. IE in protected mode runs in LOW
integrity; normal applications run in MEDIUM; and programs running with
administrator privileges run as HIGH. (There is also a SYSTEM level for some
system services).

ChangeWindowMessageFilter allows an application in a higher integrity level
to specify additional windows messages that it wants to accept from
applications running in a lower privilege level.

For example, if you run say NOTEPAD.exe, it will have a MEDIUM integirty
level. If you then run an administrative application, let's use task
scheduler as an example, it will run with HIGH integrity level.

notepad is isolated from task scheduler because they are running in
different integrity levels; the system prevents notepad from sending task
scheduler most window messages, prevents it from injecting code into task
scheduler via hooks, prevents it from writing into its process memory, etc,
etc, because of the difference in integrity level.

The ChangeWindowMessageFilter api can be used in this example by task
scheduler to allow it to receive additional window messages from notepad.

简单说,就是程序运行权限不同造成的,当然,也有解决方案,就是使用ChangeWindowMessageFilter函数来提权。

注意,该函数没有ChangeWindowMessageFilterW和ChangeWindowMessageFilterA的区分,你懂的!

所以,最终的答案是:如果你还在用D7,那么当你遇到这个问题时,你的解决方案有两个:一是不用UAC,二是将Explorer.exe提权。表面上看有两个解决方案,实际上只有一个。你懂的。不懂拉到。

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值