简体   繁体   English

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

[英]Devc++ - 'IFileOperation' undeclared (C++)

I would like to add objects IFileOperation and IShellItem , but I can not fill in any way the source and gives me back: 我想添加对象IFileOperationIShellItem ,但是我无法以任何方式填写源代码并给我回来:

IFileOperation - undeclared (first use in this function)

I'm using Dev-C++ with the parameters of the linker: -luuid -lole32 我正在使用带有链接器参数的Dev-C ++:- -luuid -lole32

I suppose I must add other header but every google search is not successful. 我想我必须添加其他标头,但每个Google搜索都不成功。 Do you have any idea? 你有什么主意吗?

#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();
}

I suspect you need to link your program to Shell32.lib 我怀疑您需要将程序链接到Shell32.lib
try going to you program settings, then find the linker and add -lShell32.lib to it and save. 尝试进入程序设置,然后找到链接器,并将-lShell32.lib添加到该链接器并保存。

anyway, Dev-C++ is a nice compilerwhen you start programing and you want to write some code , compile it and run it. 无论如何,当您开始编程并想要编写一些代码,对其进行编译并运行时,Dev-C ++是一个不错的编译器。 but this IDE is very ancient and unefficient , consider to move to Visual studio if you're using windows. 但是此IDE非常古老且效率低下,如果使用Windows,请考虑迁移到Visual Studio。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM