Click here to Skip to main content
14,975,411 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hello,
In my "Windows Form Application" project, i have created Button. On Button click , I want to open compound file present on my hard disk using function StgOpenStorageEx(). the code i have written code for this in button click event as

C#
private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
            IStorage    *pStorage;               if(StgOpenStorageEx(L"E:\\Backup.stg",STGM_READ|STGM_SHARE_DENY_WRITE,STGFMT_DOCFILE,0, NULL, 0,IID_IStorage,(void**)&pStorage)==S_OK)
            {
                tb4->Text="hehe";
            }
         }


for this i have added header files like

XML
#include "StdAfx.h"
#include<Objbase.h>

Also I have added "Ole32.lib" in proj->properties->Linker->input->additional dependencies.
But still im getting following errors
VB
1>BackGUI.obj : error LNK2020: unresolved token (0A000010) IID_IStorage
1>BackGUI.obj : error LNK2001: unresolved external symbol IID_IStorage
1>C:\Users\SUMIT\Desktop\prj\BACKUP & RESTORE\BackGUI\Debug\BackGUI.exe : fatal error LNK1120: 2 unresolved externals


any suggestions plz??
Posted
Updated 25-Apr-11 11:37am
v4
Comments
Albert Holguin 25-Apr-11 20:29pm
   
this looks familiar:
http://social.msdn.microsoft.com/Forums/en-US/vcgeneral/thread/86a81973-6171-4fac-b671-a162843700a5
Albert Holguin 25-Apr-11 20:31pm
   
...and here:
http://www.codeproject.com/Questions/185946/error-LNK2020-unresolved-token-0A000017-IID_IStora.aspx?display=PrintAll

1 solution

if you look here:
http://msdn.microsoft.com/en-us/library/aa380015%28VS.85%29.aspx[^]

...it says "IID_IStorage is defined as 0000000B-0000-0000-C000-000000000046", so why don't you try to define it yourself, its probably defined somewhere that you forgot to include or you have to define it yourself to use it.

So try this (although looking at some of the other references, you probably need to use the DEFINE_GUID() macro since its a large number rather than text)...
C++
#ifndef IID_IStorage
#define IID_IStorage "0000000B-0000-0000-C000-000000000046"
#endif


Here you can see where someone defined that in their code (using DEFINE_GUID() macro):
http://express-os.googlecode.com/svn-history/r51/express-os/bin/sh.cpp[^]

...and yet another reference:
http://force7.de/nimrod/ole2.html#119[^]
   
v4
Comments
Sandeep Mewara 26-Apr-11 0:31am
   
My 5!
MartinTaylor 26-Apr-11 4:41am
   
Thank u Albert Sir...

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




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900