gpt4 book ai didi

c++ - Devc++ - 'IFileOperation' 未声明 (C++)

转载 作者:太空宇宙 更新时间:2023-11-04 13:34:37 25 4
gpt4 key购买 nike

我想添加对象 IFileOperationIShellItem,但我无法以任何方式填写源并返回:

IFileOperation - undeclared (first use in this function)

我正在使用带有链接器参数的 Dev-C++:-luuid -lole32

我想我必须添加其他 header ,但每次谷歌搜索都不成功。你有什么主意吗?

#include <windows.h>
#include <shlobj.h>

int WINAPI WinMain(HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPSTR lpszArgument, int nFunsterStil)
{
HRESULT hr;
IShellLink* pISL;

hr = CoCreateInstance(CLSID_ShellLink, // CLSID of coclass
NULL, // not used - aggregation
CLSCTX_INPROC_SERVER, // type of server
IID_IShellLink, // IID of interface
(void**) &pISL); // Pointer to our interface pointer

if(SUCCEEDED(hr))
{
pISL->Release();
}
else
{
// Couldn't create the COM object. hr holds the error code.
}

CoUninitialize();
}

最佳答案

我怀疑您需要将您的程序链接到 Shell32.lib
尝试转到您的程序设置,然后找到链接器并向其中添加 -lShell32.lib 并保存。

无论如何,当您开始编程并且想要编写一些代码、编译并运行它时,Dev-C++ 是一个不错的编译器。但是这个 IDE 非常古老且效率低下,如果您使用的是 windows,请考虑迁移到 Visual studio。

关于c++ - Devc++ - 'IFileOperation' 未声明 (C++),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30054146/

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