Jump to content

Recommended Posts

So I am looking to write something that would detect if a laptop is docked or not. I am thinking the simple way is to detect if a certain nic card is present since all of my docks have the same hardware device type for the nic.

What I need help with is how to make this work to read when the laptop is docked and undocked. and how to make the program run without eating memory I found sleeping isn't effective but maybe that's me

thanks for the help

UPDATE 1:
Maybe looking at the key will work better for docking. But how to make it know when the state changes from a 1 to a 2?

HKLM\SYSTEM\CurrentControlSet\Control\IDConfigDB\CurrentDockInfo\DockingState

 

Edited by eagle4life69
Link to post
Share on other sites
3 minutes ago, JLogan3o13 said:

@eagle4life69 Dog ate your help file? Look at RegRead in the help file.

I understand how to read the registry but how do I loop it over and over again? so about 1000 checks a minute?

at some point would I not just eat memory? I'm looking for better programming than just doing a while loop with a sleep(50)

Edited by eagle4life69
Link to post
Share on other sites
  • Moderators

Maybe a While Loop?

While RegRead(<KeyName>, <ValueName>) = "Value"
    Sleep(100)
WEnd

MsgBox(0, "", "Value Changed!")

 

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to post
Share on other sites
  • 3 years later...
On 10/31/2017 at 9:31 AM, eagle4life69 said:

Maybe looking at the key will work better for docking. But how to make it know when the state changes from a 1 to a 2?

HKLM\SYSTEM\CurrentControlSet\Control\IDConfigDB\CurrentDockInfo\DockingState

 

I am assuming this only works if your laptop dock is the type that has an eject button because it does not work for the docking station I have for the Thinkpad T510. I do not consider this to be a port replicator but may Windows OS does . The dock station I have for T510 has a key lock; power button; no eject button; uses the connector located in the middle underside of laptop; and has various ports. It is a Thinkpad branded docking station and everything else works fine when laptop is docked. 

I set "DockingState" value manually to "4" and rebooted while docked. "DockingState" updated to "1". Windows 7 start menu had no undock option so I assume this is not considered docking station by Windows.
    
I could count the number of USB ports as an indicator of docked state but that is not a generic solution if I want code that work for many brands of laptop / dock stations. Any ideas what to check to detect the docked state for this category of docking stations (ie those with no eject button)?
    

Edited by ScottQ
revised info
Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...