gpt4 book ai didi

c++ - 使用 Shobjidl.h 的 Microsoft SDK 中的奇怪错误

转载 作者:可可西里 更新时间:2023-11-01 11:57:31 31 4
gpt4 key购买 nike

我想在cpp中检索当前用户文档文件夹的文件夹,所以我使用SHGetFolderPath并包含Shobjidl.h

因此我的代码无法编译并生成以下输出:

1>C:\Program Files\Microsoft SDKs\Windows\v7.0A\include\shobjidl.h(8994): error C2143: syntax error : missing ')' before 'constant'
1>C:\Program Files\Microsoft SDKs\Windows\v7.0A\include\shobjidl.h(8994): error C2143: syntax error : missing ';' before 'constant'
1>C:\Program Files\Microsoft SDKs\Windows\v7.0A\include\shobjidl.h(8994): error C2059: syntax error : ')'
1>C:\Program Files\Microsoft SDKs\Windows\v7.0A\include\shobjidl.h(8994): error C2238: unexpected token(s) preceding ';'

这些错误背后的代码是:

        virtual HRESULT STDMETHODCALLTYPE GetInt32( 
/* [in] */ __RPC__in REFPROPERTYKEY key,
/* [out] */ __RPC__out int *pi) = 0; // <- this line produces compile error

怎么了?提前致谢。

我使用的是 Win 7,VS2010 Express。

最佳答案

根据 the documentation,您需要为该函数包含的头文件是 Shlobj.h ,而不是 Shobjidl.h。我猜 Shobjidl.h 可能是一个内部头文件,并不打算直接包含——它可能取决于其他已经包含在它之前的头文件,这将修复你的错误重新看到。

关于c++ - 使用 Shobjidl.h 的 Microsoft SDK 中的奇怪错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13869358/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com