获取和设置剪贴板的数据

来源:互联网 发布:dota2冥魂大帝不朽淘宝 编辑:程序博客网 时间:2024/05/17 06:32

  using   System.Windows.Forms;  
  string   text   =   "Some   text   for   the   clipboard";    
   
  Clipboard.SetDataObject(text);   //clipboard   now   has   "Some   text   for   the   clipboard"    
  text   =   "";   //zap   text   so   it   can   be   reset...    
  IDataObject   data   =   Clipboard.GetDataObject();    
  if(data.GetDataPresent(DataFormats.Text))    
  {    
      text   =   (String)data.GetData(DataFormats.Text);    
      //text   is   now   back   to   "Some   text   for   the   clipboard"    
  }

原创粉丝点击