Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

135 lines
3.5 KiB

//+---------------------------------------------------------------------------
//
// Microsoft Windows
// Copyright (C) Microsoft Corporation, 1993 - 2000.
//
// File: cpl.cpp
//
// Contents: Control Panel entry point (CPlApplet)
//
//----------------------------------------------------------------------------
#include "stdafx.h"
#include <regstr.h> // REGSTR_PATH_POLICIES
#include <lm.h> // NetGetJoinInformation
#include <cpl.h>
#include "resource.h"
const struct
{
LPCTSTR pszApp;
LPCTSTR pszCommand;
}
s_rgCommands[] =
{
{ TEXT("%SystemRoot%\\system32\\rundll32.exe"), TEXT("rundll32.exe \"%SystemRoot%\\system32\\netplwiz.dll\",UsersRunDll") },
{ TEXT("%SystemRoot%\\system32\\mshta.exe"), TEXT("mshta.exe \"res://%SystemRoot%\\system32\\nusrmgr.cpl/nusrmgr.hta\"") },
};
TCHAR const c_szPolicyKey[] = REGSTR_PATH_POLICIES TEXT("\\Explorer");
TCHAR const c_szPolicyVal[] = TEXT("UserPasswordsVer");
HRESULT StartUserManager(LPCTSTR pszParams)
{
TCHAR szApp[MAX_PATH];
TCHAR szCommand[MAX_PATH];
int iCommandIndex;
STARTUPINFO rgStartup = {0};
PROCESS_INFORMATION rgProcess = {0};
// Default is to use the old UI
iCommandIndex = 0;
#ifndef _WIN64
if (IsOS(OS_PERSONAL) || (IsOS(OS_PROFESSIONAL) && !IsOS(OS_DOMAINMEMBER)))
{
// Switch to the friendly UI.
iCommandIndex = 1;
}
#endif
DWORD cch = ExpandEnvironmentStrings(s_rgCommands[iCommandIndex].pszApp, szApp, ARRAYSIZE(szApp));
if (cch == 0 || cch > ARRAYSIZE(szApp))
{
return E_FAIL;
}
cch = ExpandEnvironmentStrings(s_rgCommands[iCommandIndex].pszCommand, szCommand, ARRAYSIZE(szCommand));
if (cch == 0 || cch > ARRAYSIZE(szCommand))
{
return E_FAIL;
}
if (pszParams && *pszParams != TEXT('\0'))
{
// ExpandEnvironmentStrings counts the last '\0'
// (we checked cch == 0 above)
cch--;
// Is there room for the params?
if (cch + sizeof(' ') + lstrlen(pszParams) < ARRAYSIZE(szCommand))
{
szCommand[cch++] = TEXT(' ');
lstrcpyn(&szCommand[cch], pszParams, ARRAYSIZE(szCommand)-cch);
}
// else launch without extra parameters
}
rgStartup.cb = sizeof(rgStartup);
rgStartup.wShowWindow = SW_SHOWNORMAL;
if (CreateProcess(szApp,
szCommand,
NULL,
NULL,
FALSE,
0,
NULL,
NULL,
&rgStartup,
&rgProcess))
{
WaitForInputIdle(rgProcess.hProcess, 10000);
CloseHandle(rgProcess.hProcess);
CloseHandle(rgProcess.hThread);
return S_OK;
}
return E_FAIL;
}
LONG APIENTRY CPlApplet(HWND hwnd, UINT Msg, LPARAM lParam1, LPARAM lParam2)
{
LPCPLINFO lpCplInfo;
switch (Msg)
{
case CPL_INIT:
return TRUE;
case CPL_GETCOUNT:
return 1;
case CPL_INQUIRE:
lpCplInfo = (LPCPLINFO)lParam2;
lpCplInfo->idIcon = IDI_CPLICON;
lpCplInfo->idName = IDS_NAME;
lpCplInfo->idInfo = IDS_INFO;
lpCplInfo->lData = 0;
break;
case CPL_DBLCLK:
StartUserManager(NULL);
return TRUE;
case CPL_STARTWPARMS:
StartUserManager((LPCTSTR)lParam2);
return TRUE;
}
return 0;
}