MCPcopy Create free account
hub / github.com/DiscordMessenger/dm / LaunchURL

Function LaunchURL

src/windows/WinUtils.cpp:782–821  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

780}
781
782void LaunchURL(const std::string& link)
783{
784 LPTSTR tstr = ConvertCppStringToTString(link);
785 INT_PTR res = (INT_PTR) ShellExecute(g_Hwnd, TEXT("open"), tstr, NULL, NULL, SW_SHOWNORMAL);
786
787 if (res > 32) {
788 free(tstr);
789 return; // was fine
790 }
791
792 LPCTSTR errorCode = NULL;
793 TCHAR buff[4096];
794 switch (res)
795 {
796 case 0:
797 case SE_ERR_OOM:
798 errorCode = TEXT("Out of memory");
799 break;
800
801 case SE_ERR_FNF:
802 errorCode = TEXT("File not found");
803 break;
804
805 case SE_ERR_PNF:
806 errorCode = TEXT("Path not found");
807 break;
808
809 case SE_ERR_ACCESSDENIED:
810 errorCode = TEXT("Access denied");
811 break;
812 }
813
814 if (errorCode)
815 WAsnprintf(buff, _countof(buff), TmGetTString(IDS_CANT_LAUNCH_URL_UNS), tstr, errorCode);
816 else
817 WAsnprintf(buff, _countof(buff), TmGetTString(IDS_CANT_LAUNCH_URL_ERR), tstr, res, res);
818
819 free(tstr);
820 MessageBox(g_Hwnd, buff, TmGetTString(IDS_PROGRAM_NAME), MB_ICONERROR | MB_OK);
821}
822
823bool IsChildOf(HWND child, HWND of)
824{

Callers 1

LaunchURLMethod · 0.85

Calls 1

Tested by

no test coverage detected