News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Am I right defining the GUID?

Started by Farabi, June 07, 2009, 03:39:59 AM

Previous topic - Next topic

Farabi



STISpRecognizer STRUCT
QueryInterface                dword ?
AddRef                        dword ?
Release                      dword ?
SetPropertyNum                dword ?
GetPropertyNum                dword ?
SetPropertyString            dword ?
GetPropertyString            dword ?
SetRecognizer                dword ?
GetRecognizer                dword ?
SetInput                      dword ?
GetInputObjectToken          dword ?
GetInputStream                dword ?
CreateRecoContext            dword ?
GetRecoProfile                dword ?
SetRecoProfile                dword ?
IsSharedInstance              dword ?
GetRecoState                  dword ?
SetRecoState                  dword ?
GetStatus                    dword ?
GetFormat                    dword ?
IsUISupported                dword ?
DisplayUI                    dword ?
EmulateRecognition            dword ?
STISpRecognizer ENDS

.data
GUID_SpSharedRecognizer GUID {03BEE4890h,04FE9h,04A37h,<08Ch,1Eh,05Eh,07Eh,012h,79h,1Ch,1Fh>}
spi STISpRecognizer <?>


.code

InitSAPI proc uses esi edi

invoke CoCreateInstance,addr GUID_SpSharedRecognizer,0,CLSCTX_ALL,0,addr spi


ret
InitSAPI endp


I got the GUID From SAPI 5.1 SDK.

EXTERN_C const CLSID CLSID_SpSharedRecognizer;

#ifdef __cplusplus

class DECLSPEC_UUID("3BEE4890-4FE9-4A37-8C1E-5E7E12791C1F")
SpSharedRecognizer;
#endif


But the CoCreateInstance always Failed.
Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"

ToutEnMasm

Hello,
How to proceed seem to be your question.
Search in the registry
Quote
HKEY_CLASSES_ROOT\CLSID\{3BEE4890-4FE9-4A37-8C1E-5E7E12791C1F}
HKEY_CLASSES_ROOT\CLSID\{3BEE4890-4FE9-4A37-8C1E-5E7E12791C1F}\ProgID
                                           Sapi.SpSharedRecognizer.1
This say to you that you have to make a test with the CLSIDFromProgID function
Quote
ThreadingModel Both
This mean you have to take care with the initialisation method
Prefered is
Quote
invoke CoInitializeEx ,NULL, COINIT_MULTITHREADED


Farabi

Quote from: ToutEnMasm on June 07, 2009, 05:19:59 AM
Hello,
How to proceed seem to be your question.
Search in the registry
Quote
HKEY_CLASSES_ROOT\CLSID\{3BEE4890-4FE9-4A37-8C1E-5E7E12791C1F}
HKEY_CLASSES_ROOT\CLSID\{3BEE4890-4FE9-4A37-8C1E-5E7E12791C1F}\ProgID
                                           Sapi.SpSharedRecognizer.1
This say to you that you have to make a test with the CLSIDFromProgID function
Quote
ThreadingModel Both
This mean you have to take care with the initialisation method
Prefered is
Quote
invoke CoInitializeEx ,NULL, COINIT_MULTITHREADED



Thats complicated. Any link for information for this?
Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"

ToutEnMasm


Not so complicated

;use the init function


Quote
; use of function
invoke GetInterfaceFromProgId,SADR("DExplore.AppObj.9.0"),addr IID_Help2



GetInterfaceFromProgId PROC pProgId:DWORD,pIID:DWORD
        LOCAL wszProgID[1024]:word
        LOCAL ppv:Dword,retour,pchaine         
        LOCAL clsid     :GUID
        mov retour,0

        invoke MultiByteToWideChar,CP_ACP,MB_PRECOMPOSED,pProgId,-1,addr wszProgID,sizeof wszProgID
        invoke CLSIDFromProgID,addr wszProgID,addr clsid
        .if eax == S_OK
                invoke CoCreateInstance,addr clsid, NULL,CLSCTX_INPROC_SERVER OR CLSCTX_INPROC_HANDLER OR CLSCTX_LOCAL_SERVER,pIID,addr ppv

                .if eax == S_OK                         
                        PuPo retour,ppv
                .endif
        .endif
        mov eax,retour
        RET
GetInterfaceFromProgId endp


If it's failed  http://www.masm32.com/board/index.php?topic=10901.msg80021#msg80021

You can also look at the typelib (follow the register key)

UtillMasm

old stuf.

[attachment deleted by admin]

ToutEnMasm

I have forgotten the most important:

VERIFY that the interface you want is in your computer.
For this use OLEVIEW or my tool "cherche".
For me,I have not this one in my computer (XP sp3).

The ernie old stuff couldn't help here.

Use the header's of the ready to use SDK RC 7,there is here a full translate of the interfaces of the sapi51 .I have tested it.
Your defined one is very bad,no prototypes and couldn't be debugged easily.


Farabi

I got this code from googling, I think it is simple,


CoInitialize(NULL);

ISpRecognizer* m_iEngine = NULL;

HRESULT hr = CoCreateInstance(CLSID_SpSharedRecognizer, NULL, CLSCTX_ALL, IID_SpSharedRecognizer, reinterpret_cast<ISpRecogniser*>(&m_iEngine));


The problem is what is the value of IID_SpSharedRecognizer, and how to get it. Your Init function only give me the CLSID but not with the IID.

