/// <summary> /// Obtain Path to OSPPC.dll for Microsoft Office /// </summary> /// <returns>Path to OSPPC.dll</returns> private static string GetOSPPCPath() { switch (OfficeVersion.GetOfficeNumber()) { case 14: case 15: case 16: switch (Architecture.GetOfficeArch()) { case Architecture.X86: { return(Environment.ExpandEnvironmentVariables("%CommonProgramFiles%\\microsoft shared\\OfficeSoftwareProtectionPlatform\\osppc.dll")); } case Architecture.WOW: case Architecture.X64: { return(Environment.ExpandEnvironmentVariables("%CommonProgramW6432%\\microsoft shared\\OfficeSoftwareProtectionPlatform\\osppc.dll")); } default: { return(string.Empty); } } default: throw new ApplicationException("Unsupported Microsoft Office Edition!"); } }
/// <summary> /// Obtain a Byte Array Representing PkeyConfig for Microsoft Office PIDX Check from System /// </summary> /// <returns>Byte Array Representation of PkeyConfig.xrm-ms</returns> private static byte[] GetBuiltInPkeyConfigOffice() { string pkeyconfig = string.Empty; string officeArch = Architecture.GetOfficeArch(); int officeNumber = OfficeVersion.GetOfficeNumber(); switch (officeNumber) { case 14: case 15: switch (officeArch) { case Architecture.X86: { pkeyconfig = Environment.ExpandEnvironmentVariables("%CommonProgramFiles%\\microsoft shared\\OFFICE" + officeNumber + "\\Office Setup Controller\\pkeyconfig-office.xrm-ms"); break; } case Architecture.WOW: { pkeyconfig = Environment.ExpandEnvironmentVariables("%CommonProgramFiles(x86)%\\microsoft shared\\OFFICE" + officeNumber + "\\Office Setup Controller\\pkeyconfig-office.xrm-ms"); break; } case Architecture.X64: { pkeyconfig = Environment.ExpandEnvironmentVariables("%CommonProgramW6432%\\microsoft shared\\OFFICE" + officeNumber + "\\Office Setup Controller\\pkeyconfig-office.xrm-ms"); break; } } break; default: throw new ApplicationException("Could not find Built-In PkeyConfig"); } return(File.ReadAllBytes(pkeyconfig)); }
/// <summary> /// Obtain Path to OSPPREARM.exe for Microsoft Office /// </summary> /// <returns>Path to OSPPREARM.exe</returns> private static string GetRearmToolPath() { switch (OfficeVersion.GetOfficeNumber()) { case 14: switch (Architecture.GetOfficeArch()) { case Architecture.X86: { return(CommonUtilities.EscapePath(Environment.ExpandEnvironmentVariables("%CommonProgramFiles%\\microsoft shared\\OfficeSoftwareProtectionPlatform\\OSPPREARM.exe"))); } case Architecture.WOW: { return(CommonUtilities.EscapePath(Environment.ExpandEnvironmentVariables("%CommonProgramFiles(x86)%\\microsoft shared\\OfficeSoftwareProtectionPlatform\\OSPPREARM.exe"))); } case Architecture.X64: { return(CommonUtilities.EscapePath(Environment.ExpandEnvironmentVariables("%CommonProgramW6432%\\microsoft shared\\OfficeSoftwareProtectionPlatform\\OSPPREARM.exe"))); } default: { return(string.Empty); } } case 15: case 16: return(CommonUtilities.EscapePath(OfficeVersion.GetInstallationPath() + "OSPPREARM.exe")); default: throw new ApplicationException("Unsupported Microsoft Office Edition!"); } }