我现在要帮助别人做一个课件(PPT文档)安全管理的项目,项目内容主要是限制不同教员在不同时间对不同课件具有读权限和使用权限,不能复制、粘贴、打印、屏幕打印等,时间一过则不能使用和打开,以上功能office2003的信息权限管理(IMS)基本可以满足,但对于多名教员设置多个PPT课件的信息权限,工作量大且不易准确,我想编写一个.NET程序,根据老师上课的时间自动设置对应课件的IMS设置并将设置好IMS的PPT课件保存到指定位置。如何在一个.NET程序中对一个已经存在的PPT文档设置IMS,大家能否给我提供些帮助。谢谢! 

解决方案 »

  1.   

    更正一下:信息权限管理缩写为IRM
      

  2.   

    找到了相关答案,看来还是有能人,可为什么都不在这里现身呢?
    http://203.208.39.132/search?q=cache:mZotclm8vPwJ:msdn.microsoft.com/zh-cn/library/aa944110(VS.80).aspx+IRM+C%23+Permission&cd=1&hl=zh-CN&ct=clnk&gl=cn&st_usg=ALhdy2-lBET1btVV51pyU13ncLTh5-1fXA
      

  3.   

    该问题已经自行解决,以下是部分代码:
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    using Microsoft.Office.Core;
    using Microsoft.Office.Interop;
    using System.IO;
    namespace IDCheckSystem
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();           
                this.cbType.SelectedIndex = 0;
            }        private void button1_Click(object sender, EventArgs e)
            {
                OpenFileDialog ofd = new OpenFileDialog();
                ofd.Filter = "*.ppt|*.*";
                if (ofd.ShowDialog() == DialogResult.OK)
                {
                    this.tbFileName.Text = ofd.FileName;
                }
            }        private void button2_Click(object sender, EventArgs e)
            {
                if (this.tbFileName.Text == "" )
                {
                    MessageBox.Show("请输入要设置权限的PPT文件", "权限设置提示");
                    return;
                }
                if(!File.Exists(this.tbFileName.Text))
                {
                    MessageBox.Show("请选择要设置权限的PPT文件", "权限设置提示");
                    return;
                }            if (this.tbUserNames.Text == "")
                {
                    MessageBox.Show("请输入要设置的权限的用户列表","权限设置提示");
                    return;
                }            try
                {
                    string pptFilename = this.tbFileName.Text;
                    
                    MsoPermission per;
                    UserPermission www;
                   
                    switch (this.cbType.SelectedIndex)
                    {
                        case 0:
                            per = MsoPermission.msoPermissionRead;
                            break;
                        case 1:
                            per = MsoPermission.msoPermissionEdit;
                            break;
                        case 2:
                            per = MsoPermission.msoPermissionPrint;
                            break;
                        case 3:
                            per = MsoPermission.msoPermissionFullControl;
                            break;
                        default:
                            per = MsoPermission.msoPermissionRead;
                            break;
                    }                DateTime dtExpireDate = this.dateTimePicker1.Value;                Microsoft.Office.Interop.PowerPoint.Presentation presentation;                Microsoft.Office.Interop.PowerPoint.ApplicationClass oPPT = new  Microsoft.Office.Interop.PowerPoint.ApplicationClass();                presentation = oPPT.Presentations.Open(pptFilename.ToString(), Microsoft.Office.Core.MsoTriState.msoFalse, Microsoft.Office.Core.MsoTriState.msoFalse, Microsoft.Office.Core.MsoTriState.msoFalse);                presentation.Application.Visible = MsoTriState.msoTrue;
                    presentation.Application.Activate();                presentation.Permission.Enabled = true;                string[] users = this.tbUserNames.Text.Split('|');
                    foreach (string user in users)
                    {
                        presentation.Permission.Add(user, per, dtExpireDate);
                        presentation.Permission.Add(user,  MsoPermission.msoPermissionRead, dtExpireDate);
                        
                    }
                    presentation.Sive();
                    presentation.Close();                MessageBox.Show("权限设置成功", "权限设置提示");
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message,"错误提示");
                }
            }
        }
    }