1

我正在使用 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

这是声明windows 7的权利吗

谢谢

4

2 回答 2

2

You don't want to define your own macro to detect Windows 7, use the ones provided by Microsoft - wrap your Win7 only code in:

#ifdef _WIN32_WINNT_WIN7 
xyz()
#endif

If you do create your own, you must define it when you want to compile for Windows 7, it seems that you're hiding the SelDllDirectory() function - #ifndef means "if not defined" so if WIN7 macro is not defined anywhere, then you get that function.

于 2012-08-21T09:43:44.873 回答
1

NTDDI_VERSION或者_WIN32_WINNT怎么样?

于 2012-08-21T09:41:47.253 回答