Solved

How to create instance of an object?

Posted on 2001-06-15
4
238 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
  • 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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

757 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now