Sub StartSpeaking()
Set myobject = CreateObject("GWSpeak.Speak")
myobject.SpeakString ("This is the text you want to speak")
End Sub
I have located the file GWSpeak.dll, and to access a routine in it I would normally do something like hApi = LoadLibrary("GWSpeak.dll"); and then try to get the function through Say = GetProcAddress(hApi, "SpeakString");.
But SpeakString is not an Exported Function in this DLL. When I run DLL Export Viewer on GWSPeak.dll, I getthe following list:
I have got as far as retrieving the exported DllRegisterServer from the DLL and calling it. This makes GWSpeak.Speak appear in the registry, and I succeeded in converting that to a CLSID with the function CLSIDFromString (using L"GWSpeak.Speak" as wide-char string argument).
But there I get stuck. It seems I would have to call the export DllGetClassObject now. I have no difficulty extracting that entry point from the DLL, (with GetProcAddress), but it needs to be called with 2 input arguments (and one pointer to an output, but that is no problem). The first input argument is the CLSID, which I think I have obtained. But the second should be an "Interface ID", and I have no idea at all what that means. I tried a routine IIDFromString, but that turns out useless, as it is merely converts 32-digit hex numbers into a corresponding 128-bit int representation.
I had expected that this second parameter of DllGetClassObject would somehow specify what method I wanted to retrieve (in this case "SpeakString"), but there seems no way to convert that info into an IID. So apparently DllGetClassObject will not be able to return me a pointer to that. So what will it return, once I am successful? A pointer to a struct in which SpeakString is a member? How will I be able to address that member? I guess the structure must be declared somehow, to tell the compiler the offset of the member compared to the returned pointer. Can the necessary declaration be derived from the info I get with the DLL Export Viewer?
Learned about COM about 10 years ago and promptly forgot it. I think you'll need to dig up a basic primer and work through that. You usually have to use some sort of interface factory to load the reference, add a count to it and then you get to call it.
hgm wrote:...
The SpeakString is there, but it is listed as a COM Method rather than an Exported function. What would I have to do to call this "COM Method"?
In many C++ compiler IDE you can create an object from an Activex that encapsulate all the COM methods. In C++ Builder, for sample, you can use Component->Import Activex control. In this way, you can easly call the COM methods and use any property of the object.