• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            隨筆 - 74, 文章 - 0, 評(píng)論 - 26, 引用 - 0
            數(shù)據(jù)加載中……

            (msdn)Using MFC to Automate SAPI (SAPI 5.3)http://msdn2.microsoft.com/en-us/library/ms717069.aspx

            Microsoft Speech API 5.3   用oleview 可以產(chǎn)生 idl 文件 再用 midl工具 可以產(chǎn)生 tlb,h,c 存根文件 等.

            Using MFC to Automate SAPI

            Introduction

            The Microsoft Foundation Classes (MFC) provides an easy and convenient way to automate calls to SAPI using its Class Wizard to generate wrappers for the SAPI layer from the SAPI Type Library.

            In order to accomplish this, perform the following steps:

            1. Create a new MFCAppWizard(exe) project in Visual C++.
            2. Based on the type of application you are creating, follow the wizard prompts. In Step 3 of the wizard prompts, (or Step 2 if you are creating a Dialog Based application) make sure that the Automation check box is selected under the heading, What other support would you like to include?

            Once the new project is ready, access Class Wizard.

            1. Click the Automation tab, and then click Add Class and select From a type library in the drop-down list.
            2. Browse for the sapi.dll file and open it.
            3. Select the classes you would like Class Wizard to generate a wrapper for. The resulting default header and implementation files are sapi.h and sapi.cpp respectively. The rest of this document assumes that you have chosen to use these default file names. Click OK.
            4. You should now be back in the Class Wizard window. Click OK.
            After you are done with the above steps, Visual C++ will automatically add the Class Wizard generated files sapi.cpp and sapi.h to your project.

            Upon viewing the sapi.h file, you should notice that it is nothing more than an automation wrapper that has been generated for all the classes you selected. Notice that all the classes inherit from COleDispatchDriver, hence the dispatch interface needs to be set up. This only requires a few lines of simple code, after which the wrapper class can be used just like any other C++ class.

            Example

            This example assumes that you chose to generate a wrapper for the ISpeechVoice class from among any other classes you may have selected. Using the project created above, include the sapi.h file within a source file in the project that will make automation calls to SAPI using the wrapper. In that source file, type the following code.

            CLSID CLSID_SpVoice;    // class ID for the SAPI SpVoice object
            LPDISPATCH pDisp; // dispatch interface for the class
            ISpeechVoice voice; // use the MFC Class Wizard generated wrapper

            CLSIDFromProgID(L"SAPI.SpVoice", &CLSID;_SpVoice);
            voice.CreateDispatch(CLSID_SpVoice);
            pDisp = voice.m_lpDispatch;

            HRESULT hr = pDisp->QueryInterface(CLSID_SpVoice, (void**)&voice;.m_lpDispatch);

            if (hr == S_OK) {
            pDisp->Release();
            }
            else {
            voice.AttachDispatch(pDisp, TRUE);
            }

            voice.Speak("hello world", 1); // asynchronous call to Speak method of ISpeechVoice interface

            If you have been following the steps outlined above properly, you should hear your computer say "hello world!" That's all there is to using MFC to make automation calls to SAPI. Currently however, not all the wrapper classes generated by MFC's Class Wizard work properly. For instance, the ISpeechLexicon interface does not work. The work around for this is to implement your own automation wrapper classes using C++. The steps to do that are beyond the scope of this document. Of course, you can always use the COM interfaces in C++ and Automation in Visual Basic to ensure that every interface in SAPI works easily and flawlessly.

            posted on 2007-11-20 09:06 井泉 閱讀(1203) 評(píng)論(1)  編輯 收藏 引用 所屬分類: C++

            評(píng)論

            # re: (msdn)Using MFC to Automate SAPI (SAPI 5.3)http://msdn2.microsoft.com/en-us/library/ms717069.aspx[未登錄](méi)  回復(fù)  更多評(píng)論   

            你好,我在試驗(yàn)這個(gè)例子的時(shí)候遇見(jiàn)了問(wèn)題。我不知道Example的那段代碼應(yīng)該加到哪里。我試驗(yàn)了一下,出現(xiàn)了錯(cuò)誤。所以,希望你能詳細(xì)的指點(diǎn)我一下,可以么?謝謝啦!我的郵箱是:nvllnvll@126.com
            2010-03-19 22:07 | Harry
            欧美久久一级内射wwwwww.| 亚洲精品国产美女久久久 | 色综合久久天天综线观看| 久久婷婷五月综合97色直播| 久久久久国产日韩精品网站| 午夜精品久久久久久久| 91精品国产高清久久久久久国产嫩草| 思思久久99热免费精品6| 久久99精品久久久久久hb无码 | 国产激情久久久久影院老熟女免费 | 精品综合久久久久久888蜜芽| 一本综合久久国产二区| 99精品久久精品| 国内精品人妻无码久久久影院导航| 热99re久久国超精品首页| 久久天天躁狠狠躁夜夜avapp| 无夜精品久久久久久| 91精品国产91久久| 99久久精品国产免看国产一区| 精品久久久无码21p发布| 亚洲国产成人精品无码久久久久久综合| 精品久久久久久中文字幕人妻最新| 亚洲欧美国产日韩综合久久| 久久精品国产只有精品66| 中文字幕一区二区三区久久网站 | 久久人妻少妇嫩草AV蜜桃| 久久国产成人亚洲精品影院| 99久久精品无码一区二区毛片| 精品精品国产自在久久高清 | 国产精品久久久久乳精品爆 | 99久久久久| 久久99精品国产麻豆不卡| 久久国产精品无码网站| 久久精品视频网| 久久精品国产欧美日韩| 久久久久亚洲av毛片大| 久久中文字幕精品| 亚洲午夜久久久久久久久电影网| 亚洲国产一成人久久精品| 久久青青草原精品国产| 91亚洲国产成人久久精品网址|