summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2022-04-14 14:41:33 +0100
committerMike Kaganski <mike.kaganski@collabora.com>2022-04-15 07:06:57 +0200
commita8383345174d91f6e722128e1d53c9a4ebc18195 (patch)
tree9ea7afda84fd6e80aeea31aec909b232e66f1a9e /vcl
parente1f3f2e00c37173e5f6f1cbb5235ab95b100bde7 (diff)
No Win16-style WIN.INI since Windows Vista
Change-Id: I75bc8c7c61e863747cdfc65fb4ed7603c0eb1c0f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133034 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/win/gdi/salprn.cxx29
1 files changed, 5 insertions, 24 deletions
diff --git a/vcl/win/gdi/salprn.cxx b/vcl/win/gdi/salprn.cxx
index 835c571785a6..724c4f18e2e1 100644
--- a/vcl/win/gdi/salprn.cxx
+++ b/vcl/win/gdi/salprn.cxx
@@ -22,6 +22,7 @@
#include <osl/diagnose.h>
#include <memory>
+#include <vector>
#include <string.h>
#include <svsys.h>
@@ -224,31 +225,11 @@ OUString WinSalInstance::GetDefaultPrinter()
GetDefaultPrinterW( nullptr, &nChars );
if( nChars )
{
- LPWSTR pStr = static_cast<LPWSTR>(std::malloc(nChars*sizeof(WCHAR)));
- OUString aDefPrt;
- if( GetDefaultPrinterW( pStr, &nChars ) )
- {
- aDefPrt = o3tl::toU(pStr);
- }
- std::free( pStr );
- if( !aDefPrt.isEmpty() )
- return aDefPrt;
- }
-
- // get default printer from win.ini
- wchar_t szBuffer[256];
- GetProfileStringW( aImplWindows, aImplDevice, L"", szBuffer, SAL_N_ELEMENTS( szBuffer ) );
- if ( szBuffer[0] )
- {
- // search for printer name
- wchar_t* pBuf = szBuffer;
- wchar_t* pTmp = pBuf;
- while ( *pTmp && (*pTmp != ',') )
- pTmp++;
- return OUString( o3tl::toU(pBuf), static_cast<sal_Int32>(pTmp-pBuf) );
+ std::vector<WCHAR> pStr(nChars);
+ if (GetDefaultPrinterW(pStr.data(), &nChars))
+ return OUString(o3tl::toU(pStr.data()));
}
- else
- return OUString();
+ return OUString();
}
static DWORD ImplDeviceCaps( WinSalInfoPrinter const * pPrinter, WORD nCaps,