|
38 | 38 | #include <shlwapi.h>
|
39 | 39 | #endif
|
40 | 40 |
|
41 |
| -#include <boost/scoped_array.hpp> |
42 |
| - |
43 | 41 | #include <QAbstractItemView>
|
44 | 42 | #include <QApplication>
|
45 | 43 | #include <QClipboard>
|
@@ -548,52 +546,37 @@ bool SetStartOnSystemStartup(bool fAutoStart)
|
548 | 546 | CoInitialize(nullptr);
|
549 | 547 |
|
550 | 548 | // Get a pointer to the IShellLink interface.
|
551 |
| - IShellLink* psl = nullptr; |
| 549 | + IShellLinkW* psl = nullptr; |
552 | 550 | HRESULT hres = CoCreateInstance(CLSID_ShellLink, nullptr,
|
553 |
| - CLSCTX_INPROC_SERVER, IID_IShellLink, |
| 551 | + CLSCTX_INPROC_SERVER, IID_IShellLinkW, |
554 | 552 | reinterpret_cast<void**>(&psl));
|
555 | 553 |
|
556 | 554 | if (SUCCEEDED(hres))
|
557 | 555 | {
|
558 | 556 | // Get the current executable path
|
559 |
| - TCHAR pszExePath[MAX_PATH]; |
560 |
| - GetModuleFileName(nullptr, pszExePath, sizeof(pszExePath)); |
| 557 | + WCHAR pszExePath[MAX_PATH]; |
| 558 | + GetModuleFileNameW(nullptr, pszExePath, ARRAYSIZE(pszExePath)); |
561 | 559 |
|
562 | 560 | // Start client minimized
|
563 | 561 | QString strArgs = "-min";
|
564 | 562 | // Set -testnet /-regtest options
|
565 | 563 | strArgs += QString::fromStdString(strprintf(" -testnet=%d -regtest=%d", gArgs.GetBoolArg("-testnet", false), gArgs.GetBoolArg("-regtest", false)));
|
566 | 564 |
|
567 |
| -#ifdef UNICODE |
568 |
| - boost::scoped_array<TCHAR> args(new TCHAR[strArgs.length() + 1]); |
569 |
| - // Convert the QString to TCHAR* |
570 |
| - strArgs.toWCharArray(args.get()); |
571 |
| - // Add missing '\0'-termination to string |
572 |
| - args[strArgs.length()] = '\0'; |
573 |
| -#endif |
574 |
| - |
575 | 565 | // Set the path to the shortcut target
|
576 | 566 | psl->SetPath(pszExePath);
|
577 |
| - PathRemoveFileSpec(pszExePath); |
| 567 | + PathRemoveFileSpecW(pszExePath); |
578 | 568 | psl->SetWorkingDirectory(pszExePath);
|
579 | 569 | psl->SetShowCmd(SW_SHOWMINNOACTIVE);
|
580 |
| -#ifndef UNICODE |
581 |
| - psl->SetArguments(strArgs.toStdString().c_str()); |
582 |
| -#else |
583 |
| - psl->SetArguments(args.get()); |
584 |
| -#endif |
| 570 | + psl->SetArguments(strArgs.toStdWString().c_str()); |
585 | 571 |
|
586 | 572 | // Query IShellLink for the IPersistFile interface for
|
587 | 573 | // saving the shortcut in persistent storage.
|
588 | 574 | IPersistFile* ppf = nullptr;
|
589 | 575 | hres = psl->QueryInterface(IID_IPersistFile, reinterpret_cast<void**>(&ppf));
|
590 | 576 | if (SUCCEEDED(hres))
|
591 | 577 | {
|
592 |
| - WCHAR pwsz[MAX_PATH]; |
593 |
| - // Ensure that the string is ANSI. |
594 |
| - MultiByteToWideChar(CP_ACP, 0, StartupShortcutPath().string().c_str(), -1, pwsz, MAX_PATH); |
595 | 578 | // Save the link by calling IPersistFile::Save.
|
596 |
| - hres = ppf->Save(pwsz, TRUE); |
| 579 | + hres = ppf->Save(StartupShortcutPath().wstring().c_str(), TRUE); |
597 | 580 | ppf->Release();
|
598 | 581 | psl->Release();
|
599 | 582 | CoUninitialize();
|
|
0 commit comments