Click here to Skip to main content
13,050,358 members (139,346 online)
Rate this:
Please Sign up or sign in to vote.
See more:
First, I created a storage file using StgCreateDocfile() then added some files in it. Then i tried to open this storage file using

hr = StgOpenStorageEx(L"E:\\Storage.stg",STGM_READ|STGM_SHARE_DENY_WRITE,STGFMT_DOCFILE,0, NULL, 0,IID_IStorage,(void**)&pStorage);

which worked fine when i did it win32 console application.

But when i tried it add the same code in Windows form application project, adding a c++ class to project and then my code to that class, it generate a runtime error
1>Recovery.obj : error LNK2020: unresolved token (0A000017) IID_IStorage
1>Recovery.obj : error LNK2001: unresolved external symbol IID_IStorage

whats the problem with IID_IStorage in newly created class.

Do i need to do something with Linker properties in project setting?
Posted 23-Apr-11 3:40am
Updated 23-Apr-11 4:09am
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

It seems you are missing a lib file. Try adding Uuid.lib to your linker libraries.
MartinTaylor 23-Apr-11 10:28am
As you mentioned , i have added Uuid.lib in Properties->linker->Input->additional dependencies..
But i didnt worked....
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

I think you may need to include Objidl.h in your source code as described here[^] in MSDN.
MartinTaylor 24-Apr-11 3:44am
Objidl.h is already added... i wont be getting this error if i would have missed to include Objidl.h...
My problem is :- my code worked fine in windows console application project, but in windows form application as project type, i created a c++ class and added same code in it..but seems to have some problem for IID_IStorage parameter in "StgOpenStorageEx()" function which is leading to LNK 2020 and 2001 error..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web01 | 2.8.170713.1 | Last Updated 23 Apr 2011
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100