locked
How to unlock the device programmatically if PIN lock is used RRS feed

  • Question

  • If the user uses the lock function of Windows Mobile (using the pin or the alphanumeric  code), how can I programmatically unlock the device after stand-by to bring my app to the front and not have the user to unlock it first? All I found was the SHDeviceLockAndPrompt function, but this locks the device and I need to unlock it.
    Can this be done? In particular on WM 6.5 the locking mechanism has changed, so sending keyboard keys to the lock window will not work anymore.
    Searched about this for a very long time with no luck but I guess there must be a way to do this because if a phone call is arriving the dialer app is able to unlock the device programmatically. The user can instantly answer the call without having to unlock it first.

    Thanks in advance...
    Tuesday, July 7, 2009 7:21 PM

Answers

  • I used SHDeviceLockAndPrompt() on smartphone and always able to unlock the device.

    I can suggest one alternative if in case non of the other member can help you out :-

    To receive normal keyboard input while locked, your application's window should set the WS_EX_ABOVESTARTUP EXSTYLE using SetWindowLong(). When activated, your application will appear above the lock window and can operate normally. You must exercise caution to avoid security breaches when using this mechanism.

    #define WS_EX_ABOVESTARTUP         0x20000000L

    I tried this long back and i tell u this was always successful.


    Thanks
    Arpit Pradhan
    WinCE CODER
    • Marked as answer by MSWiege Wednesday, July 8, 2009 3:01 PM
    Wednesday, July 8, 2009 11:37 AM

All replies

  • Don't know how to do it if it has been locked with CPL locking system (especially alphanumeric), but if You need to unlock a phone just like writting a PIN, You can do it via SimUnlockPhone . You just need to do SimInitialize(0, 0, 0, &hSim) and use the handle given.
    If You'll find my answer satisfactory or helpful - mark it as answered! Thank You. PS. Votes also doesn't hurt :).
    Tuesday, July 7, 2009 7:37 PM
  • As far as I understand the documentation about SimUnlockPhone, this helps only to unlock the SIM card to access information on the card. But I will have a closer look into it anyway...

    I need a function to unlock the phone that is locked because of the users settings at Start->Settings->Lock
    Wednesday, July 8, 2009 6:33 AM
    • Edited by Amit Rote Wednesday, July 8, 2009 7:27 AM added link
    Wednesday, July 8, 2009 7:25 AM
  • I already read that thread multiple times but it only covers on how to lock the device (despite the title of the thread). That is no problem using the mentioned function above (SHDeviceLockAndPrompt).
    I need the phone to get automatically unlocked like the dialer does if a call is received.
    Wednesday, July 8, 2009 7:30 AM
  • I used SHDeviceLockAndPrompt() on smartphone and always able to unlock the device.

    I can suggest one alternative if in case non of the other member can help you out :-

    To receive normal keyboard input while locked, your application's window should set the WS_EX_ABOVESTARTUP EXSTYLE using SetWindowLong(). When activated, your application will appear above the lock window and can operate normally. You must exercise caution to avoid security breaches when using this mechanism.

    #define WS_EX_ABOVESTARTUP         0x20000000L

    I tried this long back and i tell u this was always successful.


    Thanks
    Arpit Pradhan
    WinCE CODER
    • Marked as answer by MSWiege Wednesday, July 8, 2009 3:01 PM
    Wednesday, July 8, 2009 11:37 AM
  • Thank you Arpit, the WS_EX_ABOVESTARTUP style sound good, I will definitely have a look into that!

    The SHDeviceLockAndPrompt() always did what the docs say it should do on the PocketPCs I testet it on:
    If the app calls this function the device gets locked and WM asks for the PIN code. If the device already was locked while the app calls this function nothing happens.
    Exactly what the docs say: "This function puts the device into a lock state and prompts the user to unlock it."

    I'm really surprised why this function that should lock the device would unlock it on a smartphone?!?! Or is there some kind of misunderstanding between us?
    I want the device to get unlocked without the need of the user to enter his PN code.
    Wednesday, July 8, 2009 12:46 PM
  • Hey Arpit. The EXStYLE WS_EX_ABOVESTARTUP seems to do the trick for me. That's all I needed.
    Thanks!!!
    Wednesday, July 8, 2009 3:01 PM
  • Recently just broke my HTC Diamond touch screen. I am trying to connect to windows mobile device center but cannot authenticate device due to the screen broken. Is there a way to authenticate through my pc?
    Friday, November 20, 2009 6:15 PM