您只能从STA线程访问剪贴板。Rick Brewster在Paint.NET中通过对常规Edit-> Paste命令进行一些重构来解决此问题。
码:
IDataObject idat = null;Exception threadEx = null;Thread staThread = new Thread( delegate () { try { idat = Clipboard.GetDataObject(); } catch (Exception ex) { threadEx = ex; } });staThread.SetApartmentState(ApartmentState.STA);staThread.Start();staThread.Join();// at this point either you have clipboard data or an exception
代码来自里克。http://forums.getpaint.net/index.php?/topic/13712-/page__view__findpost__p__226140
更新 :贾森·海涅取得加入一个好点
()后
delegate,以固定的暧昧方法错误。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)