The main thing is that you must allocate the memory for the string, viGetAttribute does not handle memory allocation.
I personally just fill the string with spaces before passing it to the function, then use the RTrim() function to remove the extra spaces like so:
Dim buf as string
buf = String(255, " ")
viGetAttribute(vi, VI_ATTR_RSRC_NAME, buf)
RTrim(buf)
just make sure you fill the string with enough spaces to hold the return value.