From 0a8c4b149bd0735a32fa67b99f7ce941f8d9ea34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9=20van=20Geldorp?= Date: Wed, 14 Jan 2004 23:17:50 +0000 Subject: [PATCH] Add creation of command prompt shortcut on desktop svn path=/trunk/; revision=7631 --- reactos/subsys/system/setup/makefile | 6 ++- reactos/subsys/system/setup/setup.c | 74 ++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+), 2 deletions(-) diff --git a/reactos/subsys/system/setup/makefile b/reactos/subsys/system/setup/makefile index a1907a04a8e..4ced8d09de4 100644 --- a/reactos/subsys/system/setup/makefile +++ b/reactos/subsys/system/setup/makefile @@ -1,4 +1,4 @@ -# $Id: makefile,v 1.2 2003/11/14 17:13:33 weiden Exp $ +# $Id: makefile,v 1.3 2004/01/14 23:17:50 gvg Exp $ PATH_TO_TOP = ../../.. @@ -12,7 +12,9 @@ TARGET_INSTALLDIR = system32 TARGET_SDKLIBS = kernel32.a -TARGET_CFLAGS = -DUNICODE -Wall -Werror +TARGET_GCCLIBS = ole32 uuid shell32 shlwapi + +TARGET_CFLAGS = -Wall -Werror -D__USE_W32API -D_WIN32_IE=0x0400 TARGET_LFLAGS = diff --git a/reactos/subsys/system/setup/setup.c b/reactos/subsys/system/setup/setup.c index e41b87909c4..ca4fabb41a7 100644 --- a/reactos/subsys/system/setup/setup.c +++ b/reactos/subsys/system/setup/setup.c @@ -29,6 +29,10 @@ #include +#include +#include +#include + #define DEBUG typedef DWORD STDCALL (*PINSTALL_REACTOS)(HINSTANCE hInstance); @@ -53,6 +57,74 @@ LPTSTR lstrchr(LPCTSTR s, TCHAR c) } +HRESULT CreateShellLink(LPCSTR linkPath, LPCSTR cmd, LPCSTR arg, LPCSTR dir, LPCSTR iconPath, int icon_nr, LPCSTR comment) +{ + IShellLinkA* psl; + IPersistFile* ppf; + WCHAR buffer[MAX_PATH]; + + HRESULT hr = CoCreateInstance(&CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, &IID_IShellLink, (LPVOID*)&psl); + + if (SUCCEEDED(hr)) + { + hr = psl->lpVtbl->SetPath(psl, cmd); + + if (arg) + { + hr = psl->lpVtbl->SetArguments(psl, arg); + } + + if (dir) + { + hr = psl->lpVtbl->SetWorkingDirectory(psl, dir); + } + + if (iconPath) + { + hr = psl->lpVtbl->SetIconLocation(psl, iconPath, icon_nr); + } + + if (comment) + { + hr = psl->lpVtbl->SetDescription(psl, comment); + } + + hr = psl->lpVtbl->QueryInterface(psl, &IID_IPersistFile, (LPVOID*)&ppf); + + if (SUCCEEDED(hr)) + { + MultiByteToWideChar(CP_ACP, 0, linkPath, -1, buffer, MAX_PATH); + + hr = ppf->lpVtbl->Save(ppf, buffer, TRUE); + + ppf->lpVtbl->Release(ppf); + } + + psl->lpVtbl->Release(psl); + } + + return hr; +} + + +static VOID +CreateCmdLink() +{ + char path[MAX_PATH]; + LPSTR p; + + CoInitialize(NULL); + + SHGetSpecialFolderPathA(0, path, CSIDL_DESKTOP, TRUE); + p = PathAddBackslashA(path); + + strcpy(p, "Command Prompt.lnk"); + CreateShellLink(path, "cmd.exe", "", NULL, NULL, 0, "Open command prompt"); + + CoUninitialize(); +} + + static VOID RunNewSetup (HINSTANCE hInstance) { @@ -85,6 +157,8 @@ RunNewSetup (HINSTANCE hInstance) InstallReactOS (hInstance); FreeLibrary (hDll); + + CreateCmdLink(); }