Solved

How to create instance of an object?

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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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 tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …

777 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