0

This is a coding question. Please read it before you flag it as belonging on ServerFault as the last one I wrote got thrown over there in less than 5 minutes.

I'm testing my win32/c++ application on XP which has the latest service packs. It contains two administrative user accounts both without passwords. I log in as User1 and start my app. The app runs, its main window appears and all is well with the world. I then log User1 off without first closing my app. Yes, I used "log off" not "switch user"

I then log in as User2 and my application is still running. I see it on the User 2 desktop, and I can even interact with it. It appears to be functioning normally. And task manager shows it running as User1.

Any ideas which might be going on here? Other applications (like notepad) don't exhibit this issue, yet mine does. Seems to me I'm doing something wrong in my code, but it really is a rather standard win32/c++ app. Perhaps I'm not processing some shutdown message properly? I'm sorry I can't give more specifics right now. I'm really hoping for some clue to spark further research.

SLaks
  • 868,454
  • 176
  • 1,908
  • 1,964
Charles
  • 2,642
  • 3
  • 33
  • 53
  • What do you expect when you log off? Should the app remain in the background but not accessible by anyone but the user who started it OR should it exit on logoff? – Jesse Vogt Jul 15 '09 at 18:44
  • I would expect a WM_QUERYENDSESSION followed by a WM_ENDSESSION and then the process is forcefully terminated. I'm not processing either message because I don't need to. – Charles Jul 15 '09 at 19:01
  • I think I found what is causing this, but it is a possible security issue with Windows XP. Rather than go into details that may be used for evil, I believe it is more prudent if an admin would delete this question. Thanks for all the suggestions, as they did help in my research. – Charles Jul 17 '09 at 13:25

3 Answers3

1

Are you sure your application isn't running as a service? A service with "Interact with Desktop" could look like this.

UPDATE: It must be somehow related to a service. A normal application, running in a session will be forced to close by Windows before the logoff is complete. Even if you don't handle the end session messages, Windows will tell the user about the nonresponding process and/or just kill it.

Murray
  • 680
  • 5
  • 8
1

Check windows task manager's for 2 things:

  1. "Session ID" column
    • "User Name" column

If either of these columns do not show up then select them from View -> Select columns.

Check which username and session your application that is staying open with is on. Then go and start notepad.exe and compare to the session ID and User Name that it is started with.

When you do a logoff it will close the applications running under your Session ID and username.

I'm guessing that your application is running in it's own session ID and/or username.

When you login with the other user it checks to see if it can re-use a session that is already started for the new username. So that is why you will see it running again when you login with the second user.

Brian R. Bondy
  • 339,232
  • 124
  • 596
  • 636
0

Do you need to be listening for a shutdown or logoff events?

Check out this answer for a similar question.

That answer refers to listening for WM_QUERYENDSESSION.

See WM_QUERYENDSESSION Message

Community
  • 1
  • 1
Jesse Vogt
  • 16,229
  • 16
  • 59
  • 72
  • You only need to listen for that if you intend to deal with those exits differently. Otherwise DefaultWindowProc(WM_QUERYENDSESSION) will send/post? you a WM_QUIT. – MSalters Jul 16 '09 at 11:32