if (filep.find(L"\\\\")==0)
should probably be:
if (filep.find(L"\\\\")==std::wstring::npos)
Having said that, I don't really know what you're trying to do so I can't comment on the rest of the code.
thanx for your reply,
i need to get short path of the given path hence im using GetShortPathNameW
Last edited on
You're right about the check for a UNC name.
I'm not on a Windows box right now, so I can't test it. But try:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
|
std:wstring GetShortName(const std::wstring &MAX_PATH)
{
size_t mxlen = 32767;
wchar_t* shortpath = new wchar_t[mxlen];
*shortpath = 0;
std::wstring local_longpath;
if (longpath.find(L"\\\\") = 0)
local_longpath = longpath;
else
local_longpath = = L"\\\\?\\" + longpath;
DWORD dwLen = ::GetShortPathW(local_longpath.c_str(), shortpath, mxlen);
std::wstring out(shortpath);
delete [] shortpath;
return out;
}
|
Last edited on