您的最佳的信息源和新聞 司機, 司機 并且 景色硬件 在互聯網

景色文章 名列前茅50 景色錄影 景色軟 景色幫助

剪貼板混亂!


注: 原始這個內容從 http://mygreenpaste.blogspot.com. 如果您是讀書它從某一其他站點,請需要時間參觀 我的綠色漿糊,公司. 謝謝。

或許好,因此混亂這裡是一點苛刻的話。 但剪貼板最近駕駛我堅果! 我設法做的所有是複製一些文本對它,并且操作發生故障。 當然,因為它是特別app,我沒有任何种錯誤處理。 app在一個系統運作正義罰款,但跑app在另一個系統(一臺虛擬機)一貫地導致疏忽複製文本到剪貼板。

最後,我能確定什麼過程防止我的app投入數據在剪貼板,但我未發現一個正派解決方法為,當問題發生時。 它為我比要求不是重要的,作為複製文本行動對剪貼板是更多美好。

無論如何,使用P/Invoke和 System.Diagnostics我發現vmusrvc.exe -真正個人計算機「虛擬機用戶為服務」 -有剪貼板開放。 使用時間戳從 處理顯示器『s描出事件的(引起在100女士間隔時間)和不合格的操作的時間戳從我的app,我能確定堆vmusrvc.exe :

ntdll.dllKiFastSystemCallRet
vmusrvc.exevmusrvc.exe + 0x9a17
vmusrvc.exevmusrvc.exe + 0x9c24
vmusrvc.exevmusrvc.exe + 0x91f8
vmusrvc.exevmusrvc.exe + 0x907f
USER32.dllInternalCallWinProc + 0x28
USER32.dllUserCallWinProcCheckWow + 0x150
USER32.dllDispatchClientMessage + 0xa3
USER32.dll__fnDWORD + 0x24
ntdll.dllKiUserCallbackDispatcher + 0x13
vmusrvc.exevmusrvc.exe + 0x2d29
vmusrvc.exevmusrvc.exe + 0xdba6
kernel32.dllBaseProcessStart + 0x23

參量, user32.dll當然,并且標誌信息為vmusrvc.exe不看來是可利用的,但明顯地不處理某一消息。 我也許調查這更多最新點。

要發現干涉我的剪貼板工作的過程,我使用P/Invoke叫 GetOpenClipboardWindow()然後 GetWindowThreadProcessId(),通過在返回的把柄由GetOpenClipboardWindow ()。 然後,發現過程的可執行的名字是事情使用 模塊 彙集的 過程 事例通過通過返回了在id中被檢索的過程GetWindowThreadProcessId () System.Diagnostics.Process.GetProcessById().

以下代碼:

使用System.Runtime.InteropServices;
使用System.Diagnostics;
...
串起數據= 「aasdlkjasdlk alkjsdl kajsdlkj Al」;
嘗試
{
Clipboard.SetData (System.Windows.Forms.DataFormats.Text,數據);
}
抓住(ExternalException ee)
{
LogIt (ee.ToString ());
IntPtr hWnd = GetOpenClipboardWindow ();
如果(IntPtr.Zero! = hWnd)
{
uint pid = 0;
uint tid = GetWindowThreadProcessId (hWnd, pid);
LogIt (「過程與hWnd {0}, PID {1} ({1 :x}), TID {2} ({2 :x})」, +
"name {3} has the clipboard", hWnd, pid, tid,
Process.GetProcessById( (int)pid ).Modules[0].FileName );
}
}

Resulted in the following output:


2008-03-25 00:54:45.4938864--> System.Runtime.InteropServices.ExternalException: Requested Clipboard operation did not succeed.
at System.Windows.Forms.Clipboard.ThrowIfFailed(Int32 hr)
at System.Windows.Forms.Clipboard.SetDataObject(Object data, Boolean copy, Int32 retryTimes, Int32 retryDelay)
at System.Windows.Forms.Clipboard.SetData(String format, Object data)
at Clippy.Form1.button1_Click(Object sender, EventArgs e)
2008-03-25 00:54:45.5339440--> Process with hWnd 65716 (65716), PID 1492 (5d4), TID 1496 (5d8), name C:\Program Files\Virtual Machine Additions\vmusrvc.exe has the clipboard

Interestingly, trying an alternative method of the Clipboard to set the content also failed. The Clipboard.SetDataObject() overload that takes a retryTimes and retryDelay parameter failed in the same fashion after roughly ten seconds when invoked as follows:


Clipboard.SetDataObject( data, false, 100, 100 );

I tried variations on retryTimes and retryDelay, to no avail.

Not sure what vmusrvc.exe is doing with the clipboard (probably has to do with monitoring it for host / guest VM interaction), but the act of setting the contents of the clipboard didn't fail 100% of the time in the VM. Often enough to make it extremely unreliable, though. During "normal" system usage, I was not able to cause a failure when running the app on a non-virtual (actual?) system.

Popularity: 2%


Written by «/\/\Ø|ö±ò\/»®©. Read more great feeds at is source WEBSITE
no comments.
Read more articles on P/Invoke and GetOpenClipboardWindow and System.Diagnostics and Clipboard and GetWindowThreadProcessId and Process Monitor and c# and processes and Virtual Machine and otherSoftware and Virtual PC.

No comments

There are still no comments on this article.

Leave your comment...

If you want to leave your comment on this article, simply fill out the next form:




You can use these XHTML tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong> .