title: Get current laptop lid state
body: <p>I'm writing a C# app (specifically for laptops) and I want to be aware of the state of the lid, i.e. when is it open and when is it closed.</p>
  
  <p>I've already used pInvoke along with <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/aa373196(v=vs.85).aspx" rel="nofollow noreferrer">Microsoft's RegisterPowerSettingNotification function</a> with the help of <a href="https://stackoverflow.com/questions/3355606/detect-laptop-lid-closure-and-opening">this SO answer</a>.</p>
  
  <p>So, with the above I know when the lid is being closed or opened and know its state,
  BUT I want to get the state of the lid before anything else continues. 
  I've noticed that even if there is no change to the lid, the callback function is called and I can check its parameter to know the lid's state, but this not good for me since it is an event and I can't simply wait for it to occur (maybe there's another way to work around this?). </p>
  
  <p>I've also tried PowerEnumerate function but couldn't get something from it (maybe there is something I don't know there that could help)</p>
  
  <p>EDIT 1:
  I can't wait or delay the app, and there are 2 issues that require me to get the state without a CB, the first is that a lid can be closed while the laptop is connected to a monitor thus allowing the user to use the laptop. If the user starts the app in this situation it should not start.
  The second reason is that I want the app to be user friendly and notify what happens when it starts or stops, and if I get the cb in the wrong time it might be ignored, due to the app's inner logic, and then will have to wait until the next time I get a cb, I'd at all. </p>
  
  <p>So, (no pun intended) 
  Is there a way to get this information right away?</p>
  
  <p>EDIT 2:
  It seems from comments that it's not clear what I need. I need a way to query to state of the lid. i.e. - call some API or something and that the return value is the state.
  thanks!</p>
  
  <p>Keywords: GUID_LIDSWITCH_STATE_CHANGE , WM_POWERBROADCAST, Power Setting </p>