COMatePLUS version 1.2

Developed or developing a new product in PureBasic? Tell the world about it.
Nico
Enthusiast
Enthusiast
Posts: 274
Joined: Sun Jan 11, 2004 11:34 am
Location: France

Re: COMatePLUS version 1.2

Post by Nico »

yes, of course :oops:

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
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Re: COMatePLUS version 1.2

Post by srod »

Your code with my modification worked fine here.
I may look like a mule, but I'm not a complete ass.
Nico
Enthusiast
Enthusiast
Posts: 274
Joined: Sun Jan 11, 2004 11:34 am
Location: France

Re: COMatePLUS version 1.2

Post by Nico »

yes you are right, I do not know what happened during my first attempt :)

thank you for your patience :D
User avatar
Michael Vogel
Addict
Addict
Posts: 2797
Joined: Thu Feb 09, 2006 11:27 pm
Contact:

Re: COMatePLUS version 1.2

Post 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 :wink:

Michael
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Re: COMatePLUS version 1.2

Post by ts-soft »

The same problem with EnableExplicit and my own problem :wink:

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
User avatar
Kiffi
Addict
Addict
Posts: 1485
Joined: Tue Mar 02, 2004 1:20 pm
Location: Amphibios 9

Re: COMatePLUS version 1.2

Post by Kiffi »

Edit: nonsense suggestion removed. See code below.

Greetings ... Kiffi
Last edited by Kiffi on Tue Dec 14, 2010 10:00 am, edited 1 time in total.
Hygge
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Re: COMatePLUS version 1.2

Post 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
User avatar
Kiffi
Addict
Addict
Posts: 1485
Joined: Tue Mar 02, 2004 1:20 pm
Location: Amphibios 9

Re: COMatePLUS version 1.2

Post 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
Hygge
User avatar
Kiffi
Addict
Addict
Posts: 1485
Joined: Tue Mar 02, 2004 1:20 pm
Location: Amphibios 9

Re: COMatePLUS version 1.2

Post 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
Hygge
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Re: COMatePLUS version 1.2

Post by ts-soft »

thx Peter, works :D

The problem was, i have to use x64 to become a session object. My host is x64.

Greetings
Thomas
User avatar
Rings
Moderator
Moderator
Posts: 1435
Joined: Sat Apr 26, 2003 1:11 am

Re: COMatePLUS version 1.2

Post 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 ?
SPAMINATOR NR.1
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Re: COMatePLUS version 1.2

Post 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
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
User avatar
Rings
Moderator
Moderator
Posts: 1435
Joined: Sat Apr 26, 2003 1:11 am

Re: COMatePLUS version 1.2

Post by Rings »

thx, seems to work now.
SPAMINATOR NR.1
ebs
Enthusiast
Enthusiast
Posts: 557
Joined: Fri Apr 25, 2003 11:08 pm

Re: COMatePLUS version 1.2

Post 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
dige
Addict
Addict
Posts: 1391
Joined: Wed Apr 30, 2003 8:15 am
Location: Germany
Contact:

Re: COMatePLUS version 1.2

Post 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?
"Daddy, I'll run faster, then it is not so far..."
Post Reply