Reputation: 5047
I want to extract the path from GetModuleFileNameW
and then to append "\hello.dll"
to it (Without making "\\\\"
). How to do that? (I'm not good with Unicode functions)
Upvotes: 0
Views: 852
Reputation: 106589
Assuming you're really working with paths, use the PathAppendW
function. Note that you do this by appending "hello.dll"
-- the backslash will be added if required by PathAppendW
.
Alternately, you could write your own function pretty easily. Here's an example I threw together in 5 minutes in terms of std::wstring
s
std::wstring PathAppend(const std::wstring& lhs, const std::wstring& rhs)
{
if (lhs.empty())
{
return rhs;
}
else if (rhs.empty())
{
return lhs;
}
std::wstring result(lhs);
if (*lhs.rbegin() == L'\\')
{
result.append(rhs.begin() + (rhs[0] == L'\\'), rhs.end());
}
else
{
if (rhs[0] != L'\\')
{
result.push_back(L'\\');
}
result.append(rhs);
}
return result;
}
Upvotes: 2