You simply have to remove the "Soft" word (and the space that is
right after).
But I tried your code and I get a failed assertion. The message says
"Could not resolve function "#59" in Shell32".
Having a (old) copy of Win32Declares, I only found this function:
Function Shutdown(mode as integer) as boolean
#if TargetWin32
Declare Function ExitWindowsEx Lib "User32" ( flags as Integer,
zero as Integer ) as Boolean
return ExitWindowsEx( mode, 0 )
#endif
end function
Which you call so:
if not Shutdown(2) then '2 is the value for "restart"
msgbox "Failed to restart."
end if
This works for me (I always used RB 5.5 and I used this function).
Also, I don't understand how your function (in you original post)
avoids a dialog. since the declare is named "RestartDialog".
Le 8 déc. 06 à 12:10 Soir, Carlo Rubini a écrit:
In Aarons's suite there is a shutdown-function that I would like to
use in order to shutdown the computer without the dialog-box (not
to restart it); but it uses soft declares, something RB 5.5.5
cannot make use of.
Since I dont know how to adapt it for RB 5.5.5, I would be glad if
somebody could 'translate' it for me:
Protected Function Shutdown(owner as Window, reason as String, type
as Integer) As Boolean
#if TargetWin32
Soft Declare Function RestartDialog Lib "Shell32" Alias
"#59" ( owner as Integer, reason as Ptr, flags as Integer ) as Integer
dim ownerHandle as Integer
if owner <> nil then ownerHandle = owner.WinHWND
reason = reason + EndOfLine + EndOfLine
dim retVal as Integer
dim msg as MemoryBlock
if IsPlatformNT then
msg = ConvertEncoding( reason + Chr( 0 ), Encodings.UTF16 )
else
msg = ConvertEncoding( reason + Chr( 0 ), Encodings.ASCII )
end if
retVal = RestartDialog( ownerHandle, msg, type )
Const IDOK = 1
Const IDCANCEL = 2
return retVal = IDOK
#endif
End Function
and it is called by:
if not Win32DeclareLibrary.Shutdown( self, "Because I asked
nicely", Win32DeclareLibrary.kShutdownModeReboot ) then
MsgBox "Fine, don't reboot then! Let's see if you'll shutdown
instead"
Win32DeclareLibrary.Shutdown( self )
end if
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>