Move 'Command Prompt' link creation from setup.exe to syssetup.dll.

svn path=/trunk/; revision=12381
This commit is contained in:
Eric Kohl 2004-12-28 14:41:46 +00:00
parent 9af695bf7b
commit 1b7ee37237
4 changed files with 90 additions and 101 deletions

View file

@ -1,4 +1,4 @@
# $Id: Makefile,v 1.13 2004/11/22 11:01:45 gvg Exp $
# $Id: Makefile,v 1.14 2004/12/28 14:41:46 ekohl Exp $
PATH_TO_TOP = ../..
@ -9,7 +9,9 @@ TARGET_NAME = syssetup
TARGET_BASE = $(TARGET_BASE_LIB_SYSSETUP)
TARGET_SDKLIBS = ntdll.a kernel32.a advapi32.a gdi32.a user32.a samlib.a userenv.a \
comctl32.a setupapi.a
comctl32.a setupapi.a ole32.a shell32.a shlwapi.a
TARGET_GCCLIBS = uuid
TARGET_CFLAGS = -Wall -Werror -fno-builtin

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* $Id: install.c,v 1.20 2004/11/24 23:09:46 ekohl Exp $
/* $Id: install.c,v 1.21 2004/12/28 14:41:46 ekohl Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
@ -39,13 +39,15 @@
#include <userenv.h>
#include <setupapi.h>
#include <shlobj.h>
#include <objidl.h>
#include <shlwapi.h>
#include "globals.h"
#include "resource.h"
#define VMWINST
VOID WINAPI CreateCmdLink(VOID);
/* GLOBALS ******************************************************************/
@ -97,6 +99,74 @@ RunVMWInstall(VOID)
#endif
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(VOID)
{
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
CreateRandomSid (PSID *Sid)
{
@ -320,6 +390,8 @@ InstallReactOS (HINSTANCE hInstance)
return 0;
}
CreateCmdLink();
/* Create the semi-random Domain-SID */
CreateRandomSid (&DomainSid);
if (DomainSid == NULL)
@ -368,7 +440,8 @@ InstallReactOS (HINSTANCE hInstance)
* and not completing it, let it restart instead
*/
LastError = GetLastError();
if (LastError != ERROR_USER_EXISTS) {
if (LastError != ERROR_USER_EXISTS)
{
DebugPrint("SamCreateUser() failed!\n");
RtlFreeSid(AdminSid);
RtlFreeSid(DomainSid);

View file

@ -1,4 +1,4 @@
# $Id: makefile,v 1.4 2004/08/18 02:16:00 navaraf Exp $
# $Id: makefile,v 1.5 2004/12/28 14:40:33 ekohl Exp $
PATH_TO_TOP = ../../..
@ -10,9 +10,7 @@ TARGET_NAME = setup
TARGET_INSTALLDIR = system32
TARGET_SDKLIBS = kernel32.a ole32.a shell32.a shlwapi.a
TARGET_GCCLIBS = uuid
TARGET_SDKLIBS = kernel32.a
TARGET_CFLAGS = -Wall -Werror -D__USE_W32API -D_WIN32_IE=0x0400

View file

@ -26,27 +26,23 @@
#include <windows.h>
#include <tchar.h>
#include <syssetup.h>
#include <shlobj.h>
#include <objidl.h>
#include <shlwapi.h>
#define NDEBUG
#include <debug.h>
#define DEBUG
typedef DWORD STDCALL (*PINSTALL_REACTOS)(HINSTANCE hInstance);
/* FUNCTIONS ****************************************************************/
LPTSTR lstrchr(LPCTSTR s, TCHAR c)
{
while (*s)
{
if (*s == c)
return (LPTSTR)s;
return (LPTSTR)s;
s++;
}
@ -57,74 +53,6 @@ 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)
{
@ -134,22 +62,16 @@ RunNewSetup (HINSTANCE hInstance)
hDll = LoadLibrary (TEXT("syssetup"));
if (hDll == NULL)
{
#ifdef DEBUG
OutputDebugString (TEXT("Failed to load 'syssetup'!\n"));
#endif
DPRINT("Failed to load 'syssetup'!\n");
return;
}
#ifdef DEBUG
OutputDebugString (TEXT("Loaded 'syssetup'!\n"));
#endif
DPRINT("Loaded 'syssetup'!\n");
InstallReactOS = (PINSTALL_REACTOS)GetProcAddress (hDll, "InstallReactOS");
if (InstallReactOS == NULL)
{
#ifdef DEBUG
OutputDebugString (TEXT("Failed to get address for 'InstallReactOS()'!\n"));
#endif
DPRINT("Failed to get address for 'InstallReactOS()'!\n");
FreeLibrary (hDll);
return;
}
@ -157,8 +79,6 @@ RunNewSetup (HINSTANCE hInstance)
InstallReactOS (hInstance);
FreeLibrary (hDll);
CreateCmdLink();
}
@ -173,11 +93,7 @@ WinMain (HINSTANCE hInstance,
CmdLine = GetCommandLine ();
#ifdef DEBUG
OutputDebugString (TEXT("CmdLine: <"));
OutputDebugString (CmdLine);
OutputDebugString (TEXT(">\n"));
#endif
DPRINT("CmdLine: <%s>\n",CmdLine);
p = lstrchr (CmdLine, TEXT('-'));
if (p == NULL)