locked
how to lock unlock the smartphone screen RRS feed

  • Question


  • Hi,
    I m developing the application for locking/unlocking the screen of the smartphone
    Can anybody tell to make an application C# to  lock the screen say after 1 min and the unlock it after entering some password




    Wednesday, October 3, 2007 7:43 AM

Answers

  • Hi,

     

     eranshuman wrote:
    My application make the mobile to set in low state means backlight switched off/screen should get lock
    when user press any key my application should ask the password and on right password then it should start the mobile.

     

    You may like to investigate PInvoking the native OS API called SHDeviceLockAndPrompt (documented at http://msdn2.microsoft.com/en-us/library/aa456040.aspx). Depending upon the range of devices you aim to target (and/or if you code sign your application) you may find this API will do what you want.

     

    You may also find the following chat transcript of interest (from http://msdn.microsoft.com/chats/transcripts/mobileembedded/06_0628_msdn_wince.aspx):

     

    Code Block
    MikeCal [msft] (Expert):
    Q: #4. Is there a way to do a DEVICE LOCK, KEYBOARD LOCK, FLIGHT MODE, etc. programmatically as the Quick List (quickapp.exe) does? I can shell to quickapp.exe and use keybd_event(), but that is totally a hack and not fool proof.
    A: On smartphone, the easiest way to keyboard lock is keybd_event a VK_APP6 (0xC6). On PPCs with keylock (AKU2 and later) the easiest way is to keybd_event VK_KEYLOCK (aka VK_F22). Later smartphones (AKU3 I believe) will move to VK_KEYLOCK as well. In the future there will be an API for DeviceLock called SHDeviceLockAndPrompt() but it hasn't been exposed in an SDK yet. I don't know about flight mode.

     

     

    If you search these forums you should be able to find PInvoke examples for accessing the keybd_event function.

     

    Hope this helps,

    Christopher Fairbairn

    Monday, October 8, 2007 11:09 PM

All replies

  • Hi eranshuman,

    lock means , screen should lock and the current desktop will live till give right password , no other application run till use pass the screen with right password.
    i am going right or wrong?

    say  me.
    bay
    rajat.
    Monday, October 8, 2007 11:24 AM

  • Yes you are right
    My application make the mobile to set in low state means backlight switched off/screen should get lock
    when user press any key my application should ask the password and on right password then it should start the mobile.

    If you can help me how can I do it

    thanks and regards
    Monday, October 8, 2007 5:33 PM
  • Hi,

     

     eranshuman wrote:
    My application make the mobile to set in low state means backlight switched off/screen should get lock
    when user press any key my application should ask the password and on right password then it should start the mobile.

     

    You may like to investigate PInvoking the native OS API called SHDeviceLockAndPrompt (documented at http://msdn2.microsoft.com/en-us/library/aa456040.aspx). Depending upon the range of devices you aim to target (and/or if you code sign your application) you may find this API will do what you want.

     

    You may also find the following chat transcript of interest (from http://msdn.microsoft.com/chats/transcripts/mobileembedded/06_0628_msdn_wince.aspx):

     

    Code Block
    MikeCal [msft] (Expert):
    Q: #4. Is there a way to do a DEVICE LOCK, KEYBOARD LOCK, FLIGHT MODE, etc. programmatically as the Quick List (quickapp.exe) does? I can shell to quickapp.exe and use keybd_event(), but that is totally a hack and not fool proof.
    A: On smartphone, the easiest way to keyboard lock is keybd_event a VK_APP6 (0xC6). On PPCs with keylock (AKU2 and later) the easiest way is to keybd_event VK_KEYLOCK (aka VK_F22). Later smartphones (AKU3 I believe) will move to VK_KEYLOCK as well. In the future there will be an API for DeviceLock called SHDeviceLockAndPrompt() but it hasn't been exposed in an SDK yet. I don't know about flight mode.

     

     

    If you search these forums you should be able to find PInvoke examples for accessing the keybd_event function.

     

    Hope this helps,

    Christopher Fairbairn

    Monday, October 8, 2007 11:09 PM

  • I have used aygshell.dll for SHDeviceLockAndPrompt'
     I got the following error :
    Can't find an Entry Point 'SHDeviceLockAndPrompt' in a PInvoke DLL 'aygshell.dll'

    I have found in net but I m not able to get aygshell.dll which support this SHDeviceLockAndPrompt' function.
    Please help me to get the desired dll

    Or there is any method in Windows Mobile 5.0 to which I can lock or unlock phone

    PS:I m using Windows Mobile 5.0 version.

    Thanks and regards
    Tuesday, October 9, 2007 6:16 PM
  • this function works for mobile with WinCE verison 5.1 (MDA Pro with AKU2.0 [OS 5.1.195 Build 14847.2.0.0])

    If you have Windows mobile 6.0 SDK, you can call this funtion.

     

    [DllImport("aygshell.dll")]

    public extern static IntPtr SHDeviceLockAndPrompt();

     

    IntPtr hresult=SHDeviceLockAndPrompt();

    The return value is 0 [S_Ok] but still i am not able to lock the device.

     

    Ref. to msdn documentation http://msdn2.microsoft.com/en-us/library/aa456040.aspx

     

    Friday, November 16, 2007 5:33 AM
  •  keyur47831 wrote:

    this function works for mobile with WinCE verison 5.1 (MDA Pro with AKU2.0 [OS 5.1.195 Build 14847.2.0.0])

    If you have Windows mobile 6.0 SDK, you can call this funtion.

     

    [DllImport("aygshell.dll")]

    public extern static IntPtr SHDeviceLockAndPrompt();

     

    IntPtr hresult=SHDeviceLockAndPrompt();

    The return value is 0 [S_Ok] but still i am not able to lock the device.

     

    Ref. to msdn documentation http://msdn2.microsoft.com/en-us/library/aa456040.aspx

     

    hello,i am new in wm.i have the same problem ,have you had work out it

    Tuesday, October 28, 2008 3:59 AM
  • Probably you do not configure the PIN Lock in your device, you must go to Start->Settings->Lock, configure one pin and try again your program.

     

    Tuesday, November 18, 2008 10:54 AM
  • Hi all,

    it is some thing I expecting hard overhere.. to get answer my question ...

    I tried to use the SHDeviceLockAndPromt() but not working for me in WM Professional device. Inplace of that I use

     

    keybd_event() which works fine for me.

    I want to lock the phone if it is not in use i.e. kept idle for sometime, say 5 min, It should display some screen saver or my application screen, but I am not able to acheive it .

    If any one have a idea of it please help me ..

    Thanks in advance

    Tina

    Wednesday, August 18, 2010 5:35 AM