NetTalk Central

Author Topic: Rebooting in Code  (Read 3279 times)

Richard I

  • Sr. Member
  • ****
  • Posts: 398
    • View Profile
    • Email
Rebooting in Code
« on: July 07, 2024, 08:29:56 PM »
Hi
Re a reboot in Code...
I found this..

MY QUESTIONS: Can this be rewritten if necessary to run from a NT app and if so where do I source the Windows API Windows.inc
I copy and paste -
"In Clarion, you can reboot a computer using the EXECUTE statement to run the appropriate system command. Here?s how you can do it:

clarion
Copy code
PROGRAM
MAP
END

CODE
  INCLUDE('windows.inc')  ! Include Windows API declarations
  MAP
    MODULE('kernel32.dll')
      ExitWindowsEx(*CSTRING),BOOL,PROC
    END
  END

  CODE
    IF ExitWindowsEx('0', TRUE)
      MESSAGE('Reboot initiated successfully.')
    ELSE
      MESSAGE('Failed to initiate reboot.')
    END
  END
Explanation:
Windows API Declaration (windows.inc):

The INCLUDE('windows.inc') statement includes the necessary Windows API declarations needed for ExitWindowsEx.
ExitWindowsEx Function:

ExitWindowsEx is a Windows API function that can be used to shut down or reboot a computer. In this case, '0' is used to indicate a reboot.
Execution:

The ExitWindowsEx('0', TRUE) line attempts to initiate a reboot ('0' means reboot, TRUE means force reboot if necessary).
Message Handling:

Depending on the result of ExitWindowsEx, appropriate messages are displayed to indicate whether the reboot was successful or not."

Thanks
Richard

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Rebooting in Code
« Reply #1 on: July 08, 2024, 06:33:06 PM »
you _really_ do not want to reboot the whole machine.

Richard I

  • Sr. Member
  • ****
  • Posts: 398
    • View Profile
    • Email
Re: Rebooting in Code
« Reply #2 on: July 08, 2024, 07:21:43 PM »
Hi Bruce,
Thank you, but why not?
When the Virtual servers become unresponsive, from the Amazon Console, I select the machine and reboot.
This retains the IP address, and frees the memory
Is there a difference ?
Richard

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Rebooting in Code
« Reply #3 on: July 10, 2024, 08:15:09 PM »
this is like buying a new car because the old one is dirty.