I am using
TCHAR buffer[MAX_SIZE];
after some set of steps i am gettig the relative path of folder say for ex:
c:\Microsoft.NET\Framework\v1.0.037\
Since the above path is in buffer of type TCHAR and i am trying to concatenate“RegAsm.exe”
After Appending i need to convert the path to the LPCTSTR since i need to pass it to
CreateProcess() which takes LPCTSTR type as argument
then the compiler giving error.I have tried but vexed.
can any one help me in this aspect….
The problem is TCHAR and CreateProcess are macros that expand differently depending on whether you compile for Unicode or not. The caveat is that GetCORSystemDirectory() will only accept a Unicode buffer. To get rid of these ANSI/Unicode problems write this code part explicitly for Unicode.
Instead of TCHAR use WCHAR for the buffer. Instead of CreateProcess() use CreateProcessW() – it will happily accept the Unicode buffer. Use wcscat() for strings concatenation.
Something like this (error handling omitted):