|
-
Jun 11th, 2000, 06:34 PM
#1
Thread Starter
Frenzied Member
I'm doing a set of dlls for use with VB, some of them return a pointer to a class so the VB user can refer to it later. The trouble is if the VB user doesn't pass in the right number or passes in a pointer to a class that's already destroyed the whole thing just crashes.
Is there a way of checkig if a particular address is a pointer to type of class?
thanks in adv
-
Jun 12th, 2000, 04:13 AM
#2
Monday Morning Lunatic
not really, because all a pointer is is a memory location, and there's no other information available. if you were in C++ only, you could use run time type information which gives you full info on a class, including whether it's allocated or not. A possible way is to pass a type around:
Code:
Type MyClassWrapper
Pointer as Long
Allocated as Integer
End Type
So you use this and pass it to your C++ functions, and if any of them deallocate it, they set the Allocated member to 0, and everything checks this before doing anything.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|