开发者

Trying to use SHCreateShellItem, having #include issues

开发者 https://www.devze.com 2022-12-24 19:13 出处:网络
There is a function in called SHCreateShellItem which is declared in <shlobj.h>, but it has been #ifdef\'d out based on whether or not _WIN32_IE is greater than or equal to 0x601 (if it is, then

There is a function in called SHCreateShellItem which is declared in <shlobj.h>, but it has been #ifdef'd out based on whether or not _WIN32_IE is greater than or equal to 0x601 (if it is, then the declaration is present). However, even when I define _WIN32_IE to 0x601 before I include <shlobj.h>, MSVC++ still complains that SHCreateShellItem is undeclared.

For example, I cannot get the following to compile:

#define _WIN32_IE 0x601
#include <shlobj.h>

int someFunction (LPITEMIDLIST parent, LPITEMIDLIST child)
{
    HRESULT result;
    IShellItem *shellObj;

    result = SHCreateShellItem (parent, NULL, child, &shellObj);
    if (SUCCEEDED(result))
    {
        // do stuff
    }

    return SUCCEEDED(开发者_如何学运维result);
}

Do I need to define _WIN32_IE in a different way?


_WIN32_IE is usually defined in your stdafx.h file. You must change it there.


Don't define _WIN32_IE directly, do it implicitly with _WIN32_WINNT (which sets the target platform for the SDK includes)

#define _WIN32_WINNT 0x0600 
#include <windows.h>
#include <shlobj.h>
0

精彩评论

暂无评论...
验证码 换一张
取 消