---------------------------------------------------------------------------
| 863 | } |
| 864 | //--------------------------------------------------------------------------- |
| 865 | void __fastcall CreateShortcut(int where) |
| 866 | { |
| 867 | TWaitCursor wait; |
| 868 | String ShortcuteName = Application->Title; |
| 869 | String ShortcutFileName; |
| 870 | |
| 871 | try |
| 872 | { |
| 873 | char szLinkPath[MN]; |
| 874 | HRESULT hr = SHGetFolderPath(NULL, where, NULL, 0, szLinkPath); |
| 875 | if( FAILED(hr) ) |
| 876 | throw Exception(FormatLastError2(hr) + " [1:" + IntToStr(hr) + "]"); |
| 877 | |
| 878 | ShortcutFileName = String(szLinkPath) + "\\" + ShortcuteName + ".lnk"; |
| 879 | |
| 880 | hr = CreateLink(ApplicationExeName.c_str(), |
| 881 | "", |
| 882 | ShortcutFileName.c_str(), |
| 883 | "", |
| 884 | "tray"); |
| 885 | if( FAILED(hr) ) |
| 886 | throw Exception(FormatLastError2(hr) + " [2:" + IntToStr(hr) + "]"); |
| 887 | } |
| 888 | catch(const Exception & E) |
| 889 | { |
| 890 | ReportError2("Error creating shortcut \"%s\"\nApplication \"%s\"\nError: \"%s\"", |
| 891 | ShortcutFileName.c_str(), ApplicationExeName.c_str(), E.Message.c_str()); |
| 892 | } |
| 893 | catch(...) |
| 894 | { |
| 895 | ReportError2("Error creating shortcut \"%s\"\nApplication \"%s\"", |
| 896 | ShortcutFileName.c_str(), ApplicationExeName.c_str()); |
| 897 | } |
| 898 | } |
| 899 | //--------------------------------------------------------------------------- |
| 900 | void __fastcall DeleteShortcut(int where) |
| 901 | { |
no test coverage detected