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