locked
windows mobile 6.1 wifi always on RRS feed

  • Question

  • hi, I am using the following code to change the registry setting to keep wifi always on in a win mo 5 app, it works perfect.  user press power button, screen turn off but wifi stays on.  but when used in win mo 6.1 the screen will turn off and turn right back on, the wifi does stays on. what could be the problem? i tried changing other setting in the power states, but no luck. 

     

     

            void EnableWifiOn()

            {

                    Microsoft.Win32.RegistryKey regPowerState = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(@"\SYSTEM\CurrentControlSet\Control\Power\State\Suspend", true);

                    regPowerState.SetValue("Default", "1", Microsoft.Win32.RegistryValueKind.DWord);

                    regPowerState.SetValue("Flags", "65536", Microsoft.Win32.RegistryValueKind.DWord);

                    Microsoft.Win32.RegistryKey regSuspend = regPowerState.OpenSubKey(@"\{98C5250D-C29A-4985-AE5F-AFE5367E5006}", true);

                    regSuspend.SetValue("Default", "1", Microsoft.Win32.RegistryValueKind.DWord);

                    menuItem6.Checked = true;

            }

     

            void DisableWifiOn()

            {

                    Microsoft.Win32.RegistryKey regPowerState = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(@"\SYSTEM\CurrentControlSet\Control\Power\State\Suspend", true);

                    regPowerState.SetValue("Default", "3", Microsoft.Win32.RegistryValueKind.DWord);

                    regPowerState.SetValue("Flags", "2097152", Microsoft.Win32.RegistryValueKind.DWord);

                    Microsoft.Win32.RegistryKey regSuspend = regPowerState.OpenSubKey(@"\{98C5250D-C29A-4985-AE5F-AFE5367E5006}", true);

                    regSuspend.SetValue("Default", "4", Microsoft.Win32.RegistryValueKind.DWord);

                    menuItem6.Checked = false;

            }

     

    Thursday, December 8, 2011 6:15 PM

All replies

  • You can use IOCTL_NDISUIO_REQUEST_NOTIFICATION to request a notification when the system wants to power down the radio with NDISUIO_NOTIFICATION_DEVICE_POWER_DOWN.

    When you receive that notification on a message queue, issue a SetDevicePower to the radio to put it in state D0.

    Something like this (warning, uncompiled code ahead:

     

        NDISUIO_REQUEST_NOTIFICATION ndisRequestNotification = { 0 };
        ndisRequestNotification.hMsgQueue = readQueue;
        ndisRequestNotification.dwNotificationTypes = NDISUIO_NOTIFICATION_DEVICE_POWER_DOWN;
        if( !DeviceIoControl( ndis_device_handle, 
                              IOCTL_NDISUIO_REQUEST_NOTIFICATION, 
                              &ndisRequestNotification, 
                              sizeof( NDISUIO_REQUEST_NOTIFICATION ), 
                              NULL, 
                              0, 
                              NULL, 
                              NULL ) )
        {
            // failure
            return 0;
        }
    
        NDISUIO_DEVICE_NOTIFICATION ndisDeviceNotification = { 0 };
        DWORD dwBytesReturned = 0;
        DWORD dwFlags = 0;
    
            if( ReadMsgQueue( readQueue, 
                              &ndisDeviceNotification, 
                              sizeof( NDISUIO_DEVICE_NOTIFICATION ), 
                              &dwBytesReturned, 
                              1, 
                              &dwFlags ) == TRUE )
            {
                if( ndisDeviceNotification.dwNotificationType == NDISUIO_NOTIFICATION_DEVICE_POWER_DOWN )
                {
                    SetDevicePower( command, POWER_NAME, D0 );
                }
            }
    
    

     

     

    -PaulH


    • Edited by PaulH79 Thursday, December 8, 2011 10:07 PM
    Thursday, December 8, 2011 10:03 PM
  • oh.. and end with IOCTL_NDISUIO_CANCEL_NOTIFICATION

     

    DeviceIoControl( ndis_device_handle, 
                     IOCTL_NDISUIO_CANCEL_NOTIFICATION, 
                     NULL,
                     NULL, 
                     NULL, 
                     0, 
                     NULL, 
                     NULL );
    
    

    Thursday, December 8, 2011 10:06 PM
  • cant seems to get it to work, do i need to import any system dll? do you have any sample? thanks
    Thursday, December 8, 2011 10:33 PM
  • Hello,

     

    To use the DeviceIoControl API, you need to P/Invoke this API first in your C# codes. please follow this thread:

    DeviceIoControl and PInvoke advice

     

    Best regards,

    Jesse


    Jesse Jiang [MSFT]
    MSDN Community Support | Feedback to us
    Monday, December 12, 2011 6:30 AM
  • that dont look like is the solution i am looking for.  i still need to handle when the user press the power btn with the that solution.  if only any one know whats the difference between win mo 5 and win mo 6 reg setting, i could just do it the way I do it in win mo5, please help. any one.
    Tuesday, December 13, 2011 12:04 AM
  • They are should be the same in document

    http://msdn.microsoft.com/en-us/library/aa931213.aspx

    http://msdn.microsoft.com/en-us/library/ms892149.aspx


    NEU_ShieldEdge
    Tuesday, December 13, 2011 6:07 AM