Wouldn't this be GetShortPathNameA?  As it is you are casting d_name (a char array) to LPCWSTR (a wchar_t array.)  That doesn't make sense.  It also won't fit in the destination.

-[Unknown]