I
intmainreturn0
Guest
I have a simple app that monitors and lists all clipboard formats available on the system clipboard whenever the clipboard is updated. It works totally fine in almost all scenarios. The only problem is that when the app is ran as Local System AND the clipboard is updated with registered formats (i.e. copying RTF text in MS Word), the list of formats I get from iterating over EnumCLipboardFormats is incomplete. The iterated calls to EnumClipboardFormats ends after grabbing the very first format (which is always "DataObject" - 49161) because the subsequent call always returns 0 with ERROR_SUCCESS (meaning there is no more format to return). According to the test case where the app is running as the logged-on user, copying the exact same data (RTF text in this case) should have resulted in listing >5 formats. Also, when I am dealing with standard clipboard formats (i.e. copying plain-text from notepad), I don't have this issue at all. Regardless of which user the app is running as, the list I get returned from the iterated calls to EnumClipboardFormats is always the same. It's super weird. To me, it seems like the other formats that are not getting returned from the enum call is "hidden" in some sense, but I was unable to find any documentation providing clues to explain this behavior, and I have not found any article or thread talking about this issue.
I've already tried impersonating the logged-on user, but that did not help. Impersonation was successful, but the iteration over EnumClipboardFormats still ended after giving me the first format.
For clarity, these are the test cases:
1. Run the app as the logged-on user + update the clipboard with a standard format (plain-text from notepad) = Iterated enum returns the full list of formats
2. Run the app as the logged-on user + update the clipboard with a registered format (RTF text from MS Word) = Iterated enum returns the full list of formats
3. Run the app as Local System + update the clipboard with a standard format (plain-text from notepad) = Iterated enum returns the full list of formats
4. Run the app as Local System + update the clipboard with a registered format (RTF text from MS Word) = Iterated enum returns an imcomplete list (always iterated over for only a single format)
Does anyone know what is causing this inconsistency and what the solution is to fix it?
Continue reading...
I've already tried impersonating the logged-on user, but that did not help. Impersonation was successful, but the iteration over EnumClipboardFormats still ended after giving me the first format.
For clarity, these are the test cases:
1. Run the app as the logged-on user + update the clipboard with a standard format (plain-text from notepad) = Iterated enum returns the full list of formats
2. Run the app as the logged-on user + update the clipboard with a registered format (RTF text from MS Word) = Iterated enum returns the full list of formats
3. Run the app as Local System + update the clipboard with a standard format (plain-text from notepad) = Iterated enum returns the full list of formats
4. Run the app as Local System + update the clipboard with a registered format (RTF text from MS Word) = Iterated enum returns an imcomplete list (always iterated over for only a single format)
Does anyone know what is causing this inconsistency and what the solution is to fix it?
Continue reading...