ايران ويج

نسخه‌ی کامل: دستور لاگ آف (Log Off) کردن ویندوز
شما در حال مشاهده‌ی نسخه‌ی متنی این صفحه می‌باشید. مشاهده‌ی نسخه‌ی کامل با قالب بندی مناسب.
سلام دوستان من برای دستور لاگ آف(Log Off) سرچ کردم و پیدا هم کردم ولی مثل اینمه اشتباه هستنند میشه کد درست رو بدید
کدی که اشتبه بود:
Shell(“shutdown –l –f –t 0”) ‘Log off Windows
اگر میشه دستور های دیگه مانند ریستارت و استندبای و ..
رو هم بگذارید با تشکر
چرا از توابع خود ویندوز استفاده نمیکنین؟
Exitwindowsex

کد:
The ExitWindowsEx function either logs off, shuts down, or shuts down and restarts the system.

BOOL ExitWindowsEx(

    UINT uFlags,    // shutdown operation
    DWORD dwReserved     // reserved
   );    


Parameters

uFlags

Specifies the type of shutdown. This parameter must be some combination of the following values:

Value    Meaning
EWX_FORCE    Forces processes to terminate. When this flag is set, Windows does not send the messages WM_QUERYENDSESSION and WM_ENDSESSION to the applications currently running in the system. This can cause the applications to lose data. Therefore, you should only use this flag in an emergency.
EWX_LOGOFF    Shuts down all processes running in the security context of the process that called the ExitWindowsEx function. Then it logs the user off.
EWX_POWEROFF    Shuts down the system and turns off the power. The system must support the power-off feature.Windows NT: The calling process must have the SE_SHUTDOWN_NAME privilege. For more information, see the following Remarks section. Windows 95: Security privileges are not supported or required.
EWX_REBOOT    Shuts down the system and then restarts the system. Windows NT: The calling process must have the SE_SHUTDOWN_NAME privilege. For more information, see the following Remarks section. Windows 95: Security privileges are not supported or required.
EWX_SHUTDOWN    Shuts down the system to a point at which it is safe to turn off the power. All file buffers have been flushed to disk, and all running processes have stopped. Windows NT: The calling process must have the SE_SHUTDOWN_NAME privilege. For more information, see the following Remarks section. Windows 95: Security privileges are not supported or required.


dwReserved

Reserved; this parameter is ignored.
کد:
Private Const EWX_LOGOFF = 0
Private Const EWX_SHUTDOWN = 1
Private Const EWX_REBOOT = 2

Private Const EWX_FORCE = 4
Private Declare Function ExitWindowsEx Lib "user32" (ByVal uFlags As Long, ByVal dwReserved As Long) As Long


Sub ShutDownWindows(ByVal ExitWinmod As Long)
    ExitWindowsEx ExitWinmod + EWX_FORCE, 1
End Sub

Private Sub Command1_Click()
Call ShutDownWindows(EWX_LOGOFF)
End Sub
سلام .

نقل قول: سلام دوستان من برای دستور لاگ آف(Log Off) سرچ کردم و پیدا هم کردم ولی مثل اینمه اشتباه هستنند میشه کد درست رو بدید
کدی که اشتبه بود:
Shell(“shutdown –l –f –t 0”) ‘Log off Windows

کد:
Shell ("shutdown -l")

نقل قول: اگر میشه دستور های دیگه مانند ریستارت و استندبای و ..
رو هم بگذارید با تشک

برای shutdown کردن :

کد:
Shell ("shutdown -s -t 60")

رستارت کردن :

کد:
Shell ("shutdown -r -t 60")

موفق باشید .