Unsupported operating system,major=6,version=2.2,sp=0.0,type=3
是否可以使用shim将type = 3更改为type = 1作为安装程序?如果是这样,关键步骤是什么?
根据.exe文件的属性,安装程序是用dotNetInstaller创建的.我可以想象它通过调用API函数GetProductInfo
来检索版本号(更新:不,它是GetVersionEx
).我已经尝试在各种兼容模式下运行安装程序.不幸的是,这不会影响报告的版本号.另请参阅超级用户my question.
应用程序填充程序实现API重定向,以便当应用程序进行某个API调用时,它会被截获或“被劫持”,并且其他一些数据将从填充程序返回给应用程序.
http://technet.microsoft.com/en-us/library/dd837644(v=WS.10).aspx
The Shim Infrastructure implements a form of application programming
interface (API) hooking. Specifically,it leverages the nature of
linking to redirect API calls from Windows itself to alternative
code—the shim itself.
大多数情况下,您可以使用应用程序兼容性工具包来编写自己的填充程序:
并且做一个“版本谎言”,其中shim对于应用程序关于它运行的版本是appcompat shims的最常见用例.
因为开发人员坚持在他们的代码中进行版本检查,这是错误的.微软告诉你这是错的.不要在代码中进行版本检查. (相反,请检查您打算使用的特定功能的存在与否.)
但开发人员仍然每天都进行版本检查.更糟糕的是,他们进行“==”版本检查,除非您运行的是确切版本的Windows,这是任意且愚蠢的,否则应用程序根本无法运行.
叹息……开发者.
微软的克里斯杰克逊多年来一直从事应用程序兼容性工作,他的态度相似:
One of the classes of shims that people find the easiest to understand
are the version lie shims. In essence,we have shims that can
compensate for the fact that so many developers’ keyboards were
shipped with a defective > key (and the failure rate of this key on
developer keyboards is astonishing). They work by just returning a
different value from the GetVersion(Ex) APIs,depending on which
operating system you selected.
但不幸的是in that same article,他向我们提供了我认为的重要信息:
OK,so now that you have CompatAdmin started,under the System
Database,expand the Compatibility Fixes list. With the /x switch,
you’ll notice that the WinXPSP2VersionLie now has a plus sign – if you
expand this,you’ll see a list of modules that have a red diamond next
to them. These are modules that this shim specifically excludes. Among
these? The .NET Framework modules.You see,the .NET Framework doesn’t take too kindly to being lied to.
They do version checks to determine how to implement certain things,
and thinking they’re running down-level isn’t so great. So,we
intentionally exclude these modules,and,consequently,we
intentionally exclude the code that you’re writing that these modules
are JITting and executing. Not that we wanted to do so,but the
infrastructure didn’t give us a great way to separate these out. We
either lied to everything,or we lied to nothing. It was worse to lie
to everything,so we didn’t.
呵呵,当我刚才说出一个想法有多糟糕的时候,那个.NET正在进行版本检查有点儿好笑……
For real-life applications that need a version lie,well,if the
application is managed,you’ll have to change the code. This is
something you can’t,and shouldn’t,shim up.So,if you notice the version lie isn’t working,and the application
is managed,then my spidey sense tells me you’re trying to shim it up
with an XP version lie – and that’s not going to work.
从MSDN开始:
Generally,apps should not perform operating system version checks. If an app needs a specific feature,it is preferable to try to find the feature,and fail only if the needed feature is missing.