en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en nl en en en en en en en de en en en en en nl en en en en en en en en en en en en sv en en en sv en en en en en en en nl en en en en en en en en en en en en en ar en en en en en en en en en en en en nl en en en en en en en en en en en en sv en en sv en en fi en nl en en en en en en es en en en en zh en en en en en en en de en en en en en en en en en nl en en nb en en en en en en en en en en en en en en en en sv en en en sv en en fi en nl vi en en en en en de en en en en en en en en en en nl en en en en en ar en en en en en nl fr en en en en en fi en nl en en en de en en en fr en en en en nl en en en en en en en en en fi en nl en en en en en en de en en en en en de en en en fr en en en en en en en en en pt en en en en en en
By logging into your account, you agree to our Privacy Policy, personal data processing and storage practices as described therein.
Forgot password or user name?
Search in titles only Search in PowerBASIC for Windows only
You are not logged in. You can browse in the PowerBASIC Community, but you must click Login (top right) before you can post. If this is your first visit, check out the FAQ or Sign Up.
All Time Today Last Week Last Month
All Discussions only Photos only Videos only Links only Polls only Events only
I am trying to write a Freeware 32-bit program that allows the user to rebbot his machine, power down, force power down, logoff, regular shutdown, and restart Windows. My problem arises when I try to use the Restart Windows options The code I'm trying follows:
My platform is a Dell 486SX-33 with 32MB of RAM. My OS is Windows 95 OSR-2. I have memory managers loading in my CONFIG.SYS (I need them because of my DOS-based BBS).
Your code means that you want to "LOGOFF" windows
Where have you found %EW_RESTARTWINDOWS ?
%EWX_REBOOT = &H00000002 If IsFalse ExitWindowsEx(%EWX_REBOOT,0) Then result& = GetLastError 'check why it doesn't work... End if
[This message has been edited by Fred Oxenby (edited February 23, 2000).]
Join Date: Jan 2000
23 Feb 2000, 02:39 PM
Originally posted by Fred Oxenby:
Your code is wrong
Your code means that you want to "LOGOFF" windows
Where have you found %EW_RESTARTWINDOWS ?
If IsFalse ExitWindowsEx(%EWX_REBOOT,0) Then
'check why it doesn't work...
If my code is wrong, then the example RESTART.BAS that PowerBASIC supplies with PB/DLL 6.0 is in error. That's where I got the source code. %EW_RESTARTWINDOWS is an equate in the WIN32API.INC file. It is also the equate used in the RESTART.BAS. But, yeah, I determined that by using "CALL ExitWindowsEX(0, %EW_RESTARTWINDOWS) was telling it to logoff of Windows, because of the first parameter in the brackets. So, i tried -1, instead. When I did that, it ALWAYS rebooted, even though I had applications running, which is how I tested it, first. Then, when it rebooted Windows with that option, I couldn't use the icons, and the programs in my System Tray that usually boot at startup weren't running. The Start button on the Taskbar worked, Thank God! At least I could do a power down to restore the settings. However, I never thought of using an error handling routine to see if I can find the error. I'll try that next. Thanks for the idea!
Join Date: Aug 1998
23 Feb 2000, 05:19 PM
I did not intend to be rude.
Just wanted to say that you had your parameters switched.
First parameter should be one of those:
%EWX_LOGOFF = &H0 %EWX_SHUTDOWN = &H00000001 %EWX_REBOOT = &H00000002 %EWX_FORCE = &H00000004 %EWX_POWEROFF = &H00000008 %EWX_FORCEIFHUNG = &H00000010 EWX_FORCE AND EWX_FORCEIFHUNG IS MUTUALLY EXCLUSIVE Cannot be used together
Second parameter is not used and don't care
24 Feb 2000, 12:52 AM
First of all, in my systems, PB's sample program Restart.bas works as expected. What might be problem in Clay's case - I must leave that to those who are better informed.
Then to the matter self. This has to do with undocumented features of Win9x. You are right about EWX_ constants, but not about EW_ constants, which do exists.
MS most probably uses them, too. They have (forgotten?) following defines in Winuser.h (my version of VC++ is 5.0)
#endif /* WINVER >= 0x0400 */
Then there is an undocumented function RestartDialog which is exported from SHELL32.DLL and the C declaration seems to be
int WINAPI RestartDialog(HWND hwndOwner, LPCSTR lpstrReason, UINT uFlags);
See http://www.geocities.com/SiliconValley/4942/index.html and then Function Index -> RestartDialog.
http://www.mvps.org/vbnet/code/shell/undocshelldlgs.htm has a Visual Basic example of how to use this function - their reasoning about parameters might not be exactly true (they don't mention these EW_ constants).
I don't know for sure but that function probably calls ExitWindowsEx placing one of the EW_ flags to the second, reserved parameter as PB's sample program does. As always, it is difficult to find out the arguments undocumented functions expect.
BTW, MS advices you to thunk down to a 16-bit DLL, which calls ExitWindows with EW_RESTARTWINDOWS parameter as the first parameter.
Join Date: Aug 1998
24 Feb 2000, 01:21 AM
Originally posted by Clay Clear:
I am trying to write a Freeware 32-bit program that allows the user to rebbot his machine, power down, force power down, logoff, regular shutdown, and restart Windows. My problem arises when I try to use the Restart Windows options The code I'm trying follows:
The 32-bit use of ExitWindowsEx was not correct
It seems that you are talking about 16 bit code
Sounds like kind of a shifty thing to do, no? But as it turns out, the 32-bit ExitWindowsEx() API does not allow one
to "restart" Microsoft Windows 95. However, if you were to write a 16-bit program and call the 16-bit
ExitWindows() API with the EW_RESTARTWINDOWS parameter, you can restart Windows 95.
You should be able to spawn a 16-bit application to do this. Or,
if you need to do the same from a 32-bit program,
then you will have to thunk down to a 16-bit DLL which calls the 16-bit API.
See the Microsoft Platform SDK (formerly called the Win32 SDK) for documentation on how to write a flat thunk under Windows 95.
[This message has been edited by Fred Oxenby (edited February 24, 2000).]
24 Feb 2000, 02:17 AM
I am not talking about 16-bit Windows but 32-bit ones (Win95, Win98, haven't tried in NT).
Try PB's sample Restart.bas or following small program. Both make call ExitWindowsEx(0,%EW_RESTARTWINDOWS) and it works. However, as I tried to explain, this feature is undocumented by Microsoft and they suggest thunking to 16-bit.
Should we use undocumented features of Windows is another question.
$COMPILE EXE #INCLUDE "WIN32API.INC" %RESTART = 1000 %CANCEL = 1001 %LABEL1 = 1002 DECLARE CALLBACK FUNCTION RestartProc FUNCTION WINMAIN (BYVAL CurInst AS LONG, _ BYVAL PrvInst AS LONG, _ CmdLine AS ASCIIZ PTR, _ BYVAL CmdShow AS LONG) EXPORT AS LONG LOCAL hDlg AS LONG DIALOG NEW 0, "Restart Windows?", , , 140, 60, %WS_CAPTION , TO hDlg CONTROL ADD LABEL, hDlg, %LABEL1, "", 5, 10, 130, 28 CONTROL ADD BUTTON, hDlg, %RESTART, "Restart", 25, 40, 40, 14 CONTROL ADD BUTTON, hDlg, %CANCEL, "Cancel", 75, 40, 40, 14 DIALOG SHOW MODAL hDlg, CALL RestartProc END FUNCTION CALLBACK FUNCTION RestartProc SELECT CASE CBMSG CASE %WM_COMMAND SELECT CASE CBWPARAM CASE %CANCEL DIALOG END CBHNDL CASE %RESTART CONTROL SET TEXT CBHNDL, %LABEL1, "Restarting Windows 'cause you asked" CALL ExitWindowsEx(0, %EW_RESTARTWINDOWS) CONTROL SET TEXT CBHNDL, %LABEL1, "Windows has been restarted" END SELECT END SELECT END FUNCTION
Join Date: Apr 1999
24 Feb 2000, 05:33 AM
The following code works fine on Win95
24 Feb 2000, 06:02 AM
See ResWin on my site (+ code)
24 Feb 2000, 07:03 AM
Reboot (%EWX_REBOOT) and Restart Windows (%EW_RESTARTWINDOWS) are different things.
Join Date: Sep 1999
24 Feb 2000, 07:17 AM
1) To understand who is right - PB or Fred, open Win32.Hlp or/and msdn.microsoft.com + Win32Api.Inc.
2) You can find good sample, how to reboot NT on http://support.microsoft.com/support.../Q176/6/95.ASP
(perhaps, EB used it; in any case his code works under Win2000)
24 Feb 2000, 07:34 AM
I am not saying that Fred is wrong when he talks about constants starting with %EWX_ , they should be used as he said. But there are these undocumented features of Windows to which constants starting with %EW_ belong and they, if used with ExitWindowsEx, are used differently. And they exist.
MS documentation and examples are useless here because these are undocumented features.
If anybody is interested,I have a code sample which shows how to call an undocumented API function RestartDialog, which uses these constants. And the code sample I supplied and PB's sample also show that these constants should be used differently. If you place them where %EWX_ constants are placed, you get totally different result.
Copyright © 1998-2022 PowerBASIC Tools, LLC - All Rights Reserved.
Powered by vBulletin® Version 5.7.0
Copyright © 2022 vBulletin Solutions, Inc. All rights reserved.
All times are GMT-5. This page was generated at 06:41 PM.
We process personal data about users of our site, through the use of cookies and other technologies, to deliver our services, and to analyze site activity. For additional details, refer to our Privacy Policy.
By clicking "I AGREE" below, you agree to our Privacy Policy and our personal data processing and cookie practices as described therein. You also acknowledge that this forum may be hosted outside your country and you consent to the collection, storage, and processing of your data in the country where this forum is hosted.