Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
GETOBJECT and OLEPUBLIC
Message
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01176727
Message ID:
01177446
Views:
14
John,

It's been some time since I last used it, and I scattered code here and there to make the task of remembering how to use it more complicated <g>

What I did (what I understood from the MS article + the code you downloaded) and worked perfectly for me was:

Let's say your class is called Application in a project called Test, thus your COM would be 'Test.Application', You need to add a method that will initialize it I call it SetUp, others preferr Initialize, this is important for you can not put the code in the Init, IIRC. I also added a property call ROTServer which will hold a reference to the ROTServer object, so we have: (Adding the Destroy())
define class Application as Session OLEPublic
	protected ROTServer as Object

	function Initialize() as Boolean
		this.ROTServer		= RotServer()	&& To copy what you have in MAIN.PRG, I would use newobject instead
							&& ROTServer is the PRG and should be accessible
		this.ROTServer.Register(this, 'Test.Application')
	endfunc

	procedure Destroy() as VOID
		this.ROTServer.Revoke('Test.Application')
		this.ROTServer		= null
	endproc
enddefine
You should remember to call Initialize() inmediately after the creation of the object
loTest		= createobject('Test.Application')
loTest.Initialize()
I think that is all you need, I can't be 100% sure for I changed some things that were in the original to adapt it to my base COM class, and, as I said, I have some code scattered around, but, I am quite sure that if this is not correct it should give you a starting point. Also do not trust in the code I put, I just wrote it in here, not much checking <g>
"The five senses obstruct or deform the apprehension of reality."
Jorge L. Borges?

"Premature optimization is the root of all evil in programming."
Donald Knuth, repeating C. A. R. Hoare

"To die for a religion is easier than to live it absolutely"
Jorge L. Borges
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform