Solved

How to create instance of an object?

Posted on 2001-06-15
4
252 Views
Last Modified: 2013-11-20
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);

 
0
Comment
Question by:jane1
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 1

Accepted Solution

by:
awd earned 50 total points
ID: 6196085
Have you included the header file where the IVTxtAuto interface is defined?  Or imported the type library?
0
 

Author Comment

by:jane1
ID: 6198803
which header file,which type library??????
i'm not using smart pointers to create the instance.
0
 
LVL 1

Expert Comment

by:awd
ID: 6202263
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
 
LVL 23

Expert Comment

by:Roshan Davis
ID: 9484710
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

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
In this post we will learn different types of Android Layout and some basics of an Android App.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question