How to create instance of an object?

Dear experts

i want to add text to speech facility in my application.for this i have used
voice text object.i've initialized COM libraries,got the CLSID of the object(VoiceText).but the
 problem is this
when i use the interface "IVTxtAuto" of this object it gives  error
"IVTxtAuto undeclared identifier".when i use any other interface of
the same object it doesn't give me any error and i can use  any available
method of that interface.here is my code.



CLSID clsID;
HRESULT hr;

hr= CLSIDFromProgID(OLESTR("Speech.VoiceText"), &clsID);


if(FAILED(hr))
{
   AfxMessageBox("Retrieval of ProgID failed");
   return FALSE;
}

IVTxtAuto *pFoo=NULL;
 hr = CoCreateInstance(clsID, NULL, CLSCTX_ALL,
               IID_IVTxtAuto, (void **)&pFoo);

 
jane1Asked:
Who is Participating?
 
awdConnect With a Mentor Commented:
Have you included the header file where the IVTxtAuto interface is defined?  Or imported the type library?
0
 
jane1Author Commented:
which header file,which type library??????
i'm not using smart pointers to create the instance.
0
 
awdCommented:
Does that mean you do NOT want to use smart pointers?  Are you using MFC?  The problem appears to be that you do not have the IID_IVTextAuto defined anywhere IN YOUR CODE.  There is more than one way to accomplish this.  The easiest is using the type library.  I think MFC wizards will even produce wrapper classes for you using this route.  Another way would be to include a source file (.h probably) that includes the definition of IID_IVTextAuto.  If all ealse fails, you can always define IID_IVTextAuto yourself using the GUID for that interface.  I have not used it, but it looks like IIDFromString might also work.  Have you tried that one?  Does this help?
0
 
Roshan DavisCommented:
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

Answered by : awd

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

Roshan Davis
EE Cleanup Volunteer
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.