views:

37

answers:

1

Hi, I am getting linker error while working on SHCreateStreamOnFileEx. Please help me to find out the problem.

IStream* replace::GetStream()
{ 
LPCWSTR pszFile=L"D:\\Test\\output.txt";
IStream* dataStream = NULL;
if (dataStream == NULL)
 {
    SHCreateStreamOnFileEx(pszFile, 
        STGM_READ|STGM_SHARE_DENY_NONE|STGM_DELETEONRELEASE,
        FILE_ATTRIBUTE_NORMAL, 
        FALSE, 
        NULL, 
        &dataStream);
 }
return dataStream;
}

Error: error LNK2019: unresolved external symbol _imp_SHCreateStreamOnFileEx@24 referenced in function "public: void __thiscall replace::GetStream(void)" (?GetStream@replace@@QAEXXZ) replace.obj replace

+1  A: 

Adding the matching LIB file to your project settings should do the trick. Open the project settings -> linker -> input -> additional dependencies and add the Shlwapi.lib to the list.

As an alternative you can also put the following directive into your cpp file:

#pragma comment(lib, "Shlwapi.lib");
Frank Bollack
Thanks second one working fine