根据操作系统版本加载已编译的源 [英] Load the compiled source based on Operating System version

查看:55
本文介绍了根据操作系统版本加载已编译的源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在VC ++应用程序中使用WinHttp函数进行互联网下载。

I am using WinHttp functions for internet download in a VC++ application.

当我因某些原因需要停止冗长时间下载时,会使用WinHttpWebSocketClose函数。

When I need to stop lengthy, time taking download for some reason, WinHttpWebSocketClose function is used.

但是Win8和后来的操作系统仅支持该功能。

But that function is supported from Win8 and later OS only.

因此我的应用程序将抛出一个错误"Winhttp.dll中找不到WinHttpWebSocketClose" ;在Win7&启动应用程序时的旧操作系统。

So my application will throw an error "WinHttpWebSocketClose is not found in Winhttp.dll" in Win7 & older OS while launching the application.

我想知道,我们是否可以根据操作系统版本加载一些代码或功能,否则跳过在同一个应用程序中(而不是像dll这样的单独模块)?

I would like to know, can we have some code or function which can be loaded based on OS version, otherwise skip that, within the same application(not as a separate module such as dll)?

谢谢&问候

推荐答案

您也不需要对此进行任何版本检查。

You also don't need to do any version check for this either.

只有传入的模块句柄有效并且DLL中存在该函数时,GetProcAddress函数才会成功。因此,在Windows 8之前指向此函数的指针将为NULL,并且从Windows 8开始指向该函数的有效指针。

The GetProcAddress function will only succeed if the module handle passed in is valid and the function exists in the DLL. So the pointer to this function will be NULL prior to Windows 8 and a valid pointer to the function from Windows 8 onwards.


这篇关于根据操作系统版本加载已编译的源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