From 48e40467541a02db025f06530a2ed35013caf75a Mon Sep 17 00:00:00 2001 From: Austin Wagner Date: Sat, 30 Nov 2013 09:15:42 -0500 Subject: [PATCH] Add launcher Fixes bliker/cmder#39 Launcher replaces functionality of batch file to allow taskbar pinning --- launcher/.gitignore | 181 +++++++++++++++++++++++++++++++++ launcher/CmderLauncher.sln | 22 ++++ launcher/CmderLauncher.vcxproj | 98 ++++++++++++++++++ launcher/src/CmderLauncher.cpp | 60 +++++++++++ launcher/src/Resource.rc | Bin 0 -> 3292 bytes launcher/src/resource.h | Bin 0 -> 904 bytes 6 files changed, 361 insertions(+) create mode 100644 launcher/.gitignore create mode 100644 launcher/CmderLauncher.sln create mode 100644 launcher/CmderLauncher.vcxproj create mode 100644 launcher/src/CmderLauncher.cpp create mode 100644 launcher/src/Resource.rc create mode 100644 launcher/src/resource.h diff --git a/launcher/.gitignore b/launcher/.gitignore new file mode 100644 index 0000000..0036705 --- /dev/null +++ b/launcher/.gitignore @@ -0,0 +1,181 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. + +# User-specific files +*.suo +*.user +*.sln.docstates +*.filters + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +x64/ +build/ +bld/ +[Bb]in/ +[Oo]bj/ + +# Enable "build/" folder in the NuGet Packages folder since NuGet packages use it for MSBuild targets +!packages/*/build/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +#NUNIT +*.VisualState.xml +TestResult.xml + +*_i.c +*_p.c +*_i.h +*.ilk +*.meta +*.obj +*.pch +*.pdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opensdf +*.sdf +*.cachefile + +# Visual Studio profiler +*.psess +*.vsp +*.vspx + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# JustCode is a .NET coding addin-in +.JustCode + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# NCrunch +*.ncrunch* +_NCrunch_* +.*crunch*.local.xml + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.Publish.xml +*.azurePubxml + +# NuGet Packages Directory +## TODO: If you have NuGet Package Restore enabled, uncomment the next line +#packages/ +## TODO: If the tool you use requires repositories.config, also uncomment the next line +#!packages/repositories.config + +# Windows Azure Build Output +csx/ +*.build.csdef + +# Windows Store app package directory +AppPackages/ + +# Others +sql/ +*.Cache +ClientBin/ +[Ss]tyle[Cc]op.* +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.[Pp]ublish.xml +*.pfx +*.publishsettings + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file to a newer +# Visual Studio version. Backup files are not needed, because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm + +# SQL Server files +App_Data/*.mdf +App_Data/*.ldf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings + +# Microsoft Fakes +FakesAssemblies/ + +# ========================= +# Windows detritus +# ========================= + +# Windows image file caches +Thumbs.db +ehthumbs.db + +# Folder config file +Desktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ diff --git a/launcher/CmderLauncher.sln b/launcher/CmderLauncher.sln new file mode 100644 index 0000000..e4934d3 --- /dev/null +++ b/launcher/CmderLauncher.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2013 +VisualStudioVersion = 12.0.21005.1 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CmderLauncher", "CmderLauncher.vcxproj", "{4A8485A5-B7DD-4C44-B7F6-3E2765DD0CD3}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {4A8485A5-B7DD-4C44-B7F6-3E2765DD0CD3}.Debug|Win32.ActiveCfg = Debug|Win32 + {4A8485A5-B7DD-4C44-B7F6-3E2765DD0CD3}.Debug|Win32.Build.0 = Debug|Win32 + {4A8485A5-B7DD-4C44-B7F6-3E2765DD0CD3}.Release|Win32.ActiveCfg = Release|Win32 + {4A8485A5-B7DD-4C44-B7F6-3E2765DD0CD3}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/launcher/CmderLauncher.vcxproj b/launcher/CmderLauncher.vcxproj new file mode 100644 index 0000000..557e1ac --- /dev/null +++ b/launcher/CmderLauncher.vcxproj @@ -0,0 +1,98 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + {4A8485A5-B7DD-4C44-B7F6-3E2765DD0CD3} + Win32Proj + CmderLauncher + + + + Application + true + v120 + Unicode + + + Application + false + v120 + true + Unicode + + + + + + + + + + + + + true + Cmder + + + false + Cmder + + + + + + Level3 + Disabled + WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) + true + + + Windows + true + + + + + Level3 + + + MinSpace + true + false + WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) + true + Size + + + Windows + true + true + true + + + cp $(TargetPath) $(SolutionDir)..\$(TargetFileName) + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/launcher/src/CmderLauncher.cpp b/launcher/src/CmderLauncher.cpp new file mode 100644 index 0000000..9c77579 --- /dev/null +++ b/launcher/src/CmderLauncher.cpp @@ -0,0 +1,60 @@ +#include +#include +#include +#include "resource.h" + +#pragma comment(lib, "Shlwapi.lib") + +#define USE_TASKBAR_API (UNICODE && _WIN32_WINNT >= _WIN32_WINNT_WIN7) + +int APIENTRY _tWinMain(_In_ HINSTANCE hInstance, + _In_opt_ HINSTANCE hPrevInstance, + _In_ LPTSTR lpCmdLine, + _In_ int nCmdShow) +{ + UNREFERENCED_PARAMETER(hPrevInstance); + UNREFERENCED_PARAMETER(lpCmdLine); + UNREFERENCED_PARAMETER(nCmdShow); + +#if USE_TASKBAR_API + TCHAR appId[MAX_PATH] = { 0 }; +#endif + TCHAR exeDir[MAX_PATH] = { 0 }; + TCHAR icoPath[MAX_PATH] = { 0 }; + TCHAR cfgPath[MAX_PATH] = { 0 }; + TCHAR conEmuPath[MAX_PATH] = { 0 }; + TCHAR args[MAX_PATH * 2 + 256] = { 0 }; + + GetModuleFileName(NULL, exeDir, sizeof(exeDir)); + +#if USE_TASKBAR_API + _tcscpy_s(appId, exeDir); +#endif + + PathRemoveFileSpec(exeDir); + + PathCombine(icoPath, exeDir, _T("icons\\cmder.ico")); + PathCombine(cfgPath, exeDir, _T("config\\ConEmu.xml")); + PathCombine(conEmuPath, exeDir, _T("vendor\\conemu-maximus5\\ConEmu.exe")); + + _tcscat_s(args, _T("/Icon \"")); + _tcscat_s(args, icoPath); + _tcscat_s(args, _T("\" /Title Cmder /LoadCfgFile \"")); + _tcscat_s(args, cfgPath); + _tcscat_s(args, _T("\"")); + + SetEnvironmentVariable(_T("CMDER_ROOT"), exeDir); + + STARTUPINFO si = { 0 }; + si.cb = sizeof(STARTUPINFO); +#if USE_TASKBAR_API + si.lpTitle = appId; + si.dwFlags = STARTF_TITLEISAPPID; +#endif + + PROCESS_INFORMATION pi; + + CreateProcess(conEmuPath, args, NULL, NULL, false, 0, NULL, NULL, &si, &pi); + + return 0; +} \ No newline at end of file diff --git a/launcher/src/Resource.rc b/launcher/src/Resource.rc new file mode 100644 index 0000000000000000000000000000000000000000..42eec5860378de070e02e9b5f221d85728762c8d GIT binary patch literal 3292 zcmds(YmZVf5QgWoiT|O(7dIO4@(UJN@kAC4myISQWCNlk+`<8kiND?Td0V=B77iHE z4``Zmrk&2T)9K9Hx%pAHvN^l7u?=i#b4&R~wt{yBFSWH@+k{cop3t0qvX3_7Tf$#K zhwzqA>8jLvd>oV($Xw?xslh?+UNGp z+SakI)hw~M*0+{jz^&15TEjlTY4g9d3Y-T0xW8;Ty%w#D)L9+BZ2NeGm*zI*{42a8 zKXf?td;SThu5wQK;{yH*zU>?N^&Ncm{tbHf{eOBMix!3GSmP^2(ui{(7aP&@aoy9R z(K^TN&d9$BHMzQ5ABkP5yMr zt|~kCiLM4s>wc%Xy_y}?Xc5DGw3_Ij`CS`un{d0(x{uSy337GTPRP~Q_LQ~T$W`D3 zoo$IevmvWP1n4aLBS86a#Yx_w#N6B06CIot676dU>Qpzq?P-2ceBplqTVA1D$NAZ(kZRiDZNG@nXx`9WuvA4$gan`Qz(oK<3Rgt0@>`ocW61}6c zM><+{LQ{3}Z8JNChPP1`Cty~UxgqRJP%xyCOt!N# znLTr6PQN~zYU&+})mN%Op{_Zxzs2gPOEl02cB~_6n{tXYRi>pDDmb}TM#VWsvhf&nuN%Dl^|ul*8GN%`G!X` zEbHgs9dJ^ZM1Gcp+#%M|nOeTXri)`M6TSLrjd{*YCCqL5XFqpIwjj!3y2Klk7yLqF zJ#o*dEq+)#e`~-vUvqbAv;Bc?H1zCEkuF_FXmf=Q!Pbj;&6|YUHr0LJ_H+lzfN!Kr zGCl75_LZ)Cr@RSu3x|}goA!O!B!rF8TYH^(|KsKw? q_^b0i-i97CLE`7FW9>ja47=K-X;F`B+xh*68mMoInby_zcjIq^UwxGT literal 0 HcmV?d00001