I successfully wrote a small test of a COM server and a VB client, following the CVF Professional documentation and using the COM Server Wizard. I have a couple of questions about some things that seem to work but that I don?t exactly understand.
In the sample, instance data is passed to individual methods via a pointer, called ObjectData, to a user-defined data structure. This would be unsatisfactory for us since the whole idea of our project is to recast a large amount of legacy code in the form of a COM server. We do not want to rewrite all this legacy code.
I found that I could define instance data in the form of members of a COMMON block. This seems to work just fine. Instance data are store in COMMON blocks, and multiple instances of the server are nicely independent of each other. This is what we need.
Also I found that, in the subroutines that implement my methods, local variables, which I defined to be static as specified in the CVF documentation, are independent across instances and behave the way static variables in a subroutine should. This is just what we need because our legacy code often depends on local variables in subroutines being static, so they retain their value when a subroutine is re-entered.
1. Is the passing of instance data through the ObjectData pointer simply done for convenience, and storing instance data in common blocks is equally valid? Or is there something else I need to know?
2. Are my variables in COMMON, and my local variables, stored in a heap (or some orther sort of memory structure) that is created when my COM server is instantiated? If not, how are they stored?