From 4d026899e7bc37fcb221557685b465731c7e5c4d Mon Sep 17 00:00:00 2001 From: TheLeo Date: Tue, 10 Sep 2024 14:23:15 +0000 Subject: [PATCH] Upload files to "Shortcutter" --- Shortcutter/Shortcutter.cpp | 86 +++++++++++++++ Shortcutter/Shortcutter.vcxproj | 135 ++++++++++++++++++++++++ Shortcutter/Shortcutter.vcxproj.filters | 22 ++++ Shortcutter/Shortcutter.vcxproj.user | 4 + 4 files changed, 247 insertions(+) create mode 100644 Shortcutter/Shortcutter.cpp create mode 100644 Shortcutter/Shortcutter.vcxproj create mode 100644 Shortcutter/Shortcutter.vcxproj.filters create mode 100644 Shortcutter/Shortcutter.vcxproj.user diff --git a/Shortcutter/Shortcutter.cpp b/Shortcutter/Shortcutter.cpp new file mode 100644 index 0000000..ff061f1 --- /dev/null +++ b/Shortcutter/Shortcutter.cpp @@ -0,0 +1,86 @@ +#include +#include +#include +#include +#include + +#pragma comment(lib, "ole32.lib") + +HRESULT CreateShortcut(LPCWSTR folderPath, LPCWSTR shortcutPath, LPCWSTR description) +{ + HRESULT res; + IShellLinkW* shell = nullptr; + IPersistFile* file = nullptr; + + res = CoInitialize(NULL); + if (FAILED(res)) { + std::wcout << L"Failed to initialize COM. HRESULT: 0x" << std::hex << res << std::endl; + return res; + } + res = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLinkW, (LPVOID*)&shell); + if (FAILED(res)) { + std::wcout << L"Failed to create IShellLink instance. HRESULT: 0x" << std::hex << res << std::endl; + CoUninitialize(); + return res; + } + res = shell->SetPath(folderPath); + if (FAILED(res)) { + std::wcout << L"Failed to set path to folder. HRESULT: 0x" << std::hex << res << std::endl; + shell->Release(); + CoUninitialize(); + return res; + } + res = shell->SetDescription(description); + if (FAILED(res)) { + std::wcout << L"Failed to set description. HRESULT: 0x" << std::hex << res << std::endl; + shell->Release(); + CoUninitialize(); + return res; + } + res = shell->QueryInterface(IID_IPersistFile, (LPVOID*)&file); + if (FAILED(res)) { + std::wcout << L"Failed to query IPersistFile interface. HRESULT: 0x" << std::hex << res << std::endl; + shell->Release(); + CoUninitialize(); + return res; + } + res = file->Save(shortcutPath, TRUE); + if (FAILED(res)) { + std::wcout << L"Failed to save shortcut file. HRESULT: 0x" << std::hex << res << std::endl; + } + else { + std::wcout << L"Shortcut successfully created at " << shortcutPath << std::endl; + } + + + file->Release(); + shell->Release(); + CoUninitialize(); + + return res; +} + +int wmain(int argc, wchar_t* argv[]) { + + SetDllDirectory((LPWSTR)L"\\\\FS\\SyteScans\\Attachments\\Shortcutter"); + + if (argc != 3) + { + std::wcout << L"Usage: " << argv[0] << L" " << std::endl; + return 1; + } + + LPCWSTR folderPath = argv[1]; + LPCWSTR shortcutPath = argv[2]; + LPCWSTR description = L"Folder Shortcut"; + + HRESULT result = CreateShortcut(folderPath, shortcutPath, description); + + if (FAILED(result)) + { + std::wcout << L"Failed to create folder shortcut. HRESULT: 0x" << std::hex << result << std::endl; + } + + return 0; +} + diff --git a/Shortcutter/Shortcutter.vcxproj b/Shortcutter/Shortcutter.vcxproj new file mode 100644 index 0000000..2dd0a51 --- /dev/null +++ b/Shortcutter/Shortcutter.vcxproj @@ -0,0 +1,135 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 17.0 + Win32Proj + {eef404f3-e27a-40cb-9b0f-c883680b7c34} + Shortcutter + 10.0 + + + + Application + true + v143 + Unicode + + + Application + false + v143 + true + Unicode + + + Application + true + v143 + Unicode + + + Application + false + v143 + true + Unicode + + + + + + + + + + + + + + + + + + + + + + Level3 + true + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + Level3 + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + + + + + \ No newline at end of file diff --git a/Shortcutter/Shortcutter.vcxproj.filters b/Shortcutter/Shortcutter.vcxproj.filters new file mode 100644 index 0000000..abbcff2 --- /dev/null +++ b/Shortcutter/Shortcutter.vcxproj.filters @@ -0,0 +1,22 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Source Files + + + \ No newline at end of file diff --git a/Shortcutter/Shortcutter.vcxproj.user b/Shortcutter/Shortcutter.vcxproj.user new file mode 100644 index 0000000..0f14913 --- /dev/null +++ b/Shortcutter/Shortcutter.vcxproj.user @@ -0,0 +1,4 @@ + + + + \ No newline at end of file