Okay, this may not be too bad.

First off, I think that I disagree with you statement about the char * being deallocated as the function closes. With the explicit return, the variable in the program that makes the call should be set to point to the same block of memory. You will now have two pointers. The pointer inside the called function will be deallocated, but because there is still a pointer to that block of memory, it (the block of memory) will not be dealloc'ed.

'Course, all of that is true provided we are in C++. But this is a VB program calling the VC++ function. I don't know if the VB variable will be set equal to the string "ABCD" or to the memory address 0x0001254. VB doesn't support pointers. I also am afraid that the memory block will be dealloc'ed because C++ doesn't regonize the VB variables claim to that memory. Hopefully the data is copied into the VB programs memory space and not just a hex number which will have no meaning to VB.

I hope that makes sense.

Anyway... I looked at the projects you mention. There, the VB app is call the function GetString myString, myLength. I'm looking at preserving the myString = GetString(myLength) format. But that is a side point for now... here is the VC++ DLL function:
Code:
char *str = "1234567890123456789012345678901234567890";

void __stdcall GetString(char *pcString, long lLength) {
	strncpy(pcString, str, lLength);
	pcString[lLength] = 0;
}
I notice here that the first argument is being passed by reference, and that is expected. Instead of returning a memory address to VB, it is picking VBs address and altering its memory block.

But that isn't my question... my question is... why is it setting the nth character to zero? Is that providing the null termination for the string?

I'm going to experiment with changing it from a void return to char *. I'll let you know how it goes.