Page 14 of 23
Re: COMatePLUS version 1.2
Posted: Sat Oct 23, 2010 10:33 am
by Nico
yes, of course
but the code doesn't work, Here is the code of MSDN
http://msdn.microsoft.com/en-us/library ... 85%29.aspx
Code: Select all
Dim FileName As String
Dim FileStream As New SpFileStream
Dim Voice As SpVoice
'Create a SAPI voice
Set Voice = New SpVoice
'The output audio data will be saved to ttstemp.wav file
FileName = "c:\ttstemp.wav"
'Create a file; set DoEvents=True so TTS events will be saved to the file
FileStream.Open FileName, SSFMCreateForWrite, True
'Set the output to the FileStream
Set Voice.AudioOutputStream = FileStream
'Speak the text
Voice.Speak "hello world"
'Close the Stream
FileStream.Close
'Release the objects
Set FileStream = Nothing
Set Voice = Nothing
Re: COMatePLUS version 1.2
Posted: Sat Oct 23, 2010 10:35 am
by srod
Your code with my modification worked fine here.
Re: COMatePLUS version 1.2
Posted: Sat Oct 23, 2010 11:27 am
by Nico
yes you are right, I do not know what happened during my first attempt
thank you for your patience

Re: COMatePLUS version 1.2
Posted: Sat Nov 13, 2010 2:00 pm
by Michael Vogel
Hi, not sure if I'm right, but when using EnableExplicit I got warnings about three undefined variables: winerror, len and *Buffer. Maybe this can be modified sometimes
Michael
Re: COMatePLUS version 1.2
Posted: Mon Dec 13, 2010 6:24 pm
by ts-soft
The same problem with EnableExplicit and my own problem
I can't create a "VirtualBox.Session" Object. The SDK can you download here:
http://download.virtualbox.org/virtualb ... -68302.zip
My testcode:
Code: Select all
IncludePath "..\..\"
XIncludeFile "COMatePLUS.pbi"
Define.COMateObject virtualbox, machine, session
virtualbox = COMate_CreateObject("VirtualBox.VirtualBox")
If virtualbox
Debug "VirtualBox Version " + virtualbox\GetStringProperty("Version") ; works
machine = virtualbox\GetObjectProperty("findMachine('WinXP_SP3')") ; change to a real vm
If machine
Debug machine\GetStringProperty("id") ; works
session = COMate_CreateObject("VirtualBox.Session") ; <- doesn't work
If session
Debug "session"
session\Release()
EndIf
machine\Release()
EndIf
virtualbox\Release()
EndIf
Greetings
Thomas
Re: COMatePLUS version 1.2
Posted: Mon Dec 13, 2010 11:04 pm
by Kiffi
Edit: nonsense suggestion removed. See code below.
Greetings ... Kiffi
Re: COMatePLUS version 1.2
Posted: Mon Dec 13, 2010 11:27 pm
by ts-soft
thx Peter, but doesn't work
I use this vbs as template:
Code: Select all
'
' Copyright (C) 2009 Oracle Corporation
'
' This file is part of VirtualBox Open Source Edition (OSE), as
' available from http://www.virtualbox.org. This file is free software;
' you can redistribute it and/or modify it under the terms of the GNU
' General Public License (GPL) as published by the Free Software
' Foundation, in version 2 as it comes in the "COPYING" file of the
' VirtualBox OSE distribution. VirtualBox OSE is distributed in the
' hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
'
Sub Print(str)
Wscript.Echo str
End Sub
Sub StartVm(vb, mach)
Dim session, progress
Set session = CreateObject("VirtualBox.Session")
Set progress = vb.openRemoteSession(session, mach.id, "gui", "")
progress.waitForCompletion(-1)
session.close()
End Sub
Sub StopVm(vb, mach)
Dim session, progress
Set session = CreateObject("VirtualBox.Session")
vb.openExistingSession session, mach.id
session.console.powerDown().waitForCompletion(-1)
session.close()
End Sub
Sub Main
Dim vb, mach
set vb = CreateObject("VirtualBox.VirtualBox")
Print "VirtualBox version " & vb.version
' Safe arrays not fully functional from Visual Basic Script, as we
' return real safe arrays, not ones wrapped to VARIANT and VBS engine
' gets confused. Until then, explicitly find VM by name.
' May wish to use hack like one described in
' http://www.tech-archive.net/Archive/Excel/microsoft.public.excel.programming/2006-05/msg02796.html to handle safearrays
' if desperate
Set mach = vb.findMachine("WinXP_SP3")
Print "Machine: " & mach.name & " ID: " & mach.id
StartVm vb, mach
End Sub
Main
this works fine.
Greetings
Thomas
Re: COMatePLUS version 1.2
Posted: Tue Dec 14, 2010 12:11 am
by Kiffi
@Thomas:
I will try to solve your problem tomorrow at my office.
Currently i have no vb-image here at home.
Greetings ... Kiffi
Re: COMatePLUS version 1.2
Posted: Tue Dec 14, 2010 9:50 am
by Kiffi
Ta-Da!
Code: Select all
IncludePath #PB_Compiler_Home + "srod\comateplus\"
XIncludeFile "comateplus.pbi"
EnableExplicit
Define.COMateObject VirtualBox, Machine, Session, Progress
Define.s MachineID
VirtualBox = COMate_CreateObject("VirtualBox.VirtualBox")
If VirtualBox
Debug "VirtualBox-Version: " + VirtualBox\GetStringProperty("Version")
Machine = VirtualBox\GetObjectProperty("findMachine('Xubuntu')")
If Machine
MachineID = Machine\GetStringProperty("id")
Debug "Machine-ID: " + MachineID
Machine\Release()
Session = COMate_CreateObject("VirtualBox.Session")
If Session
Progress = VirtualBox\GetObjectProperty("openRemoteSession(" + Str(Session) + " As COMateObject, '" + MachineID + "', 'gui', '')")
If Progress
Progress\Invoke("waitForCompletion(-1)")
Progress\Release()
Else
Debug "!Progress: " + COMate_GetLastErrorDescription()
EndIf
Session\Invoke("close()")
Session\Release()
Else
Debug "!Session: " + COMate_GetLastErrorDescription()
EndIf
Else
Debug "!Machine: " + COMate_GetLastErrorDescription()
EndIf
VirtualBox\Release()
Else
Debug "!VirtualBox: " + COMate_GetLastErrorDescription()
EndIf
Greetings ... Kiffi
Re: COMatePLUS version 1.2
Posted: Tue Dec 14, 2010 1:12 pm
by ts-soft
thx Peter, works
The problem was, i have to use x64 to become a session object. My host is x64.
Greetings
Thomas
Re: COMatePLUS version 1.2
Posted: Mon Jan 31, 2011 3:23 pm
by Rings
anyone got comateplus (latest version from srods place)
got working with PB4.51 ?
on the most examples (WMI ones) , i got an error at
COMate_GetObject() Procedure,
Line 374 hResult = iPersist\Load( bstr2, 0)
Bad Parameter type: a string is expected.
Unfortunality, i don't have a clue where to look
for the definition or how to solve this.
anyone can help ?
Re: COMatePLUS version 1.2
Posted: Mon Jan 31, 2011 3:39 pm
by ts-soft
Code: Select all
Procedure.i COMate_GetObject(file$, progID$="", blnInitCOM = #True)
Protected *this._membersCOMateClass, hResult = #E_OUTOFMEMORY, iPersist.IPERSISTFILE, clsid.CLSID, cf.IClassFactory, iUnknown.IUNKNOWN
Protected bstr1, t1
If blnInitCOM
CoInitialize_(0)
EndIf
If file$ Or progID$
*this = AllocateMemory(SizeOf(_membersCOMateClass))
If *this
*this\vTable = ?VTable_COMateClass
If file$
If progID$ = ""
;Here we attempt to create an object based upon the filename only.
bstr1 = COMate_MakeBSTR(file$)
If bstr1 ;If an error then hResult already equals #E_OUTOFMEMORY!
hResult = CoGetObject_(bstr1, 0, ?IID_IDispatch, @*this\iDisp)
SysFreeString_(bstr1)
EndIf
Else
;Here we attempt to create an object based upon the filename and the progID.
bstr1 = COMate_MakeBSTR(progID$)
If bstr1
hResult = CLSIDFromProgID_(bstr1, @clsid)
If SUCCEEDED(hResult)
hResult = CoGetClassObject_(clsid, #CLSCTX_LOCAL_SERVER|#CLSCTX_INPROC_SERVER, 0, ?IID_IClassFactory, @cf)
If SUCCEEDED(hResult)
hResult = cf\CreateInstance(0, ?IID_IPersistFile, @iPersist)
If SUCCEEDED(hResult)
hResult = iPersist\Load(file$, 0)
If SUCCEEDED(hResult)
hResult = iPersist\QueryInterface(?IID_IDispatch, @*this\iDisp)
EndIf
EndIf
If iPersist
iPersist\Release()
EndIf
EndIf
If cf
cf\Release()
EndIf
EndIf
EndIf
If bstr1
SysFreeString_(bstr1)
EndIf
EndIf
Else
;Here we attempt to create a new COMate object containing a new instance of a currently active object.
bstr1 = COMate_MakeBSTR(progID$)
If bstr1
If Left(progID$, 1) = "{"
hResult = CLSIDFromString_(bstr1, @clsid)
If SUCCEEDED(hResult)
hResult = ProgIDFromCLSID_(clsid, @t1)
If SUCCEEDED(hResult) And t1
SysFreeString_(t1)
EndIf
EndIf
Else
hResult = CLSIDFromProgID_(bstr1, @clsid);
EndIf
If SUCCEEDED(hResult)
hResult = GetActiveObject_(clsid, 0, @iUnknown)
If SUCCEEDED(hResult)
hResult = iUnknown\QueryInterface(?IID_IDispatch, @*this\iDisp)
EndIf
If iUnknown
iUnknown\Release()
EndIf
EndIf
SysFreeString_(bstr1)
EndIf
EndIf
EndIf
Else
hResult = #E_INVALIDARG
EndIf
If SUCCEEDED(hResult)
COMate_gNumObjects+1
ElseIf *this
FreeMemory(*this)
*this = 0
EndIf
CompilerIf Defined(COMATE_NOERRORREPORTING, #PB_Constant)=0
COMateClass_INTERNAL_SetError(*this, hResult)
CompilerEndIf
ProcedureReturn *this
EndProcedure
no problems with this
Re: COMatePLUS version 1.2
Posted: Mon Jan 31, 2011 4:06 pm
by Rings
thx, seems to work now.
Re: COMatePLUS version 1.2
Posted: Mon Feb 21, 2011 7:20 pm
by ebs
Does anyone have any experience using COMate Plus with the "ActiveLock" COM DLL? (
http://www.activelocksoftware.com/)
I have tried to create an ActiveLock object using this:
Code: Select all
Define.COMateObject ALObject
ALObject = COMate_CreateObject("ActiveLock3.IActiveLock")
which fails at this line in COMatePlus.pbi:
Code: Select all
229 hResult = CoGetClassObject_(clsid, #CLSCTX_LOCAL_SERVER|#CLSCTX_INPROC_SERVER, 0, ?IID_IClassFactory, @cf)
Any suggestions would be
greatly appreciated!
Regards,
Eric
Re: COMatePLUS version 1.2
Posted: Mon May 02, 2011 6:48 pm
by dige
I use COMate to send Emails via COMate_CreateObject("Outlook.Application").
Does anybody knows if its possible to use also other Email clients than Outlook,
eg. Thunderbird?