NO

Author Topic: c COM client example using a PowerBASIC created COM server  (Read 5251 times)

Offline jcfuller

  • Member
  • *
  • Posts: 35
c COM client example using a PowerBASIC created COM server
« on: January 27, 2009, 03:55:41 pm »
The c source was created and tested with Pelles 32bit c compiler. You will need to add oleauto32 and uuid libraries to the linker tabs.
I am NOT a c/c++ programmer but did find enough information to put together this example of accessing PowerBASIC COM Servers with no MFC,ATL, ABCDEFGH or whatever .....
Much of it is based on code I either found here or on the Code Project web site.
If you have ever written a com server in c or c++ I'm sure you will find the PowerBASIC Server source enlightening and maybe a bit jaw dropping on it's simpilcity.
Sources and a compiled server dll are included in the attachment.

Edit:
I forgot to mention there is no need to register the com class. Code shows loading dynamically from dll.


James C. Fuller 01-27-09
« Last Edit: January 27, 2009, 03:59:47 pm by jcfuller »

Gerome

  • Guest
Re: c COM client example using a PowerBASIC created COM server
« Reply #1 on: February 02, 2009, 02:17:09 am »
Hello James,
The c source was created and tested with Pelles 32bit c compiler. You will need to add oleauto32 and uuid libraries to the linker tabs.
I am NOT a c/c++ programmer but did find enough information to put together this example of accessing PowerBASIC COM Servers with no MFC,ATL, ABCDEFGH or whatever .....
Much of it is based on code I either found here or on the Code Project web site.
If you have ever written a com server in c or c++ I'm sure you will find the PowerBASIC Server source enlightening and maybe a bit jaw dropping on it's simpilcity.
Sources and a compiled server dll are included in the attachment.

Edit:
I forgot to mention there is no need to register the com class. Code shows loading dynamically from dll.


James C. Fuller 01-27-09


Kinda useful!
BTW, how do you correctly call (after having registering) your DLL via Excel, Word or any VBA compatible language because the constructor + destructors are OK but the two functions/methods are impossible to call :

Example :
Code: [Select]
Sub test()
Set o = CreateObject("cTest01")
    o.Fx1 42  '//==>> error 424 (object required) ??!!
Set o = Nothing
End Sub

Offline jcfuller

  • Member
  • *
  • Posts: 35
Re: c COM client example using a PowerBASIC created COM server
« Reply #2 on: February 02, 2009, 10:50:17 am »
Gerome,
  I replied to your pm first but will comment here also.
I don't think you can call this particular server from VB in the normal fashion as the interfaces are all IUnknown.
I do not have VB so I really don't know, but to do it the way you've shown I believe the interfaces need to
be either Dual or Automation. PowerBASIC can create these types of interfaces also. For more information you can
check http://www.powerbasic.com/support/pbforums/

James