Recent Posts

Pages: [1] 2 3 ... 10
1
Development / Re: COM
« Last post by John on November 25, 2020, 12:03:41 PM »
Charles,

Basically I need to pass returned LONG object pointers as VT_DISPATCH type for the Sage CreateOject method. That's why Mike used SET.
2
Development / Re: COM
« Last post by John on November 21, 2020, 01:48:01 PM »
Charles,

Is using i for integer with DLLC to define a DWORD argument correct? Windows uses a lot of DWORD references. I was thinking p for pointer would be a better choice.
3
Development / Re: COM
« Last post by John on November 20, 2020, 02:54:33 AM »
Sweet!

I hope you're having as much fun as I did playing with OLE automation.

VirtualInterface seems to answer my question about pasing iUnknown (object) pointers as arguments.

In the Sage accounting software ole automation interface it has a CreateObject call which often uses a previously created object as an argument to provide inherent use.

Take another peek at my example I posted to show this in use. Mike saved the day and added this feature (along with couple other improvements) that wasn't functional where Dave left off. Without this ability I can't access the Sage software which I personally do a lot of work with. My current project is using this feature in ScriptBasic.
4
Development / Re: COM
« Last post by Charles Pegge on November 20, 2020, 02:42:08 AM »
Thanks John,

JosÚs TypeLib Browser is an excellent tool. It provides all the interfacing details you need. The virtual table offsets can be used to access the required functions generically without a header.

CallByOffset
Code: [Select]
  uses  COM/COMutil
  CoInitialize null
  CreateGuid clsid "96749377-3391-11D2-9EE3-00C04F797396" 'SAPI
  CreateGuid iid   "6C44DF74-72B9-4992-A1EC-EF996E0422D4" 'IspVoice
  VirtualInterface *voice
  err=CoCreateInstance clsid, null, context, iid, @voice
  CallByOffset voice(80) (L"Hello World",1,0) 'speak async
  print "ok" 'pause required before ending
  CallByOffset voice(8) () 'release
  CoUninitialize
5
Development / Re: COM
« Last post by John on November 17, 2020, 05:34:23 PM »
This works in VB6 as a button click event.

Code: Visual Basic
  1. Private Sub Command1_Click()
  2.   Dim Voice As SpVoice
  3.   Set Voice = New SpVoice
  4.   Voice.Speak "Hello World"
  5. End Sub
  6.  

I exported from OLEview to an .idl file with the SAPI COM object info. This file is readable in a text editor.
6
Development / Re: COM
« Last post by John on November 17, 2020, 12:25:08 PM »
If you have VB6 it comes with a typelib viewer.
7
Development / Re: COM
« Last post by John on November 16, 2020, 09:18:44 PM »
Have you tried Jose Roca's typelib viewer?

I'm not a member of the JRS forum so I can't download attachments. Please post the latest here so I can update my version.

8
Development / Re: COM
« Last post by Charles Pegge on November 16, 2020, 02:38:18 PM »
Hi John,

speak will run in a thread. I do this in ProjectsA\speech\speech2.o2bas. I expect most COM interface methods will tolerate being in a thread

But speak is also capable of running asynchronously without requiring a thread. This is done by adding an extra arg '1'. voice.speak "hello ...",1

But I was unable to go asynchronous using iDispatch. I don't have a typelib browser and can't find the properties or methods  for automation ispVoice, to check for alternatives.
9
Development / Re: COM
« Last post by John on November 15, 2020, 05:35:05 PM »
I was able to get the Speak_String function to return an error.

Code: Script BASIC
  1. ' DLLC SAPI5
  2.  
  3. IMPORT dllc.sbi
  4.  
  5. sapi = dllfile("tts.dll")
  6.  
  7. Begin_Speech = dllproc(sapi, "Begin_Speech i = (i bufsz)")
  8. Speak_String = dllproc(sapi, "Speak_String i = (i usetxt, c *vtxt, i clrbuf, i vidx, i nttsa, i udv, i vol, i udp, i pitch, i uds, i speed)")
  9. End_Speech   = dllproc(sapi, "End_Speech ()")
  10.  
  11.  
  12. rtn = dllcall(Begin_Speech, 5000)
  13. PRINT "Begin_Speech = ", rtn,"\n"
  14.  
  15. rtn = dllcall(Speak_String,0,"Hello World",1,0,1,0,0,0,0,0,0)
  16. PRINT "Speak_String = ", rtn, "\n"
  17.  
  18. dllcall(End_Speech)
  19.  
  20. dllfile
  21.  


C:\ScriptBASIC\examples>sbc dllc_com.sb
Begin_Speech = 1
Speak_String = 0

C:\ScriptBASIC\examples>


I can't believe Theo would post a library reference and not even test if it works on current OS versions.  :-[
10
Development / Re: COM
« Last post by John on November 14, 2020, 09:30:33 PM »
Charles,

I tried to used SB/DLLC to call the tts.dll library. It gets as far as Begin_Speech and drops to the command prompt.  :(

Here is the C declares.

Code: C
  1. extern int Begin_Speech(DWORD);
  2. extern BOOL Speak_String(int,char *,int,int,int,int,DWORD,int,DWORD,int,DWORD);
  3. extern void End_Speech(void);
  4.  


Code: Script BASIC
  1. ' DLLC SAPI5
  2.  
  3. IMPORT dllc.sbi
  4.  
  5. sapi = dllfile("tts.dll")
  6.  
  7. Begin_Speech = dllproc(sapi, "Begin_Speech i = (i bufsz)")
  8. Speak_String = dllproc(sapi, "Speak_String i = (i usetxt, c *words, i clrbuf, i vidx, i nttsa, i udv, i vol, i udp, i pitch, i uds, i speed)")
  9. End_Speech   = dllproc(sapi, "End_Speech ()")
  10.  
  11. TEXT_BUFFER_SIZE = 5000
  12. USE_TEXT = 1
  13. CLEAR_TEXT_BUFFER = 1
  14. NEW_TTS_ALWAYS = 1
  15. USE_DEFAULT_VOLUME = 1
  16. USE_DEFAULT_PITCH = 1
  17. USE_DEFAULT_SPEED = 1
  18.  
  19. rtn = 0
  20. currentVoice = 0
  21. volume = 0
  22. pitch = 0
  23. speed = 0
  24.  
  25. rtn = dllcall(Begin_Speech, TEXT_BUFFER_SIZE)
  26. PRINT "Begin_Speech = ", rtn,"\n"
  27.  
  28. greeting$ = "Hello World"
  29.  
  30. rtn = dllcall(Speak_String,USE_TEXT,greeting$,CLEAR_TEXTSPEECH_BUFFER,currentVoice,NEW_TTS_ALWAYS,USE_DEFAULT_VOLUME,volume,USE_DEFAULT_PITCH,pitch,USE_DEFAULT_SPEED,speed)
  31. PRINT "Speak_String = ", rtn, "\n"
  32.  
  33. dllcall(End_Speech)
  34.  
  35. dllfile
  36.  
Pages: [1] 2 3 ... 10