//*****************************************************************************
//
// Systems Management Server SDK
// Copyright (C) Microsoft Corporation. All rights reserved.
//
// FileName: Programs.cs
//
//*****************************************************************************
using System;
using System.Collections;
using System.Collections.Specialized;
using System.Management;
namespace Microsoft.SystemsManagementServer.Automation
{
///
/// This class manages all of the programs in a package. You can access the programs of a package via the
/// .Programs property on an SMSPackage instance.
///
public class SMSPrograms : IEnumerable
{
// Internal properties
private SMSProvider m_oProvider = null;
private SMSPackage m_oPackage = null;
// **********************************************************************
// Constructor
// **********************************************************************
internal SMSPrograms(SMSProvider oProvider, SMSPackage oPackage)
{
m_oProvider = oProvider;
m_oPackage = oPackage;
}
///
/// Creates a new program on the package.
///
/// Unique user-friendly name of the program to be created.
/// Command Line for the program to be created.
/// The SMSProgram instance for the new program.
public SMSProgram Create(string sProgramName, string sCommandLine)
{
// Create a new SMSProgram instance
return new SMSProgram(m_oProvider, m_oPackage, sProgramName, sCommandLine);
}
///
/// Gets a SMSProgram instance from the known Program Name.
///
/// Name of the program to get.
/// SMSPackage instance for the given Program Name.
public SMSProgram Get(string sProgramName)
{
// Re-get the full package
string sRelPath = "SMS_Program.PackageID=\"" + m_oPackage.PackageID + "\",ProgramName=\"" + sProgramName + "\"";
ManagementObject oProgram = m_oProvider.Connection.GetObject(sRelPath, m_oProvider.Context);
return new SMSProgram(m_oProvider, m_oPackage, oProgram);
}
///
/// Deletes a specified program.
///
/// The program to be deleted.
public void Delete(SMSProgram oProgram)
{
oProgram.Delete();
}
///
/// SMSProgram enumerator.
///
/// Returns an enumeration of all the programs in a package.
public IEnumerator GetEnumerator()
{
// Create an ArrayList of all the Programs on this site
ArrayList alPrograms = new ArrayList();
// Query the Programs for this package
ManagementObjectCollection oQueryResults =
m_oProvider.Connection.ExecuteQuery("SELECT * FROM SMS_Program WHERE PackageID=\"" + m_oPackage.PackageID + "\"");
foreach(ManagementObject oLoopProgram in oQueryResults)
{
// Re-get the full program
string sRelPath = oLoopProgram.Path.RelativePath;
ManagementObject oProgram = m_oProvider.Connection.GetObject(sRelPath, m_oProvider.Context);
alPrograms.Add(new SMSProgram(m_oProvider, m_oPackage, oProgram));
}
// Return the arraylist of programs
return alPrograms.GetEnumerator();
}
}
///
/// This class represents a program in a package on an SMS site server. The methods and properties of this class can be used to configure
/// the program. After making any changes to the program settings, you must call Save() to commit the changes.
///
public class SMSProgram
{
// Internal properties
private SMSProvider m_oProvider = null;
private SMSPackage m_oPackage = null;
private string m_sProgramName;
private string m_sRemovalKey;
private SMSSupportedPlatformCollection m_cSupportedPlatforms = new SMSSupportedPlatformCollection();
private bool m_bShowInARP = false;
// Public Properties (read-only)
// --------------------------------------
/// The provider where this program lives.
public SMSProvider Provider { get {return m_oProvider;} }
/// The package that owns this program.
public SMSPackage OwnerPackage { get {return m_oPackage;} }
/// The user-friendly name that uniquely identifies this program.
public string ProgramName { get {return m_sProgramName;} }
// Public Properties
// --------------------------------------
/// (Reserved for advanced use only).
public Int32 ProgramFlags;
/// Command to execute when the program is launched.
public string CommandLine;
/// Description of the program displayed in the SMS Administrator console.
public string Comment;
/// Defines the location from which the program executes. This can be an absolute path on the client or a
/// path relative to the distribution point folder that contains the package.
public string WorkingDirectory;
/// Description of the program.
public string Description;
/// Approximate disk space that the program requires. The format is "[size] [KB|MB|GB]".
public string DiskSpaceReq;
/// Approximate time, in minutes, that the program executes.
public Int32 Duration;
/// Description of any additional requirements of the program.
public string Requirements;
/// Drive letter (one character in the range a–z) that the program maps to and runs from when it is executed.
/// The DriveMode property must be set to DriveModes.MappedDrive in order for this drive letter to take effect.
public string DriveLetter;
/// Windows Installer File path for enabling installation source management of the product.
public string MSIFilePath;
/// Windows Installer Product Code.
public string MSIProductID;
/// (Reserved for advanced use only).
public string ApplicationHierarchy;
/// (Reserved for advanced use only).
public Int32 DeviceFlags;
/// (Reserved for advanced use only).
public byte[] ISVData;
/// (Reserved for advanced use only).
public Int32 ISVDataSize;
/// A program that should run prior to executing the current program.
/// Set this to null if you do not want a dependent program.
public SMSProgram DependentProgram;
/// A collection of operating systems and platforms that this program supports. (These values are ignored unless the RunOnAnyPlatform is set to false).
public SMSSupportedPlatformCollection SupportedOperatingSystems {get{return m_cSupportedPlatforms;}}
// **********************************************************************
// Program Flag Accessors
// **********************************************************************
/// Gets and sets the "Display this program in Add/Remove Programs" flag.
public bool DisplayInARP
{
get { return m_bShowInARP; }
set { m_bShowInARP = value; }
}
/// Gets and sets the "This program can run on any platform" flag.
public bool RunOnAnyPlatform
{
get { return (ProgramFlags & AP_ANY_PLATFORM) > 0; }
set { if(value == true) ProgramFlags |= AP_ANY_PLATFORM; else ProgramFlags &= ~AP_ANY_PLATFORM;}
}
///
/// Gets and sets the "Run with administrative rights" flag.
/// If this property is set to true, the following properties should be changed accordingly:
/// "ReconnectToDPAtLogon = false"
/// If this property is set to false, the following properties should be changed accordingly:
/// "UserRequirements = OnlyRunWhenUserLoggedOn",
/// "UseSoftwareInstallationAccount = false",
/// "AllowUserToInteractWithProgram = false".
///
public bool RunWithAdminRights
{
get { return (ProgramFlags & AP_ADV_RIGHTS) > 0; }
set { if(value == true) ProgramFlags |= AP_ADV_RIGHTS; else ProgramFlags &= ~AP_ADV_RIGHTS; }
}
/// Gets and Sets the "Use Software Installation Account" flag.
/// If this property is set to true, the following properties should be changed accordingly:
/// "RunWithAdminRights = true", "UserRequirements = RunWhetherLoggedOnOrOff or OnlyRunWhenUserLoggedOff".
///
public bool UseSoftwareInstallationAccount
{
get { return (ProgramFlags & AP_RUN_ACCOUNT) > 0; }
set
{
if(value == true)
ProgramFlags |= AP_RUN_ACCOUNT;
else
ProgramFlags &= ~AP_RUN_ACCOUNT;}
}
///
/// Gets and sets the "Allow users to interact with this program" flag.
/// If this property is set to true, the the following properties should be changed accordingly:
/// "RunWithAdminRights = true", "UserRequirements = RunWhetherLoggedOnOrOff or OnlyRunWhenUserLoggedOn".
///
public bool AllowUserToInteractWithProgram
{
get { return (ProgramFlags & AP_UNATTENDED) == 0; }
set
{
if(value == false)
ProgramFlags |= AP_UNATTENDED;
else
ProgramFlags &= ~AP_UNATTENDED;
}
}
/// Gets and sets the "Reconnect to distribution point at logon" flag.
/// If this property is set to true, the following properties should be changed accordingly:
/// "RunWithAdminRights = false".
///
public bool ReconnectToDPAtLogon
{
get { return (ProgramFlags & AP_PERSISTENT) > 0; }
set
{
if(value == true)
ProgramFlags |= AP_PERSISTENT;
else
ProgramFlags &= ~AP_PERSISTENT;
}
}
/// Gets and sets the "run this other program every time" flag.
public bool AlwaysRunDependentProgram
{
get { return (ProgramFlags & AP_RUN_DEPENDENT_ALWAYS) > 0; }
set { if(value == true) ProgramFlags |= AP_RUN_DEPENDENT_ALWAYS; else ProgramFlags &= ~AP_RUN_DEPENDENT_ALWAYS;}
}
/// Gets and sets the "Suppress program notifications" flag.
public bool SuppressProgramNotification
{
get { return (ProgramFlags & AP_SUPPRESS_COUNTDOWN) > 0; }
set { if(value == true) ProgramFlags |= AP_SUPPRESS_COUNTDOWN; else ProgramFlags &= ~AP_SUPPRESS_COUNTDOWN;}
}
/// Gets and sets the "Disable this program on computers where it is advertised" flag (true=Enabled, false=Disabled).
public bool ProgramEnabled
{
get { return (ProgramFlags & AP_DISABLED) == 0; }
set { if(value == false) ProgramFlags |= AP_DISABLED; else ProgramFlags &= ~AP_DISABLED;}
}
/// Gets and sets the drive mode type for this program.
public DriveModes DriveMode
{
get { if((ProgramFlags & AP_UNC_PATH) > 0) return DriveModes.UNC; return DriveModes.MappedDrive; }
set { if(value == DriveModes.UNC) ProgramFlags |= AP_UNC_PATH; else ProgramFlags &= ~AP_UNC_PATH;}
}
/// Gets and sets how the program window should be displayed when first executed.
public ProgramRunModes RunMode
{
get
{
if((ProgramFlags & AP_MINIMIZED) > 0) return ProgramRunModes.Minimized;
if((ProgramFlags & AP_MAXIMIZED) > 0) return ProgramRunModes.Maximized;
if((ProgramFlags & AP_HIDE_WINDOW) > 0) return ProgramRunModes.Hidden;
return ProgramRunModes.Normal;
}
set
{
ProgramFlags &= c_RunWindowMask; // Cut out all the run window flags
switch(value)
{
case ProgramRunModes.Normal: /* Do nothing */ break;
case ProgramRunModes.Minimized: ProgramFlags |= AP_MINIMIZED; break;
case ProgramRunModes.Maximized: ProgramFlags |= AP_MAXIMIZED; break;
case ProgramRunModes.Hidden: ProgramFlags |= AP_HIDE_WINDOW; break;
}
}
}
///
/// Gets and sets the user requirements for when the program can run.
/// If this property is set to OnlyRunWhenUserLoggedOn, the following properties should be changed accordingly:
/// "UseSoftwareInstallationAccount = false".
/// If this property is set to OnlyRunWhenUserLoggedOff, the following properties should be changed accordingly:
/// "RunWithAdminRights = true",
/// "UserInputRequired = false",
/// "WhenAssignedToComputer = RunOnce".
/// If this property is set to RunWhetherLoggedOnOrOff, the following properties should be changed accordingly:
/// "RunWithAdminRights = true",
/// "WhenAssignedToComputer = RunOnce".
///
public UserRequirementsFlags UserRequirements
{
get
{
if((ProgramFlags & AP_USER_CONTEXT) > 0) return UserRequirementsFlags.OnlyRunWhenUserLoggedOn;
if((ProgramFlags & AP_NO_USER) > 0) return UserRequirementsFlags.OnlyRunWhenUserLoggedOff;
return UserRequirementsFlags.RunWhetherLoggedOnOrOff;
}
set
{
ProgramFlags &= c_ProgramCanRunMask; // Cut out all the appropriate flags
switch(value)
{
// ---------------------------------------------------------
case UserRequirementsFlags.RunWhetherLoggedOnOrOff:
{
// Do Nothing
} break;
// ---------------------------------------------------------
case UserRequirementsFlags.OnlyRunWhenUserLoggedOn:
{
ProgramFlags |= AP_USER_CONTEXT;
} break;
// ---------------------------------------------------------
case UserRequirementsFlags.OnlyRunWhenUserLoggedOff:
{
ProgramFlags |= AP_NO_USER;
} break;
}
}
}
/// Gets and sets the flag for what action will be taken after the program finished running.
public ProgramAfterRunningFlags AfterRunningFlag
{
get
{
if((ProgramFlags & AP_OK_REBOOT) > 0) return ProgramAfterRunningFlags.SMSReboots;
if((ProgramFlags & AP_OK_TO_QUIT) > 0) return ProgramAfterRunningFlags.ProgramReboots;
if((ProgramFlags & AP_OK_LOGOFF) > 0) return ProgramAfterRunningFlags.SMSLogsOff;
return ProgramAfterRunningFlags.NoAction;
}
set
{
ProgramFlags &= c_AfterRunningMask; // Cut out all the run window flags
switch(value)
{
case ProgramAfterRunningFlags.NoAction: /* Do nothing */ break;
case ProgramAfterRunningFlags.ProgramReboots: ProgramFlags |= AP_OK_TO_QUIT; break;
case ProgramAfterRunningFlags.SMSLogsOff: ProgramFlags |= AP_OK_LOGOFF; break;
case ProgramAfterRunningFlags.SMSReboots: ProgramFlags |= AP_OK_REBOOT; break;
}
}
}
///
/// Gets and sets the option for "When this program is assigned to a computer"
/// If this property is set to RunForEveryUser, the following properties should be changed accordingly:
/// "UserRequirements = OnlyRunWhenUserLoggedOn".
///
public ProgramRunAssignments WhenAssignedToComputer
{
get { if((ProgramFlags & AP_EVERY_USER) > 0) return ProgramRunAssignments.RunForEveryUser; return ProgramRunAssignments.RunOnce; }
set
{
if(value == ProgramRunAssignments.RunForEveryUser)
{
ProgramFlags |= AP_EVERY_USER;
// Set "UserRequirements = OnlyRunWhenUserLoggedOn"
if(UserRequirements != UserRequirementsFlags.OnlyRunWhenUserLoggedOn)
UserRequirements = UserRequirementsFlags.OnlyRunWhenUserLoggedOn;
}
else
ProgramFlags &= ~AP_EVERY_USER;
}
}
/// Gets and sets the registry key that identifies the uninstall script for this program. The script must reside in the HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall registry path. Specify an empty string to disable uninstall
public string RemovalKey
{
get {return m_sRemovalKey;}
set
{
m_sRemovalKey = value;
if(m_sRemovalKey.Length > 0)
ProgramFlags |= AP_SUPPORT_UNINSTALL;
else
ProgramFlags &= ~AP_SUPPORT_UNINSTALL;
}
}
// **********************************************************************
// Constructor - Create a new program
// **********************************************************************
internal SMSProgram(SMSProvider oProvider, SMSPackage oPackage, string sProgramName, string sCommandLine)
{
// Create a new SMS_Program instance
m_oProvider = oProvider;
m_oPackage = oPackage;
ManagementObject oProgram = m_oProvider.Connection.CreateInstance("SMS_Program");
oProgram.SetPropertyValue("PackageID", oPackage.PackageID);
oProgram.SetPropertyValue("ProgramName", sProgramName);
oProgram.SetPropertyValue("CommandLine", sCommandLine);
string sRelPath = oProgram.Put(new PutOptions(m_oProvider.Context)).RelativePath;
// Load the new program
oProgram = m_oProvider.Connection.GetObject(sRelPath, m_oProvider.Context);
Load(oProgram);
}
// **********************************************************************
// Constructor - Load an existing program
// **********************************************************************
internal SMSProgram(SMSProvider oProvider, SMSPackage oPackage, ManagementObject oProgram)
{
// Load the existing package
m_oProvider = oProvider;
m_oPackage = oPackage;
Load(oProgram);
}
// **********************************************************************
// Load - Reads the properties for a program into this instance
// **********************************************************************
private void Load(ManagementObject oProgram)
{
// Read all the properties for this package
m_sProgramName = (string)oProgram.GetPropertyValue("ProgramName");
m_sRemovalKey = (string)oProgram.GetPropertyValue("RemovalKey");
//ProgramFlags = Convert.ToInt32(oProgram.GetPropertyValue("ProgramFlags"));
CommandLine = (string)oProgram.GetPropertyValue("CommandLine");
Comment = (string)oProgram.GetPropertyValue("Comment");
WorkingDirectory = (string)oProgram.GetPropertyValue("WorkingDirectory");
Description = (string)oProgram.GetPropertyValue("Description");
DiskSpaceReq = (string)oProgram.GetPropertyValue("DiskSpaceReq");
Duration = Convert.ToInt32(oProgram.GetPropertyValue("Duration"));
Requirements = (string)oProgram.GetPropertyValue("Requirements");
DriveLetter = (string)oProgram.GetPropertyValue("DriveLetter");
MSIFilePath = (string)oProgram.GetPropertyValue("MSIFilePath");
MSIProductID = (string)oProgram.GetPropertyValue("MSIProductID");
ApplicationHierarchy = (string)oProgram.GetPropertyValue("ApplicationHierarchy");
DeviceFlags = Convert.ToInt32(oProgram.GetPropertyValue("DeviceFlags"));
// Get the program flags
UInt32 uiProgramFlags = Convert.ToUInt32(oProgram.GetPropertyValue("ProgramFlags"));
m_bShowInARP = (uiProgramFlags & AP_SHOW_IN_ARP) > 0;
ProgramFlags = Convert.ToInt32(uiProgramFlags & ~AP_SHOW_IN_ARP);
// Get the dependent program
string sDependentProgram = (string)oProgram.GetPropertyValue("DependentProgram");
if(sDependentProgram == null || sDependentProgram.Length == 0)
DependentProgram = null;
else
{
// Get the PackageID & ProgramName of the dependent program
int nIndex = sDependentProgram.IndexOf(";");
string sDepPackageID = sDependentProgram.Substring(0, nIndex);
string sDepProgramName = sDependentProgram.Substring(nIndex+2);
// Load the SMSPackage instance for the dependent program
SMSPackage oDepPackage = m_oProvider.Packages.Get(sDepPackageID);
if(oDepPackage == null)
{
DependentProgram = null;
}
else
{
// Load the SMSProgram instance for the dependent program
DependentProgram = oDepPackage.Programs.Get(sDepProgramName);
}
}
// Get the supported platforms
m_cSupportedPlatforms.Clear();
object oSupportedOSs = oProgram.GetPropertyValue("SupportedOperatingSystems");
if(oSupportedOSs != null)
{
// Loop through the operating systems
foreach(ManagementBaseObject oSupportedOS in (Array)oSupportedOSs)
{
// This this supported OS to the collection
string sMaxVersion = (string)oSupportedOS.GetPropertyValue("MaxVersion");
string sMinVersion = (string)oSupportedOS.GetPropertyValue("MinVersion");
string sName = (string)oSupportedOS.GetPropertyValue("Name");
string sPlatform = (string)oSupportedOS.GetPropertyValue("Platform");
m_cSupportedPlatforms.Add(new SMSSupportedPlatform(
sMaxVersion, sMinVersion, sName, sPlatform));
}
}
}
///
/// Saves all the changes to the properties on this program and updates the SMS provider.
///
public void Save()
{
// Get the package instance
string sRelPath = "SMS_Program.PackageID=\"" + m_oPackage.PackageID + "\",ProgramName=\"" + m_sProgramName + "\"";
ManagementObject oProgram = m_oProvider.Connection.GetObject(sRelPath, m_oProvider.Context);
// Fill in the simple properties for the instance
oProgram.SetPropertyValue("RemovalKey", m_sRemovalKey);
oProgram.SetPropertyValue("ApplicationHierarchy", ApplicationHierarchy);
oProgram.SetPropertyValue("CommandLine", CommandLine);
oProgram.SetPropertyValue("Comment", Comment);
oProgram.SetPropertyValue("Description", Description);
oProgram.SetPropertyValue("DeviceFlags", DeviceFlags);
oProgram.SetPropertyValue("DiskSpaceReq", DiskSpaceReq);
oProgram.SetPropertyValue("DriveLetter", DriveLetter);
oProgram.SetPropertyValue("Duration", Duration);
oProgram.SetPropertyValue("MSIFilePath", MSIFilePath);
oProgram.SetPropertyValue("MSIProductID", MSIProductID);
//oProgram.SetPropertyValue("ProgramFlags", ProgramFlags);
oProgram.SetPropertyValue("Requirements", Requirements);
oProgram.SetPropertyValue("WorkingDirectory", WorkingDirectory);
// Get the program flags
UInt32 uiProgramFlags = Convert.ToUInt32(ProgramFlags);
if (m_bShowInARP)
uiProgramFlags |= AP_SHOW_IN_ARP;
oProgram.SetPropertyValue("ProgramFlags", uiProgramFlags);
// Set the dependent program
if(DependentProgram == null)
{
oProgram.SetPropertyValue("DependentProgram", "");
}
else
{
string sDepProgram = m_oPackage.PackageID + ";;" + m_sProgramName;
oProgram.SetPropertyValue("DependentProgram", sDepProgram);
}
// Save the supported OSs
if(m_cSupportedPlatforms.Count > 0)
{
// Create an array for the supported operating systems
ManagementBaseObject[] aSupportsOSs = new ManagementBaseObject[m_cSupportedPlatforms.Count];
// Loop through the platforms
for(int iIndex=0; iIndex
/// Deletes this program.
///
public void Delete()
{
// Get the RelPath for the program
string sRelPath = "SMS_Program.PackageID=\"" + m_oPackage.PackageID + "\",ProgramName=\"" + m_sProgramName + "\"";
// Delete the program
m_oProvider.Connection.DeleteObject(sRelPath, m_oProvider.Context);
}
// **********************************************************************
// ProgramFlags bitfield values
// **********************************************************************
private const Int32 AP_AC_RUN_DEPENDENT_ALWAYS = 0x00000080; // For AC only. If set this program's immediate dependent should always be run.
private const Int32 AP_OLD_RUN_DEPENDENT_ALWAYS = 0x00000200; // If set this program's immediate dependent should always be run.
private const Int32 AP_RUN_DEPENDENT_ALWAYS = 0x00000280; // Use this value to modify the Run Dependent Always program flag
private const Int32 AP_SUPPRESS_COUNTDOWN = 0x00000400; // If set the sountdown dialog is not displayed.
private const Int32 AP_REQUIRES_APM_RESTART = 0x00000800; // The command requires APM to be restarted, e.g. APASetup.exe
private const Int32 AP_DISABLED = 0x00001000; // Command disabled by company policy, i.e. no "Run from Network" support.
private const Int32 AP_UNATTENDED = 0x00002000; // Requires no user interaction
private const Int32 AP_USER_CONTEXT = 0x00004000; // Needs to run in the user context
private const Int32 AP_ADV_RIGHTS = 0x00008000; // Requires Administrator rights
private const Int32 AP_EVERY_USER = 0x00010000; // This job must be executed by every user for whom it is valid. Only valid for mandatory jobs.
private const Int32 AP_NO_USER = 0x00020000; // Run only when no user is logged on
private const Int32 AP_OK_TO_QUIT = 0x00040000; // Exit application on a Quit message - for programs which restart OS
private const Int32 AP_OK_REBOOT = 0x00080000; // When done with successful command restart the OS
private const Int32 AP_OK_LOGOFF = 0x02000000; // When done with successful command logoff user
private const Int32 AP_RUN_ACCOUNT = 0x04000000; // Special SMS admin defined account to run program
private const Int32 AP_ANY_PLATFORM = 0x08000000; // Override check for platform support.
private const Int32 AP_STILL_RUNNING = 0x10000000; // Display "Still running..." notice.
private const Int32 AP_SUPPORT_UNINSTALL = 0x20000000; // PGC like behavior, run uninstall from registry key when advert expires.
private const Int32 AP_BAD_PLATFORM = 0x40000000; // Platform Not Supported.
private const Int32 AP_UNC_PATH = 0x00100000; // Use UNC connection vs. Drive Letter connection
private const Int32 AP_PERSISTENT = 0x00200000; // Do not disconnect Persistent connection when done
private const Int32 AP_MINIMIZED = 0x00400000; // Run minimized
private const Int32 AP_MAXIMIZED = 0x00800000; // Run with a maximized window
private const Int32 AP_HIDE_WINDOW = 0x01000000; // Do not show window when run
//private const Int32 AP_SHOW_IN_ARP = 0x80000000; // display in ARP
private const UInt32 AP_SHOW_IN_ARP = 0x80000000; //display in ARP
// **********************************************************************
// Program Flags Masks
// **********************************************************************
private const Int32 c_RunWindowMask = ~(AP_MINIMIZED | AP_MAXIMIZED | AP_HIDE_WINDOW); // 0xFE3FFFFF;
private const Int32 c_AfterRunningMask = ~(AP_OK_TO_QUIT | AP_OK_REBOOT | AP_OK_LOGOFF); // 0xFDF3FFFF;
private const Int32 c_ProgramCanRunMask = ~(AP_USER_CONTEXT | AP_NO_USER);
}
///
/// This class represents a supported platform for a program.
///
public class SMSSupportedPlatform
{
// Private properties
private string m_sMaxVersion;
private string m_sMinVersion;
private string m_sName;
private string m_sPlatform;
// Public properties
// ---------------------------
///The maximum version number of this platform.
public string MaxVersion {get{return m_sMaxVersion;}}
///The minimum version number of this platform.
public string MinVersion {get{return m_sMinVersion;}}
///The name of this platform ("Win NT", "Win 9X", etc).
public string Name {get{return m_sName;}}
///The type of this platform ("I386" or "Alpha").
public string Platform {get{return m_sPlatform;}}
///
/// Creates a new SMSSupportedPlatform instance. You should instead use the static
/// .[PlatformName] properties on the SMSSupportedPlatform class to access the common
/// instances for this class.
///
/// The maximum version number of this platform.
/// The minimum version number of this platform.
/// The name of this platform ("Win NT", "Win 9x", etc).
/// The type of this platform ("I386" or "Alpha").
public SMSSupportedPlatform(string sMaxVersion, string sMinVersion, string sName, string sPlatform)
{
m_sMaxVersion = sMaxVersion;
m_sMinVersion = sMinVersion;
m_sName = sName;
m_sPlatform = sPlatform;
}
// Common instances accessable from static properties
// --------------------------------------------------------
// ============== Common Large Sets =================
/// All 16-bit Windows clients
public static SMSSupportedPlatform AllWin16
{get{return new SMSSupportedPlatform("99.99.9999.9999", "0.00.0000.0", "Win 16", "I386");}}
/// All x86 Windows NT clients
public static SMSSupportedPlatform x86WinNT
{get{return new SMSSupportedPlatform("99.99.9999.9999", "0.00.0000.0", "Win NT", "I386");}}
/// All Alpha Windows NT clients
public static SMSSupportedPlatform AlphaWinNT
{get{return new SMSSupportedPlatform("99.99.9999.9999", "0.00.0000.0", "Win NT", "Alpha");}}
// ==================== Windows 9X ===================
/// All Windows 9x clients
public static SMSSupportedPlatform AllWin9x
{get{return new SMSSupportedPlatform("99.99.9999.9999", "0.00.0000.0", "Win 9x", "I386");}}
/// All Windows 95 clients
public static SMSSupportedPlatform AllWin95
{get{return new SMSSupportedPlatform("4.00.9999.9999", "0.00.0000.0", "Win 9x", "I386");}}
/// All Windows 95 Vanilla clients
public static SMSSupportedPlatform AllWin95Vanilla
{get{return new SMSSupportedPlatform("4.00.0950.0", "4.00.0950.0", "Win 9x", "I386");}}
/// All Windows 95 OSR2 clients
public static SMSSupportedPlatform AllWin95OSR2
{get{return new SMSSupportedPlatform("4.00.1111.2", "4.00.1111.2", "Win 9x", "I386");}}
/// All Windows 98 clients
public static SMSSupportedPlatform AllWin98
{get{return new SMSSupportedPlatform("4.10.9999.9999", "4.10.1998.0", "Win 9x", "I386");}}
/// All Windows ME clients
public static SMSSupportedPlatform AllWinME
{get{return new SMSSupportedPlatform("4.90.9999.9999", "4.90.3000.0", "Win 9x", "I386");}}
// ====================== NT 3.51 ========================
/// All x86 Windows NT 3.51 clients
public static SMSSupportedPlatform x86WinNT351
{get{return new SMSSupportedPlatform("3.51.9999.9999", "3.51.0000.0", "Win NT", "I386");}}
/// All Alpha Windows NT 3.51 clients
public static SMSSupportedPlatform AlphaWinNT351
{get{return new SMSSupportedPlatform("3.51.9999.9999", "3.51.0000.0", "Win NT", "Alpha");}}
/// All x86 Windows NT 3.51 NoSP clients
public static SMSSupportedPlatform x86WinNT351Vanilla
{get{return new SMSSupportedPlatform("3.51.1057.0", "3.51.1057.0", "Win NT", "I386");}}
/// All Alpha Windows NT 3.51 NoSP clients
public static SMSSupportedPlatform AlphaWinNT351Vanilla
{get{return new SMSSupportedPlatform("3.51.1057.0", "3.51.1057.0", "Win NT", "Alpha");}}
/// All x86 Windows NT 3.51 SP1 clients
public static SMSSupportedPlatform x86WinNT351SP1
{get{return new SMSSupportedPlatform("3.51.1057.1", "3.51.1057.1", "Win NT", "I386");}}
/// All Alpha Windows NT 3.51 SP1 clients
public static SMSSupportedPlatform AlphaWinNT351SP1
{get{return new SMSSupportedPlatform("3.51.1057.1", "3.51.1057.1", "Win NT", "Alpha");}}
/// All x86 Windows NT 3.51 SP2 clients
public static SMSSupportedPlatform x86WinNT351SP2
{get{return new SMSSupportedPlatform("3.51.1057.2", "3.51.1057.2", "Win NT", "I386");}}
/// All Alpha Windows NT 3.51 SP2 clients
public static SMSSupportedPlatform AlphaWinNT351SP2
{get{return new SMSSupportedPlatform("3.51.1057.2", "3.51.1057.2", "Win NT", "Alpha");}}
/// All x86 Windows NT 3.51 SP3 clients
public static SMSSupportedPlatform x86WinNT351SP3
{get{return new SMSSupportedPlatform("3.51.1057.3", "3.51.1057.3", "Win NT", "I386");}}
/// All Alpha Windows NT 3.51 SP3 clients
public static SMSSupportedPlatform AlphaWinNT351SP3
{get{return new SMSSupportedPlatform("3.51.1057.3", "3.51.1057.3", "Win NT", "Alpha");}}
/// All x86 Windows NT 3.51 SP4 clients
public static SMSSupportedPlatform x86WinNT351SP4
{get{return new SMSSupportedPlatform("3.51.1057.4", "3.51.1057.4", "Win NT", "I386");}}
/// All Alpha Windows NT 3.51 SP4 clients
public static SMSSupportedPlatform AlphaWinNT351SP4
{get{return new SMSSupportedPlatform("3.51.1057.4", "3.51.1057.4", "Win NT", "Alpha");}}
/// All x86 Windows NT 3.51 SP5 clients
public static SMSSupportedPlatform x86WinNT351SP5
{get{return new SMSSupportedPlatform("3.51.1057.5", "3.51.1057.5", "Win NT", "I386");}}
/// All Alpha Windows NT 3.51 SP5 clients
public static SMSSupportedPlatform AlphaWinNT351SP5
{get{return new SMSSupportedPlatform("3.51.1057.5", "3.51.1057.5", "Win NT", "Alpha");}}
// ======================== NT 4.0 ==========================
/// All x86 Windows NT 4.0 clients
public static SMSSupportedPlatform x86WinNT4
{get{return new SMSSupportedPlatform("4.00.9999.9999", "4.00.0000.0", "Win NT", "I386");}}
/// All Alpha Windows NT 4.0 clients
public static SMSSupportedPlatform AlphaWinNT4
{get{return new SMSSupportedPlatform("4.00.9999.9999", "4.00.0000.0", "Win NT", "Alpha");}}
/// All x86 Windows NT 4.0 NoSP clients
public static SMSSupportedPlatform x86WinNT4Vanilla
{get{return new SMSSupportedPlatform("4.00.1381.0", "4.00.1381.0", "Win NT", "I386");}}
/// All Alpha Windows NT 4.0 NoSP clients
public static SMSSupportedPlatform AlphaWinNT4Vanilla
{get{return new SMSSupportedPlatform("4.00.1381.0", "4.00.1381.0", "Win NT", "Alpha");}}
/// All x86 Windows NT 4.0 SP1 clients
public static SMSSupportedPlatform x86WinNT4SP1
{get{return new SMSSupportedPlatform("4.00.1381.1", "4.00.1381.1", "Win NT", "I386");}}
/// All Alpha Windows NT 4.0 SP1 clients
public static SMSSupportedPlatform AlphaWinNT4SP1
{get{return new SMSSupportedPlatform("4.00.1381.1", "4.00.1381.1", "Win NT", "Alpha");}}
/// All x86 Windows NT 4.0 SP2 clients
public static SMSSupportedPlatform x86WinNT4SP2
{get{return new SMSSupportedPlatform("4.00.1381.2", "4.00.1381.2", "Win NT", "I386");}}
/// All Alpha Windows NT 4.0 SP2 clients
public static SMSSupportedPlatform AlphaWinNT4SP2
{get{return new SMSSupportedPlatform("4.00.1381.2", "4.00.1381.2", "Win NT", "Alpha");}}
/// All x86 Windows NT 4.0 SP3 clients
public static SMSSupportedPlatform x86WinNT4SP3
{get{return new SMSSupportedPlatform("4.00.1381.3", "4.00.1381.3", "Win NT", "I386");}}
/// All Alpha Windows NT 4.0 SP3 clients
public static SMSSupportedPlatform AlphaWinNT4SP3
{get{return new SMSSupportedPlatform("4.00.1381.3", "4.00.1381.3", "Win NT", "Alpha");}}
/// All x86 Windows NT 4.0 SP4 clients
public static SMSSupportedPlatform x86WinNT4SP4
{get{return new SMSSupportedPlatform("4.00.1381.4", "4.00.1381.4", "Win NT", "I386");}}
/// All Alpha Windows NT 4.0 SP4 clients
public static SMSSupportedPlatform AlphaWinNT4SP4
{get{return new SMSSupportedPlatform("4.00.1381.4", "4.00.1381.4", "Win NT", "Alpha");}}
/// All x86 Windows NT 4.0 SP5 clients
public static SMSSupportedPlatform x86WinNT4SP5
{get{return new SMSSupportedPlatform("4.00.1381.5", "4.00.1381.5", "Win NT", "I386");}}
/// All Alpha Windows NT 4.0 SP5 clients
public static SMSSupportedPlatform AlphaWinNT4SP5
{get{return new SMSSupportedPlatform("4.00.1381.5", "4.00.1381.5", "Win NT", "Alpha");}}
/// All x86 Windows NT 4.0 SP6 clients
public static SMSSupportedPlatform x86WinNT4SP6
{get{return new SMSSupportedPlatform("4.00.1381.6", "4.00.1381.6", "Win NT", "I386");}}
/// All Alpha Windows NT 4.0 SP6 clients
public static SMSSupportedPlatform AlphaWinNT4SP6
{get{return new SMSSupportedPlatform("4.00.1381.6", "4.00.1381.6", "Win NT", "Alpha");}}
// ======================== Windows 2000 ==========================
/// All Windows 2000 clients
public static SMSSupportedPlatform AllWin2000
{get{return new SMSSupportedPlatform("5.00.9999.9999", "5.00.0000.0", "Win NT", "I386");}}
/// All Windows 2000 Original Release clients
public static SMSSupportedPlatform AllWin2000Vanilla
{get{return new SMSSupportedPlatform("5.00.2195.0", "5.00.2195.0", "Win NT", "I386");}}
/// All Windows 2000 SP1 clients
public static SMSSupportedPlatform AllWin2000SP1
{get{return new SMSSupportedPlatform("5.00.2195.1", "5.00.2195.1", "Win NT", "I386");}}
/// All Windows 2000 SP2 clients
public static SMSSupportedPlatform AllWin2000SP2
{get{return new SMSSupportedPlatform("5.00.2195.2", "5.00.2195.2", "Win NT", "I386");}}
/// All Windows 2000 SP3 clients
public static SMSSupportedPlatform AllWin2000SP3
{get{return new SMSSupportedPlatform("5.00.2195.3", "5.00.2195.3", "Win NT", "I386");}}
/// All Windows 2000 SP4 clients
public static SMSSupportedPlatform AllWin2000SP4
{get{return new SMSSupportedPlatform("5.00.2195.4", "5.00.2195.4", "Win NT", "I386");}}
// ======================== Windows XP ==========================
/// All Windows XP clients
public static SMSSupportedPlatform AllWinXP
{get{return new SMSSupportedPlatform("5.10.9999.9999", "5.10.0000.0", "Win NT", "I386");}}
/// All Windows XP Original Release clients
public static SMSSupportedPlatform AllWinXPVanilla
{get{return new SMSSupportedPlatform("5.10.2600.0", "5.10.2600.0", "Win NT", "I386");}}
/// All Windows XP SP1 clients
public static SMSSupportedPlatform AllWinXPSP1
{get{return new SMSSupportedPlatform("5.10.2600.1", "5.10.2600.1", "Win NT", "I386");}}
/// All Windows XP SP2 clients
public static SMSSupportedPlatform AllWinXPSP2
{get{return new SMSSupportedPlatform("5.10.2600.2", "5.10.2600.2", "Win NT", "I386");}}
// ==================== Windows Server 2003 ======================
/// All Windows Server 2003 clients
public static SMSSupportedPlatform AllWin2003
{get{return new SMSSupportedPlatform("5.20.9999.9999", "5.20.0000.0", "Win NT", "I386");}}
}
///
/// This class contains a collection of SMSSupportedPlatform instances.
///
public class SMSSupportedPlatformCollection : IEnumerable
{
// Interal properties
private ArrayList m_alPlatforms = new ArrayList();
// *******************************************************************************
// Ctor
// *******************************************************************************
internal SMSSupportedPlatformCollection() {}
/// Returns the number of items in this collection.
public int Count { get { return m_alPlatforms.Count; } }
///
/// Determines if the specified platform exists in this collection.
///
/// Platform to check for.
/// Returns true if the platform exists in this collection.
public bool Contains(SMSSupportedPlatform oPlatform)
{
foreach(SMSSupportedPlatform oLoop in m_alPlatforms)
if( oPlatform.MaxVersion.ToLower() == oLoop.MaxVersion.ToLower() &&
oPlatform.MinVersion.ToLower() == oLoop.MinVersion.ToLower() &&
oPlatform.Name.ToLower() == oLoop.Name.ToLower() &&
oPlatform.Platform.ToLower() == oLoop.Platform.ToLower() )
return true;
return false;
}
///
/// Clear the collection
///
public void Clear()
{
m_alPlatforms.Clear();
}
///
/// Adds a single SMSSupportedPlatform to the collection.
///
/// Platform to be added to the collection.
public void Add(SMSSupportedPlatform oPlatform)
{
m_alPlatforms.Add(oPlatform);
}
///
/// Inserts a SMSSupportedPlatform into the collection at a specified index.
///
/// Platform to be inserted into the collection.
/// Index at which to insert the platform (zero-based).
public void Insert(SMSSupportedPlatform oPlatform, int iIndex)
{
m_alPlatforms.Insert(iIndex, oPlatform);
}
///
/// Removes a SMSSupportedPlatform instance from the collection.
///
/// Platform to be removed from the collection.
public void Remove(SMSSupportedPlatform oPlatform)
{
m_alPlatforms.Remove(oPlatform);
}
///
/// Removes a SMSSupportedPlatform instance from the collection at a specific index.
///
/// Index at which to remove the platform.
public void RemoveAt(int iIndex)
{
m_alPlatforms.RemoveAt(iIndex);
}
///
/// Access the SMSSupportedPlatform instance at a specific index in the collection.
///
/// Index of the platform to access.
public SMSSupportedPlatform this[int iIndex]
{
get
{
return (SMSSupportedPlatform)m_alPlatforms[iIndex];
}
}
///
/// SMSSupportedPlatform enumerator.
///
/// Returns an enumeration of all the SMSSupportedPlatform instances in the collection.
public IEnumerator GetEnumerator()
{
return m_alPlatforms.GetEnumerator();
}
}
}