• How do safe shutdown programmatically?

    From Andi B.@21:1/5 to All on Sun Oct 29 13:01:08 2017
    Hi,
    I want to shut down the system from my program. I can do it the ACPI toolkit way -

    AcpiTkPrepareToSleep(ACPI_STATE_S5);
    rc = DosShutdown(0L);
    DosSleep(3000); /* Wait allows shutdown to complete */
    rc = AcpiTkGoToSleep(&Hdl, ACPI_STATE_S5);

    But PowerOff.c still states 'Created 2005 eCo Software'. I'm pretty sure the code is
    changed by David afterwards but usually when he does he adds name and date. So I'm not
    sure if this is really the latest and best way to shut down / power off. Moreover this
    code does shut down my T60 so fast that I think running application may not have a chance
    to properly close down and save files before shutting down.

    I want a clean shut down like xwp extended shutdown feature. With all application closes
    cleanly. So I guess I could call some xwp code to to it for me. But how to do? Is there a
    xwp api to start extended shut down?

    If I would send a WM_QUIT myself to all running programs I think this would be reinventing
    the wheel again. On the other hand if I would let some other program send WM_QUIT to all
    programs, my own program will get it too and may close before I can AcpiTkGoToSleep. I
    would need to assure my program is the last one which is closed in this scenario.

    I can call some system(shutdown.exe). But which one is the best? I tried the default on my
    T60 installation (upgraded eCS2.x) and it end up with the message box - shutdown completed
    you can now power off the system. But I don't want to power off by myself. That's the task
    of ACPI (APM on older systems).

    AcpiStat poweroff does the same as the Acpi toolkit poweroff. At least when looking at the
    sources from -
    * Rewritten by: David Azarewicz
    * Copyright (c) 2011-2012 Mensys BV

    No clue where I got it. Are there newer versions available?

    Any thoughts welcome.

    Andreas

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Andi B.@21:1/5 to All on Sun Oct 29 12:58:32 2017
    Hi,
    I want to shut down the system from my program. I can do it the ACPI toolkit way -

    AcpiTkPrepareToSleep(ACPI_STATE_S5);
    rc = DosShutdown(0L);
    DosSleep(3000); /* Wait allows shutdown to complete */
    rc = AcpiTkGoToSleep(&Hdl, ACPI_STATE_S5);

    But PowerOff.c still states 'Created 2005 eCo Software'. I'm pretty sure the code is
    changed by David afterwards but usually when he does he adds name and date. So I'm not
    sure if this is really the latest and best way to shut down / power off. Moreover this
    code does shut down my T60 so fast that I think running application may not have a chance
    to properly close down and save files before shutting down.

    I want a clean shut down like xwp extended shutdown feature. With all application closes
    cleanly. So I guess I could call some xwp code to to it for me. But how to do? Is there a
    xwp api to start extended shut down?

    If I would send a WM_QUIT myself to all running programs I think this would be reinventing
    the wheel again. On the other hand if I would let some other program send WM_QUIT to all
    programs, my own program will get it too and may close before I can AcpiTkGoToSleep. I
    would need to assure my program is the last one which is closed in this scenario.

    I can call some system(shutdown.exe). But which one is the best? I tried the default on my
    T60 installation (upgraded eCS2.x) and it end up with the message box - shutdown completed
    you can now power off the system. But I don't want to power off by myself. That's the task
    of ACPI (APM on older systems).

    AcpiStat poweroff does the same as the Acpi toolkit poweroff. At least when looking at the
    sources from -
    * Rewritten by: David Azarewicz
    * Copyright (c) 2011-2012 Mensys BV

    No clue where I got it. Are there newer versions available?

    Any thoughts welcome.

    Andreas

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Andreas Schnellbacher@21:1/5 to Andi B. on Wed Nov 1 21:21:43 2017
    On 29.10.17 12:58, Andi B. wrote:

    I want a clean shut down like xwp extended shutdown feature. With all application
    closes cleanly.

    Then you should probably better use XWP funcs.

    So I guess I could call some xwp code to to it for me. But how to do? Is there a
    xwp api to start extended shut down?

    The file "xworkplace\branch-1-0\src\startshut\shutdown.c" looks interesting.

    --
    Andreas Schnellbacher

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Andi B.@21:1/5 to Andreas Schnellbacher on Fri Nov 3 17:58:55 2017
    Andreas Schnellbacher schrieb:
    On 29.10.17 12:58, Andi B. wrote:

    I want a clean shut down like xwp extended shutdown feature. With all application
    closes cleanly.

    Then you should probably better use XWP funcs.

    So I guess I could call some xwp code to to it for me. But how to do? Is there a
    xwp api to start extended shut down?

    The file "xworkplace\branch-1-0\src\startshut\shutdown.c" looks interesting.


    I think there must be a simpler method than integrating xwp code in my
    own program. Something like 'send xwp (xcenter) button extended
    shutdown'. Maybe the sendmsg package can do something like this?

    Andreas

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Andi B.@21:1/5 to Andi B. on Sun Nov 5 11:31:45 2017
    Andi B. schrieb:
    Andreas Schnellbacher schrieb:
    On 29.10.17 12:58, Andi B. wrote:

    I want a clean shut down like xwp extended shutdown feature. With all application
    closes cleanly.

    Then you should probably better use XWP funcs.

    So I guess I could call some xwp code to to it for me. But how to do? Is there a
    xwp api to start extended shut down?

    The file "xworkplace\branch-1-0\src\startshut\shutdown.c" looks interesting. >>

    I think there must be a simpler method than integrating xwp code in my
    own program. Something like 'send xwp (xcenter) button extended
    shutdown'. Maybe the sendmsg package can do something like this?

    Andreas

    Just found \XWorkplace\bin\xshutdwn.cmd. It's as simple as system("xshutdwn.cmd");

    Solved. :-)

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Andi B.@21:1/5 to Andi B. on Sun Nov 5 13:40:28 2017
    Andi B. schrieb:
    Andi B. schrieb:
    Andreas Schnellbacher schrieb:
    On 29.10.17 12:58, Andi B. wrote:

    I want a clean shut down like xwp extended shutdown feature. With all application
    closes cleanly.

    Then you should probably better use XWP funcs.

    So I guess I could call some xwp code to to it for me. But how to do? Is there a
    xwp api to start extended shut down?

    The file "xworkplace\branch-1-0\src\startshut\shutdown.c" looks interesting.


    I think there must be a simpler method than integrating xwp code in my
    own program. Something like 'send xwp (xcenter) button extended
    shutdown'. Maybe the sendmsg package can do something like this?

    Andreas

    Just found \XWorkplace\bin\xshutdwn.cmd. It's as simple as system("xshutdwn.cmd");

    Solved. :-)

    Even better -
    object = WinQueryObject("<WP_DESKTOP>");
    fSuccess = WinSetObjectData(object,"XSHUTDOWNNOW=POWEROFF,NOCONFIRM;");

    Andreas

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Lars Erdmann@21:1/5 to Andi B. on Sun Nov 5 15:36:39 2017
    Just for the record:

    if you want to have PM applications notified on shutdown you need to use "WinShutdownSystem" API function. That will also eventually call
    DosShutdown.

    Lars


    Andi B. schrieb:
    Andi B. schrieb:

    Even better -
    object = WinQueryObject("<WP_DESKTOP>");
    fSuccess = WinSetObjectData(object,"XSHUTDOWNNOW=POWEROFF,NOCONFIRM;");

    Andreas


    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Pete@21:1/5 to Andi B. on Wed Feb 6 02:14:04 2019
    Hi

    Andi B. wrote:
    Andi B. schrieb:
    Andi B. schrieb:
    Andreas Schnellbacher schrieb:
    On 29.10.17 12:58, Andi B. wrote:

    I want a clean shut down like xwp extended shutdown feature. With
    all application
    closes cleanly.

    Then you should probably better use XWP funcs.

    So I guess I could call some xwp code to to it for me. But how to
    do? Is there a
    xwp api to start extended shut down?

    The file "xworkplace\branch-1-0\src\startshut\shutdown.c" looks
    interesting.


    I think there must be a simpler method than integrating xwp code in my
    own program. Something like 'send xwp (xcenter) button extended
    shutdown'. Maybe the sendmsg package can do something like this?

    Andreas

    Just found \XWorkplace\bin\xshutdwn.cmd. It's as simple as
    system("xshutdwn.cmd");

    Solved. :-)

    Even better -
    object = WinQueryObject("<WP_DESKTOP>");
    fSuccess = WinSetObjectData(object,"XSHUTDOWNNOW=POWEROFF,NOCONFIRM;");

    Andreas



    I was looking into adding reboot capability to an app, USBcfg, and
    noticed this thread.

    Changing the above slightly for use with the WDSibyl pascal "dialect"
    and using REBOOT instead of POWEROFF works great.

    Dobject = WinQueryObject('<WP_DESKTOP>');
    fSuccess = WinSetObjectData(object,'XSHUTDOWNNOW=REBOOT,NOCONFIRM;');


    Thanks.


    Pete

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)