Klemmbrett-Chaos!
Anmerkung: dieser Inhalt ursprünglich von http://mygreenpaste.blogspot.com. Wenn Sie Messwert es von irgendeinem anderem Aufstellungsort sind, dauern Sie bitte die Zeit zu besuchen Meine grüne Paste, Inc.. Danke.
O.K., also möglicherweise Chaos ist ein wenig ein rauhes Wort hier. Aber das Klemmbrett fuhr mich vor kurzem Nüsse! Alles, das ich versuchte zu tun, war, etwas Text zu ihm zu kopieren, und der Betrieb fiel aus. Selbstverständlich da es eine ad hoc APP war, hatte ich keine Art Fehlerbehandlung. Die APP bearbeitete gerechte Geldstrafe auf einem System, aber das Laufen lassen der APP auf einem anderen System (eine virtuelle Maschine) ergab durchweg Störung, den Text zum Klemmbrett zu kopieren.
Schließlich war ich in der Lage, festzustellen, welcher Prozeß meine APP am Einsetzen von Daten in das Klemmbrett verhinderte, aber ich habe nicht noch einen annehmbaren Workaround für gefunden, wenn das Problem geschieht. Es ist nicht für mich, als die Tat der Kopie des Textes zum Klemmbrett ist mehr einer Feinheit als eine Anforderung kritisch.
Sowieso mit P/Invoke und System.Diagnostics, Fand ich, daß vmusrvc.exe - der virtuelle PC „virtueller Maschine Benutzer hält“ instand - das geöffnete Klemmbrett hatte. Verwenden der Zeitstempel von Prozeßmonitor's, das die Fälle (erzeugt in 100 Msabständen) und der Zeitstempel des verlassenen Betriebes von meiner APP profilieren, war ich in der Lage, den Stapel von vmusrvc.exe festzustellen:
| ntdll.dll | KiFastSystemCallRet |
| vmusrvc.exe | vmusrvc.exe + 0x9a17 |
| vmusrvc.exe | vmusrvc.exe + 0x9c24 |
| vmusrvc.exe | vmusrvc.exe + 0x91f8 |
| vmusrvc.exe | vmusrvc.exe + 0x907f |
| USER32.dll | InternalCallWinProc + 0x28 |
| USER32.dll | UserCallWinProcCheckWow + 0x150 |
| USER32.dll | DispatchClientMessage + 0xa3 |
| USER32.dll | __fnDWORD + 0x24 |
| ntdll.dll | KiUserCallbackDispatcher + 0x13 |
| vmusrvc.exe | vmusrvc.exe + 0x2d29 |
| vmusrvc.exe | vmusrvc.exe + 0xdba6 |
| kernel32.dll | BaseProcessStart + 0x23 |
Keine Parameter, selbstverständlich und Symbolinformationen für vmusrvc.exe scheinen nicht, vorhanden zu sein, aber offensichtlich user32.dll verarbeitet irgendeine Anzeige. Ich kann in dieses mehr auf einen neueren Punkt schauen.
Um den Prozeß zu finden der meine Klemmbrettarbeit behinderte, verwendete ich P/Invoke um zu benennen GetOpenClipboardWindow() und dann GetWindowThreadProcessId(), überschreiten in den Handgriff zurückgebracht durch GetOpenClipboardWindow (). Dann den vollziehbaren Namen der Prozesse war zu finden nur eine Angelegenheit des Verwendens Module Ansammlung von Prozeß Fall ging zurück, indem er in die Prozeßkennzeichnung überschritt, die durch GetWindowThreadProcessId zurückgeholt wird () zu System.Diagnostics.Process.GetProcessById().
Der folgende Code:
Verwenden von System.Runtime.InteropServices;
Verwenden von System.Diagnostics;
...
reihen Sie Daten = „aasdlkjasdlk alkjsdl kajsdlkj Al“ auf;
Versuch
{
Clipboard.SetData (System.Windows.Forms.DataFormats.Text, Daten);
}
Verriegelung (ExternalException ee)
{
LogIt (ee.ToString ());
IntPtr hWnd = GetOpenClipboardWindow ();
wenn (IntPtr.Zero! = hWnd)
{
uint pid = 0;
uint tid = GetWindowThreadProcessId (hWnd, heraus pid);
LogIt („Prozeß mit hWnd {0}, PID {1} ({1: x}), TID {2} ({2: x}),“ +
„Name {3} hat das Klemmbrett“, 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.
- [+] Digg: Feature this article
- [+] Del.icio.us: Bookmark this article
- [+] Furl: Bookmark this article














