CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 15 of 15
  1. #1
    Join Date
    Oct 2015
    Posts
    5

    Windows CE restart every 24 hours

    Hello,

    I want to restart my Windows CE Controller every 24 hours because my Webserver applications has run out of memory and a restart will fix the problem.
    I read that I have to put an EXE file for it in the Windows Startup folder. Which code I need to generate the EXE File.
    Or are there any other solutions?

    Thanks

    Bye

  2. #2
    Join Date
    Nov 2003
    Posts
    1,902

    Re: Windows CE restart every 24 hours

    What version is CE is it?
    Do you have the ability to "remote run" an application on the device? Or even put new files on the device?

    gg

  3. #3
    Join Date
    Oct 2015
    Posts
    5

    Re: Windows CE restart every 24 hours

    The version is Windows Embedded Compact 7.
    I only have the option to make a remote via network with the program CERHOST.EXE

    gg

  4. #4
    Join Date
    Nov 2003
    Posts
    1,902

    Re: Windows CE restart every 24 hours

    gg is my signature

    x86 or ARM? Do have an IDE to compile programs for your target?

    gg

  5. #5
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,825

    Re: Windows CE restart every 24 hours

    I want to restart my Windows CE Controller every 24 hours because my Webserver applications has run out of memory
    Isn't the real question why it keeps running out of memory? Is there a memory leak somewhere?
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++23 Compiler: Microsoft VS2022 (17.6.5)

  6. #6
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,635

    Re: Windows CE restart every 24 hours

    Quote Originally Posted by 2kaud View Post
    Isn't the real question why it keeps running out of memory? Is there a memory leak somewhere?
    That's what I was thinking. Regardless, restarting the program should be sufficient.

  7. #7
    Join Date
    Mar 2001
    Posts
    2,529

    Re: Windows CE restart every 24 hours

    May we ask if it is a homegrown solution or is it a commercially available product with a memory leak?
    ahoodin
    To keep the plot moving, that's why.

  8. #8
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: Windows CE restart every 24 hours

    Can you restart the webservice application?

  9. #9
    Join Date
    Oct 2015
    Posts
    5

    Re: Windows CE restart every 24 hours

    It's ARM and donÄt have an IDE yet.

    Yes thats the right question but I checked it and it looks like the windows CE network connection. If there comes many network terminations (which is normal in WLAN networks) the webserver applications runs out of memory.
    So the easiest way to fix the problem is to restart the controller every day at 00:00 am because the error comes every two days.

  10. #10
    Join Date
    Nov 2003
    Posts
    1,902

    Re: Windows CE restart every 24 hours

    The easiest solution is probably to get a wall socket timer: http://www.amazon.com/s/?ie=UTF8&key...l_6wo46poof5_b

    There is no standard support for a programmatic "reboot" in CE. You would need that support in a "board SDK" provided by the OEM. (I forgot that's what I've been using on CE, but using ExitWindowsEx() for everything else...)

    gg

  11. #11
    Join Date
    Mar 2001
    Posts
    2,529

    Re: Windows CE restart every 24 hours

    ahoodin
    To keep the plot moving, that's why.

  12. #12
    Join Date
    Nov 2003
    Posts
    1,902

    Re: Windows CE restart every 24 hours

    Good find. Looks like SetSystemPowerState(NULL, POWER_STATE_RESET, 0) is the standard way to "reboot" in CE.

    gg

  13. #13
    Join Date
    Oct 2015
    Posts
    5

    Re: Windows CE restart every 24 hours

    Thanks!

    What do you think about it:

    Code:
    #include "stdafx.h"
    #include <windows.h>
    #include <commctrl.h>
    #include <Pm.h>
    
    int _tmain(int argc, _TCHAR* argv[])
    {
        SYSTEMTIME tSysTime;
        GetSystemTime(&tSysTime);
    
        if (tSysTime.wYear!= 2005)
        {
            int delay = 1000 *60 * 60 * 48;// 48 Hrs
            Sleep(delay);
    
            //windows Mobile
            //ExitWindowsEx(2,0);
    
            //windows CE
            return (int)SetSystemPowerState(NULL, POWER_STATE_RESET, 0);
    
        }
    
        return 0;
    }
    Can I easly compile it with Dev-C++?

  14. #14
    Join Date
    Oct 2015
    Posts
    5

    Re: Windows CE restart every 24 hours

    or like this:

    Code:
    [DllImport("coredll.dll")]
        private static extern bool KernelIoControl(Int32 IoControlCode, IntPtr InputBuffer, Int32 InputBufferSize, byte[] OutputBuffer, Int32 OutputBufferSize, ref Int32 BytesReturned);
        private const uint FILE_DEVICE_HAL = 0x00000101;
        private const uint METHOD_BUFFERED = 0;
        private const uint FILE_ANY_ACCESS = 0;
    
        private static uint CTL_CODE(uint DeviceType, uint Function, uint Method, uint Access)
        {
            return ((DeviceType << 16) | (Access << 14) | (Function << 2) | Method);
        }
    
        public static void softReset()
        {
            byte[] OutputBuffer = new byte[256];
            Int32 OutputBufferSize, BytesReturned;
            OutputBufferSize = OutputBuffer.Length;
            BytesReturned = 0;
    
            Int32 IOCTL_HAL_REBOOT = (Int32)CTL_CODE(FILE_DEVICE_HAL, 15, METHOD_BUFFERED, FILE_ANY_ACCESS);
    
            KernelIoControl(IOCTL_HAL_REBOOT, IntPtr.Zero, 0, OutputBuffer, OutputBufferSize, ref BytesReturned);
        }
    http://stackoverflow.com/questions/1...-with-emdk-2-6
    Last edited by Dennis2015; October 13th, 2015 at 01:47 AM.

  15. #15
    Join Date
    Nov 2003
    Posts
    1,902

    Re: Windows CE restart every 24 hours

    For C++, you'll need a "board sdk" from the OEM. It will integrate with VS 2008 or higher. This will allow you to build targets for that device.

    For .NET I have no idea.

    gg

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured