Click here to Skip to main content
11,806,590 members (66,763 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: C++ Visual-Studio
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
Edited 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 at 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 at 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
0 ppolymorphe 205
1 OriginalGriff 175
2 Richard Deeming 175
3 Sergey Alexandrovich Kryukov 170
4 Abhinav S 120
0 OriginalGriff 3,380
1 Maciej Los 1,990
2 CPallini 1,915
3 KrunalRohit 1,907
4 ppolymorphe 1,317

Advertise | Privacy | Mobile
Web02 | 2.8.151002.1 | Last Updated 23 Apr 2011
Copyright © CodeProject, 1999-2015
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