Use Wide String variants explicitly for Windows API calls#7235
Use Wide String variants explicitly for Windows API calls#7235bob80905 merged 1 commit intomicrosoft:mainfrom
Conversation
| CHAR szFullModuleFilePath[MAX_PATH] = ""; | ||
| GetModuleFileName(GetModuleHandle("d3d10warp.dll"), | ||
| szFullModuleFilePath, sizeof(szFullModuleFilePath)); | ||
| if (GetModuleHandleW(L"d3d10warp.dll") != NULL) { |
There was a problem hiding this comment.
This change looks good. However, I've seen projects where the use of the W api function vs the char one was controlled via a compile time flag. Would there be any reason to do that here?
There was a problem hiding this comment.
Yes, there have been projects that do this. However, our char strings are not ASCII or based on some current global character set, they are utf-8. The char APIs are not Unicode. Therefore, we should always use the Unicode wide string APIs. We have no reason to ever build for the non-Unicode APIs.
There was a problem hiding this comment.
By the way, this is the reason for all the forced conversions in the DXC API. The only Unicode API style for Windows (and thus COM APIs) is the wide string APIs, yet we internally use char strings representing Unicode in UTF-8 encoding.
This PR changes some code in ExecutionTests.cpp to use the wide string variants of Windows API calls explicitly. This is because some internal builds will get confused about which overload to resolve the GetModuleHandle function to. By being explicit, this should eliminate the error that an arg can't be converted to LPCWSTR. Cherry picked from #7235
…7236) This PR changes some code in ExecutionTests.cpp to use the wide string variants of Windows API calls explicitly. This is because some internal builds will get confused about which overload to resolve the GetModuleHandle function to. By being explicit, this should eliminate the error that an arg can't be converted to LPCWSTR. Cherry picked from microsoft#7235 (cherry picked from commit 2399215)
This PR changes some code in ExecutionTests.cpp to use the wide string variants of Windows API calls explicitly. This is because some internal builds will get confused about which overload to resolve the GetModuleHandle function to. By being explicit, this should eliminate the error that an arg can't be converted to LPCWSTR.