# Cannot 'LPTSTR' to 'char \*'

**URL:** <https://iplug2.discourse.group/t/cannot-lptstr-to-char/303>\
**Category:** Windows\
**Created:** [12 February 2021 13:22 UTC](https://iplug2.discourse.group/t/cannot-lptstr-to-char/303 "2021-02-12T13:22:45Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![SKyZz](https://avatars.discourse-cdn.com/v4/letter/s/4491bb/32.png) [@SKyZz](https://iplug2.discourse.group/u/SKyZz)\
**Post date:** [12 February 2021 13:22 UTC](https://iplug2.discourse.group/t/cannot-lptstr-to-char/303/1 "2021-02-12T13:22:45Z")

</div>

Hello guys,

> LPTSTR strDLLPath1 = new TCHAR[\_MAX\_PATH];  
> ::GetModuleFileName((HINSTANCE)&\_\_ImageBase, strDLLPath1, \_MAX\_PATH);  
> ss \<\< “{\n "sum\_artifact": "” \<\< md5.digestFile(strDLLPath1) \<\< “"\n}”;

In VST 2th project looks good but in VST 3th I see this problem` Cannot 'LPTSTR' to 'char *`'. How to fix this? Thanks.

---

<div class="post-metadata">

**Author:** ![radiofarmer](https://avatars.discourse-cdn.com/v4/letter/r/f475e1/32.png) [@radiofarmer](https://iplug2.discourse.group/u/radiofarmer)\
**Post date:** [13 February 2021 12:58 UTC](https://iplug2.discourse.group/t/cannot-lptstr-to-char/303/2 "2021-02-13T12:58:06Z")

</div>

I haven’t worked on the VST2 distribution and haven’t used the `LPTSTR` macro/typedef, but I encountered a similar problem with code portability between the standalone app and VST3 build. In the APP project, `TCHAR` is a typedef for `char`, so it can be directly converted to a string. In the VST3 project, `TCHAR` is `wchar_t` and cannot be automatically converted to `std::string`. I got around this by converting it the `wchar_t` array to a `wstring`, converting that to bytes, and then converting that to a regular string for further use.

As for what solution is best for you - that’s a general C++ issue. The first result on StackOverflow for “convert wchar\_t to string” worked for me.
