Results 1 to 3 of 3

Thread: Signal when computer locks

  1. #1
    Join Date
    Mar 2014
    Location
    USA
    Posts
    82
    Thanks
    16
    Thanked 2 Times in 2 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Signal when computer locks

    I'm working in a Windows environment. I have a program that needs to perform a function when the computer locks, whether it's by command + L or time-out. How can I get this? In a windows forum, they gave me the suggestion to use WM_WTSSESSION_CHANGE and then wParam WTS_SESSION_LOCK in the nativeEvent. The only thing is, you have to run WTSRegisterSessionNotification first. I can't run WTSRegisterSessionNotification, because it doesn't seem to exist when I try to call it in the constructor. Is there a way to do this using Qt or does anybody know how to get nativeEvent to see it?
    Last edited by TonyInSoMD; 6th February 2018 at 16:17. Reason: updated contents

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,709
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Signal when computer locks

    I can't run WTSRegisterSessionNotification, because it doesn't seem to exist when I try to call it in the constructor.
    Amm... include the header file declaring it maybe?
    (And don't forget to link against the lib defining it too)
    https://msdn.microsoft.com/en-us/lib...(v=vs.85).aspx
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  3. The following user says thank you to high_flyer for this useful post:

    TonyInSoMD (7th February 2018)

  4. #3
    Join Date
    Mar 2014
    Location
    USA
    Posts
    82
    Thanks
    16
    Thanked 2 Times in 2 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Signal when computer locks

    Thanks, that's what it was, I was forgetting the #include and #pragma statements in the constructor. My only excuse is I don't deal with Windows events very much, I stick to Qt as much as possible.

Similar Threads

  1. QFileSystemWatcher locks directory
    By NehaGupta in forum Qt Programming
    Replies: 0
    Last Post: 3rd September 2014, 13:42
  2. QReadWriteLock locks for reading...but why?
    By Qtonimo in forum Qt Programming
    Replies: 5
    Last Post: 29th August 2012, 11:58
  3. QwtPlotZoomer locks up, possibly bug?
    By Neekeetos in forum Qwt
    Replies: 12
    Last Post: 10th February 2012, 12:49
  4. Replies: 2
    Last Post: 28th December 2010, 06:20
  5. QThread locks my gui ??
    By LordQt in forum Qt Programming
    Replies: 8
    Last Post: 8th December 2008, 19:53

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.