AnsweredAssumed Answered

vrf Using DLLs with "this" pointers and Mike's Scroll Bars

Question asked by VRFuser on Jun 24, 2003
Hi Kirk & welcome.

> What is this pointer and how do I handle this?

At first glance I was confused. Never say "this" to a C++ programmer It
means something very special.

Now I understand though. What he's asking you to supply is a buffer to copy
the string returned by the instrument in to. What's happening when VEE goes
away is that the string returned by the instrument is longer than the string
you passed down to the dll. The dll happily copies right over the passed
string and continues on past the end. Usually this results in a BRB - the
Big Red Box. This is what happens when an external function commits an
Access Violation.

What's happening in this case though is that the dll doesn't cause an Access
Violation itself, but VEE does when it attempts to use the returned data -
probably when it attempts to construct a Text object from the returned data.
The violation isn't caught by VEE so Windows handles it. Usually it will
give you a dialog box explaining that VEE caused an Access Violation and has
to be shut down, but if the situation is particularly bad Windows will just
terminate the offending process with no notification and VEE simply vanishes
in a puff of greasy black smoke.

To avoid this unhappy scenario, you have to pass a string buffer long enough
to contain the returned data. What I usually do is use a Formula object with
the expression:

"*" * bufsize

where bufsize is large enough. Assuming the function goes something like:
SendAndReceive(char *pSend, char *pReceive), wire this formula to the
pReceive pin and you're all set. The actual character you use to construct
the buffer is inconsequential as long as the returned data is
zero-terminated. If it's not, you have a more interesting problem and the
solution lies in zero-terminating the data when it's returned to the dll.

You are currently subscribed to vrf as:
To subscribe send a blank email to "".
To unsubscribe send a blank email to "".
To send messages to this mailing list,  email "". 
If you need help with the mailing list send a message to "".