It is currently Sun May 19, 2013 5:38 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: COM Interface Question
PostPosted: Fri Feb 24, 2012 8:45 pm 
Offline
Enthusiast
Enthusiast

Joined: Thu May 21, 2009 6:56 pm
Posts: 249
Hi

The following are the details for a COM object I want to use with Purebasic. I defined and interface as follows and I am not sure if I need the ReturnValue parameter however if I leave it out I get an invalid memory error in Purebasic. I found I had to add this extra ReturnValue parameter when the COM object returned a string value so I am guessing that it might be needed but I do not know why.

Secondly when I do *loCOM\Execute(@*lnReturnPtr.i) it does return #S_OK.

So how should the Interface be defined and the Execute method called?

It would be helpful if there were more details about COM in the PB documentation since COM is used often in MS Windows and most of their products support it.

Thanks,
Simon

Code:

DEFINE_GUID(CLSID_dCVFPSrvc, $E3238B33, $AC18, $42FD, $BF, $DF, $97, $AD, $09, $73, $75, $4B)
DEFINE_GUID(IID_dCVFPSrvc,   $9E0C18A3, $B124, $49E3, $A2, $86, $A5, $A2, $70, $9A, $08, $BE)

Interface dCVFPSrvc Extends IDispatch
  DestroyWorkers(ReturnValue.i)
  Execute(ReturnValue.i)
  ProcessQueue(ReturnValue.i)
  StartWorkers(ReturnValue.i)
  StopWorkers(ReturnValue.i)
  WriteToLog(ReturnValue.i)
EndInterface

Define *loCOM.dCVFPSrvc



Code:
' Version Dependent ProgIDs
$PROGID_dcvfpsrvc_dcvfpsrvcdCVFPSrvc = "dcvfpsrvc.dCVFPSrvc"

' Version Independent ProgIDs
$PROGID_dcvfpsrvc_dcvfpsrvc = "dcvfpsrvc.dCVFPSrvc"

' Class Identifiers
$CLSID_dcvfpsrvc_dcvfpsrvc = GUID$("{E3238B33-AC18-42FD-BFDF-97AD0973754B}")

' Interface Identifiers
$IID_dcvfpsrvc_Idcvfpsrvc = GUID$("{9E0C18A3-B124-49E3-A286-A5A2709A08BE}")

' Interface Name  : Idcvfpsrvc
' Description     : dcvfpsrvc.dCVFPSrvc
' Class Name      : dcvfpsrvc
' ClassID         : $CLSID_dcvfpsrvc_dcvfpsrvc
' ProgID          : $PROGID_dcvfpsrvc_dcvfpsrvc
' Version ProgID  : $PROGID_dcvfpsrvc_dcvfpsrvcdCVFPSrvc
Interface Idcvfpsrvc $IID_dcvfpsrvc_Idcvfpsrvc
    Inherit IDispatch

    Method destroyworkers <0> () As Variant
    Method execute <1> () As Variant
    Method ProcessQueue <2> () As Variant
    Method startworkers <3> () As Variant
    Method stopworkers <4> () As Variant
    Method writetolog <5> () As Variant
End Interface



Top
 Profile  
 
 Post subject: Re: COM Interface Question
PostPosted: Mon Feb 27, 2012 2:48 am 
Offline
Addict
Addict

Joined: Fri Oct 23, 2009 2:33 am
Posts: 2852
Location: Wales, UK
Some info from Freak about making a COM Object using his framework: http://www.purebasic.fr/english/viewtopic.php?t=22132

...and a COM tutorial by Freak: http://freak.purearea.net/help/COMTutorial.pdf

eek! Adobe Reader doesn't want to read that pdf on my PC...... but you will find an example here: http://www.purearea.net/pb/english/index.htm

_________________
IdeasVacuum
If it sounds simple, you have not grasped the complexity.


Top
 Profile  
 
 Post subject: Re: COM Interface Question
PostPosted: Tue Feb 28, 2012 1:51 pm 
Offline
Enthusiast
Enthusiast

Joined: Thu May 21, 2009 6:56 pm
Posts: 249
Thank-you I will have a look.

Simon


Top
 Profile  
 
 Post subject: Re: COM Interface Question
PostPosted: Fri Mar 02, 2012 4:15 am 
Offline
Enthusiast
Enthusiast

Joined: Thu May 21, 2009 6:56 pm
Posts: 249
I had a look but it is handling things quite differently that anything I understand. All I need now is to correctly define the Interface shown below. I was able to make it work in PowerBasic but I would also like to understand how to make this work in Purebasic.

Thanks
Simon

Code:
Interface Idcvfpsrvc $IID_dcvfpsrvc_Idcvfpsrvc
    Inherit IDispatch

    Property Get AWORKERS <0> () As Variant
    Property Set AWORKERS <0> (ByVal AWORKERS As Variant)
    Property Get NWORKERCOUNT <2> () As Variant
    Property Set NWORKERCOUNT <2> (ByVal NWORKERCOUNT As Variant)
    Method destroyworkers <4> () As Variant
    Method execute <5> () As Variant
    Method GetWorker <6> () As Variant
    Method ProcessQueue <7> () As Variant
    Method startworkers <8> () As Variant
    Method stopworkers <9> () As Variant
    Method writetolog <10> () As Variant
End Interface



Top
 Profile  
 
 Post subject: Re: COM Interface Question
PostPosted: Sat Mar 03, 2012 6:19 am 
Offline
Enthusiast
Enthusiast

Joined: Thu May 21, 2009 6:56 pm
Posts: 249
I found my problem. I had not correctly declared my methods in the COM server as void and I had added an extra method in the COM object for testing that I had not correctly accounted for in Purebasic. The correct and working interface is as follows:

Code:
Interface dCVFPSrvc Extends IDispatch
    DestroyWorkers()
    Execute()
    ProcessQueue()
    StartWorkers()
    StopWorkers()
    Test()
    Writetolog()
EndInterface


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye