Blog Stats
  • Posts - 45
  • Articles - 0
  • Comments - 16
  • Trackbacks - 20

 

bad bad bad hack

Have you ever written a piece of code that you know is bad but you had to push it out because you know it had to be implemented?

I ran across one of those scenaios the other day. While using Interop Services, I discovered that a Wchar pointer in VC++ 6.0 that was returning back a value would not return back any value if marshalled as a string (with UnmanagedType.LPWStr) The only way that I could do this was as UnmanagedType.LPArray of char[]. This got me the string back except it looked like this "h e l l o w o r l d". The spaces were there because the C++ representation assigned double the space needed for char. So in true bad hack fashion, I assigned another string and picked alternate characters. The new string now read "hello world". If anyone knows a better way, please let me know.

Feedback

No comments posted yet.


Post a comment





 

 

 

Copyright © Rishi Pande