Results 1 to 2 of 2

Thread: What am I pointing too?

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Mar 2000
    Posts
    1,089
    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

  2. #2
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    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
  •  



Click Here to Expand Forum to Full Width