summaryrefslogtreecommitdiff
path: root/shell/source/win32/shlxthandler/infotips/infotips.cxx
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2017-09-27 14:20:25 +0300
committerMike Kaganski <mike.kaganski@collabora.com>2017-09-28 08:55:04 +0200
commite80aef4e032f08ef0c4cfbb028bf83b81002f112 (patch)
treeabb1d7e2ae7f46623d2769b5820e716ad063b4eb /shell/source/win32/shlxthandler/infotips/infotips.cxx
parent09917566b6ce86ea65a246f2055b5d1f41df4e76 (diff)
shell: use Unicode on Windows
Change-Id: I9f7962db320f8832879ba327108425a7592b4b77 Reviewed-on: https://gerrit.libreoffice.org/42885 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'shell/source/win32/shlxthandler/infotips/infotips.cxx')
-rw-r--r--shell/source/win32/shlxthandler/infotips/infotips.cxx24
1 files changed, 11 insertions, 13 deletions
diff --git a/shell/source/win32/shlxthandler/infotips/infotips.cxx b/shell/source/win32/shlxthandler/infotips/infotips.cxx
index 7985cb19bc25..c15f9723deb7 100644
--- a/shell/source/win32/shlxthandler/infotips/infotips.cxx
+++ b/shell/source/win32/shlxthandler/infotips/infotips.cxx
@@ -101,23 +101,23 @@ ULONG STDMETHODCALLTYPE CInfoTip::Release()
/** get file type information from registry.
*/
-std::wstring getFileTypeInfo(const std::string& file_extension)
+std::wstring getFileTypeInfo(const std::wstring& file_extension)
{
- char extKeyValue[MAX_STRING];
- char typeKeyValue[MAX_STRING];
- ::std::string sDot(".");
- if (QueryRegistryKey(HKEY_CLASSES_ROOT, (sDot.append(file_extension)).c_str(), "", extKeyValue, MAX_STRING))
- if (QueryRegistryKey( HKEY_CLASSES_ROOT, extKeyValue, "",typeKeyValue, MAX_STRING))
- return StringToWString(typeKeyValue);
+ wchar_t extKeyValue[MAX_STRING];
+ wchar_t typeKeyValue[MAX_STRING];
+ ::std::wstring sDot(L".");
+ if (QueryRegistryKey(HKEY_CLASSES_ROOT, (sDot.append(file_extension)).c_str(), L"", extKeyValue, MAX_STRING))
+ if (QueryRegistryKey( HKEY_CLASSES_ROOT, extKeyValue, L"",typeKeyValue, MAX_STRING))
+ return typeKeyValue;
return EMPTY_STRING;
}
/** get file size.
*/
-DWORD getSizeOfFile( char const * FileName )
+DWORD getSizeOfFile( wchar_t const * FileName )
{
- HANDLE hFile = CreateFile(StringToWString(FileName).c_str(), // open file
+ HANDLE hFile = CreateFileW(FileName, // open file
GENERIC_READ, // open for reading
FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE, // share for all operations
nullptr, // no security
@@ -178,7 +178,7 @@ std::wstring formatSizeOfFile( DWORD dwSize )
/** get file size information.
*/
-std::wstring getFileSizeInfo(char const * FileName)
+std::wstring getFileSizeInfo(wchar_t const * FileName)
{
DWORD dwSize=getSizeOfFile(FileName);
if (dwSize != INVALID_FILE_SIZE)
@@ -329,13 +329,11 @@ HRESULT STDMETHODCALLTYPE CInfoTip::Load(LPCOLESTR pszFileName, DWORD /*dwMode*/
fname = getShortPathName( fname );
- std::string fnameA = WStringToString(fname);
-
// ZeroMemory because strncpy doesn't '\0'-terminates the destination
// string; reserve the last place in the buffer for the final '\0'
// that's why '(sizeof(m_szFileName) - 1)'
ZeroMemory(m_szFileName, sizeof(m_szFileName));
- strncpy(m_szFileName, fnameA.c_str(), (sizeof(m_szFileName) - 1));
+ wcsncpy(m_szFileName, fname.c_str(), (sizeof(m_szFileName)/sizeof(*m_szFileName) - 1));
return S_OK;
}