I want to extract the path from GetModuleFileNameW
and then to appen开发者_开发问答d "\hello.dll"
to it (Without making "\\\\"
). How to do that? (I'm not good with Unicode functions)
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;
}
精彩评论