After COM API call, getting EOSError Exceptions (access denied) but only when switching users or Locking the station on Windows 7
Asked Answered
P

2

2

I have a Delphi 6 application that is getting an EOSError Exception, code 5, access denied but only when I switch away to another Windows 7 user account, or I Lock the station. I am printing out a stack trace but the error appears to be coming straight from the Application.Run() statement with Application.ProcessMessages() immediately beneath it on the stack. The rest of the stack is my Exception handling code.

During operation the code does make calls to ShellExecuteEx() and accesses a COM/ActiveX object, but only when the user explicitly clicks a button. This only happens on Windows 7, not on Windows XP. I changed my application so that it installs completely to the user app data directory and therefore does not require access to any admin rights directories. I know that shouldn't matter but I'm pointing it out just in case.

When this happens the Exceptions come fast and furious. I trap them and dump them to an Error Log to avoid plaguing the user with a sea of dialog boxes. Can anyone tell me what would trigger a flood of these errors merely by switching away from or locking the currently logged-in user? Why would my app run into trouble when the current user account is not active?

One thought. Do some bitmap operations cause trouble if the user is not currently logged in? I do have a spinning tag cloud that does Windows API bitmap operations continually to update the tag cloud image. Could that have something to do with it?

If so, I could try deactivating the tag cloud when the current user is switched away or locked, but I believe I would need code for Delphi that reacts to the events mentioned in this Stack Overflow post:

How do I detect a Lock This Computer command from a WPF application?

UPDATE: I have done some additional testing. The errors do not occur until I access the COM/ActiveX interface for Evernote, the software I am interacting with. Once I make the first call to Evernote vai the COM API, the errors happen immediately when I Lock the station.

Perk answered 8/10, 2012 at 0:9 Comment(3)
For the base code for session lock/unlock/logon/logoff detection you can follow this post.Mcbrayer
@TLama. Thanks! BTW I've added an update to my orignal post. This is starting to seem like some weird problem between my app as a parent process and Evernote's ENScript.exe as a child process.Perk
Look at Explain errors from GetKeyState / GetCursorPos for a similar issue.Canaanite
P
2

I found the problem. It's because I am calling Controls.TMouse.GetCursorPos() on a timer to update the tag cloud view I mentioned in my original post. That function will raise an Exception if the current desktop is unavailable, like when you switch to another user account or Lock the station. This Stack Overflow post covers the issue from a general WinAPI context for the GetCursorPos() function.

Call to TMouse.GetCursorPos sometimes fails with "A call to an OS function failed"

In contrast to the author of the above post, it only happens to me on Windows 7 and not on Windows XP. I need to change my code to detect when the active desktop is no longer available and suppress that call using the session lock/unlock/logon/logoff detection techniques covered in the post linked below as suggested to me by TLama. See DavidHeffernan's answer:

What does an application have to do in order "support" Remote Desktop Services?

Perk answered 9/10, 2012 at 1:9 Comment(0)
A
1

If possible for your users to change your program to compatibility mode XP SP3 that may eliminate those errors. This is obviously a workaround.

You can use processmonitor along with filemon in order to see what is going on on windows: http://technet.microsoft.com/en-us/sysinternals/bb896645.aspx

for the full suite: http://technet.microsoft.com/en-us/sysinternals/bb842062

Adipose answered 8/10, 2012 at 10:37 Comment(3)
I have those utilities but I was wondering if they work with 64-bit Windows 7 properly?Perk
I have windows 7 64bit and processmon works fine. I have not used every tool in their excellent suite but never had problems due to my system being 64bit. On another note I'm a big fan of Evernote :) Hope your program increases it's usefulness.Adipose
@ - Thanks. Do a search for TagHunter in Google. I don't want to link to it here and be seen as promoting a product.Perk

© 2022 - 2024 — McMap. All rights reserved.