[edit]
ToutEnMasm:
Okay I got it.
Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"

ToutEnMasm


The IID_ ... is the register key of an interface.
The one you have is a CLSID who can only give you the Iunknown interface using the IID_iunknow in the GetInterfaceFromProgId function.

Farabi

Quote from: ToutEnMasm on June 07, 2009, 07:31:50 AM

The IID_ ... is the register key of an interface.
The one you have is a CLSID who can only give you the Iunknown interface using the IID_iunknow in the GetInterfaceFromProgId function.


IID is GUID? Sorry a bit late of thinking in here.
Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"

ToutEnMasm


More explain seem needed.
Following what I was saying in my upper post,i have searched in the typelib
Quote
    coclass SpSharedRecognizer {
        [default] interface ISpeechRecognizer;
        interface ISpRecognizer;

Here you have the two interface supported by SpSharedRecognizer
Verify that those interfaces are present in your registry
use the IID (given by the registry)  with the function given upper.This one is the good method to connect.

ToutEnMasm

complete soluce using the RC 7 sdk translate.
Quote
   include translate.inc
   include windows.sdk
   ;include richedit.sdk
   ;include adoctint.sdk
   include sapi51.sdk
   include macro.inc
   ;include dbdao.sdk
   ;------- librairie courantes ,identiques masm32rt
   ;ExitProcess PROTO :DWORD   
   GetInterfaceFromProgId PROTO :DWORD,:DWORD
   
      includelib \masm32\lib\gdi32.lib
      includelib \masm32\lib\user32.lib
      includelib \masm32\lib\kernel32.lib
      includelib \masm32\lib\Comctl32.lib
      includelib \masm32\lib\comdlg32.lib
      includelib \masm32\lib\shell32.lib
      includelib \masm32\lib\oleaut32.lib
      includelib \masm32\lib\ole32.lib
      ;includelib \masm32\lib\msvcrt.lib   incompatible avec certaines librairies windows,directx
   ;editmasm.ini pour l'environnement du projet
;RIEN MACRO
;   :DWORD,
;ENDM
   

   .const


   .data
ppvISpRecognizer dd 0   
ppvISpeechRecognizer dd 0
CLSID_SpSharedRecognizer GUID {03BEE4890h,04FE9h,04A37h,<08Ch,1Eh,05Eh,07Eh,012h,79h,1Ch,1Fh>}   
IID_IUnknown GUID <0H,0H,0H,<0C0H,0H,0H,0H,0H,0H,0H,046H>>
IID_ISpeechRecognizer GUID {2D5F1C0Ch,0BD75h,4B08h,<94h,78h,3Bh,11h,0FEh,0A2h,58h,6Ch>}
   .code
   
   start:
   invoke CoInitializeEx ,NULL, COINIT_MULTITHREADED   
   invoke GetInterfaceFromProgId,SADR("Sapi.SpSharedRecognizer.1"),addr IID_ISpeechRecognizer
   .if eax != 0
      mov ppvISpeechRecognizer,eax
      ISpeechRecognizer Release
   .endif
   invoke ExitProcess,0
   ;------- proc içi ------------
GetInterfaceFromProgId PROC pProgId:DWORD,pIID:DWORD
        LOCAL wszProgID[1024]:word
        LOCAL ppv:Dword,retour,pchaine         
        LOCAL clsid     :GUID
        mov retour,0

        invoke MultiByteToWideChar,CP_ACP,MB_PRECOMPOSED,pProgId,-1,addr wszProgID,sizeof wszProgID
        invoke CLSIDFromProgID,addr wszProgID,addr clsid
        .if eax == S_OK
                invoke CoCreateInstance,addr clsid, NULL,CLSCTX_INPROC_SERVER OR CLSCTX_INPROC_HANDLER OR CLSCTX_LOCAL_SERVER,pIID,addr ppv

                .if eax == S_OK                         
                        PuPo retour,ppv
                .endif
        .endif
        mov eax,retour
        RET
GetInterfaceFromProgId endp   


Farabi

Quote from: ToutEnMasm on June 07, 2009, 07:52:25 AM

More explain seem needed.
Following what I was saying in my upper post,i have searched in the typelib
Quote
    coclass SpSharedRecognizer {
        [default] interface ISpeechRecognizer;
        interface ISpRecognizer;

Here you have the two interface supported by SpSharedRecognizer
Verify that those interfaces are present in your registry
use the IID (given by the registry)  with the function given upper.This one is the good method to connect.

Any code for doing it automatically?  :dazzled:
I used IID_Iunknown GUID <0H,0H,0H,<0C0H,0H,0H,0H,0H,0H,0H,046H>> on pIID and it connected, but retour return 0, is it okay?

[edit]
Aaaah this is what I want

IID_ISpeechRecognizer GUID {2D5F1C0Ch,0BD75h,4B08h,<94h,78h,3Bh,11h,0FEh,0A2h,58h,6Ch>}


[edit again]
USing IID_ISpeechRecognizer ppv return zero, is it normal?
Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"

ToutEnMasm


If the return value is 0 , it's not OK,perhaps have you not this CLSID in your registry.
MADE the verify , use regedit , open the HKEY_CLASSES_ROOT\CLSID key and with the edit menu search for 03BEE4890.It is enough like that.

Farabi

Oh its working, the return value is zero becase the SAPISrv is already started and Im not releasing it. Thanks. I will try to studying the documentation.
Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"

UtillMasm