We can use the DLL export Function Tool to see that the first export function of MSGINA. dll is shellshutdowndialog, but it is not described in msdn. So we went to Win2000.Source codeFind the function definition, convert it to the Delphi version, and provide an instance.
{
* The Windows exit system dialog box is displayed *
Description: This function is exported by MSGINA. dll, but no description is provided for querying msdn. Check the Win2000 source. Code Function Definition
Author: jjony
Contact: jzj_jony@126.com
QQ: 254706028
}
Program showexitwindowsdialog;
{$ Apptype console}
Uses
Windows;
Const // constant of the custom operation code
Shut_down_none = 0; // No operation
Shut_down_logout = 1; // log out
Shut_down_poweroff = 2; // Shutdown
Shut_down_reboot = 4; // restart
Shut_down_wait = 16; // standby
Shut_down_dormancy = 64; // sleep
Type
Tshellshutdowndialog = function (hparent: hwnd; Username: pchar; bhidelogoff: bool): DWORD; stdcall;
VaR
Shellshutdowndialog: tshellshutdowndialog;
Curu: array [0 .. max_path] of char;
Len: Cardinal;
R: DWORD;
Info: string;
Function strpas (const STR: pchar): string;
Begin
Result: = STR;
End;
Procedure cvtint;
ASM
Or Cl, Cl
Jnz @ cvtloop
@ C1: Or eax, eax
JNS @ C2
Neg eax
Call @ C2
MoV Al ,'-'
INC ECx
Dec ESI
MoV [esi], Al
RET
@ C2: mov ECx, 10
@ Cvtloop:
Push edX
Push ESI
@ D1: XOR edX, EDX
Div ECx
Dec ESI
Add DL, '0'
Cmp dl, '0' + 10
JB @ D2
Add DL, ('A'-'0')-10
@ D2: mov [esi], DL
Or eax, eax
JNE @ d1
Pop ECx
Pop edX
Sub ECx, ESI
Sub edX, ECx
Jbe @ D5
Add ECx, EDX
MoV Al, '0'
Sub ESI, EDX
JMP @ Z
@ Zloop: mov [ESI + EDX], Al
@ Z: Dec edX
Jnz @ zloop
MoV [esi], Al
@ D5:
End;
Function inttostr (value: integer): string;
ASM
Push ESI
MoV ESI, ESP
Sub ESP, 16
XOR ECx, ECx
Push edX
XOR edX, EDX
Call cvtint
MoV edX, ESI
Pop eax
Call system. @ lstrfrompcharlen
Add ESP, 16
Pop ESI
End;
Function loadshell: Boolean; // dynamically load shellshutdowndialog
VaR
H: hmodule;
Begin
H: = loadlibrary ('msgina. dll ');
If H <> 0 then
Shellshutdowndialog: = getprocaddress (H, 'shellshutdowndialog ')
Else
Begin
Writeln ('error occurred while loading MSGINA. dll ');
Readln;
End;
Result: = assigned (shellshutdowndialog );
End;
Begin
If not loadshell then exit;
Len: = sizeof (curu );
GetUserName (curu, Len );
Writeln ('');
Writeln ('* display windows exit system dialog box *');
Writeln ('Description: This function is exported by MSGINA. dll, but no description is provided for querying msdn. Check the function definition in Win2000 source code ');
Writeln ('author: jjony ');
Writeln ('Contact: jzj_jony@126.com ');
Writeln ('qq: 254706028 ');
Writeln ('');
Writeln ('Press enter to display the Windows exit system dialog box ');
Readln;
R: = shellshutdowndialog (0, @ curu, false );
Writeln ('');
Case R
Shut_down_none: info: = '(no operation)'; // No operation
Shut_down_logout: info: = '(logout' + strpas (curu) + ')'; // logout
Shut_down_poweroff: info: = '(shutdown)'; // Shutdown
Shut_down_reboot: info: = '(restart)'; // restart
Shut_down_wait: info: = '(standby)'; // standby
Shut_down_dormancy: info: = '(sleep)'; // sleep
End;
Writeln ('Return execution operation code: '+ inttostr (r) + info );
Writeln ('');
Writeln ('Press enter to exit ');
Readln;
End.