Solved

How to create instance of an object?

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to create frequencies of a variable from SAS dataset? 10 121
modThree challenge 4 79
fix34  challenge 9 105
wordcount challenge 11 107
In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
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.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

920 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

15 Experts available now in Live!

Get 1:1 Help Now