简体   繁体   English

检查winapi功能是否可用

[英]Check if winapi function is available

Is is possible in c++ to check if a function is available? 是否可以在C ++中检查某个功能是否可用? For example SetThreadPriority . 例如SetThreadPriority If it is available, I want to call it, if not I want to simply ignore it, as it is not critical for my application. 如果可用,我想调用它,否则,我想简单地忽略它,因为它对我的应用程序并不重要。

You can use the GetProcAddress function. 您可以使用GetProcAddress函数。 The example in the link does exactly this kind of thing: it checks if the GetNativeSystemInfo is available and calls it if yes, otherwise it calls the GetSystemInfo function. 链接中的示例确实做了这种事情:它检查GetNativeSystemInfo是否可用,如果可用,则调用它,否则调用GetSystemInfo函数。

May be you are looking for Dynamic Linking Function . 可能是您在寻找动态链接功能 If so, then use LoadLibraryEx then GetProcAddress 如果是这样,则使用LoadLibraryEx然后使用GetProcAddress

This will allow you skip the DLL load if it is not available 如果不可用,这将允许您跳过DLL加载

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM