Defining a preprocessor directive for windows 7

Defining a preprocessor directive for windows 7

本文关键字:windows for directive preprocessor Defining      更新时间:2023-10-16

我正在使用SetDllDirectory(),想知道如何为windows 7 HP 64位定义指令

在预处理器指令中:

 Add WIN7

在.cpp中,我想添加一些类似的内容

#ifndef WIN7<- where the function is used
SetDllDirectory();
#endif

但一旦我添加了这些语句,SetDllDirectory就会被注释。

这是我尝试过的,我在预处理器定义中添加了WIN7,并添加了:

#if defined(__WIN7__)
if (regkeyExists) {
    if (regkey->HasValue("LibPath")) {
        regkey->QueryValue("LibPath", value);
        if (!value.empty()) {
            wxSetEnv("ABCLib", value);
            SetDllDirectory(value.c_str());
        }
    }
}
SetDllDirectory("C:\Program Files\ABC\ABCProject\lib");
#endif

这是申报Windows7 的权利吗

感谢

您不想定义自己的宏来检测Windows7,请使用Microsoft提供的宏-将您的Win7代码封装在:中

#ifdef _WIN32_WINNT_WIN7 
xyz()
#endif

如果你真的创建了自己的,那么当你想为Windows 7编译时,你必须定义它,看起来你隐藏了SelDllDirectory()函数——#ifndef的意思是"如果没有定义",所以如果WIN7宏没有在任何地方定义,那么你就得到了这个函数。

NTDDI_VERSION_WIN32_WINNT怎么样?