VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



If a users attempts to shutdown/restart their computer while your application is still running

by www.cupidsystems.com (3 Submissions)
Category: Complete Applications
Compatability: Visual Basic 5.0
Difficulty: Beginner
Date Added: Wed 3rd February 2021
Rating: (3 Votes)

If a users attempts to shutdown/restart their computer while your application is still running, this simple piece of code will actually allow you to abort the request to shutdown. Can be very useful. Please mail me at [email protected] if you are facing any problems or www.shouvik.tk

Assumes
www.cisindia.net = Free Software. www.bnetsupport.com and www.vexat.net = Free Tutorials/Ebooks.
API Declarations
Declare Function GetComputerName Lib "kernel32" Alias "GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Declare Function AbortSystemShutdown Lib "advapi32.dll" Alias "AbortSystemShutdownA" (ByVal lpMachineName As String) As Long
Function GetName()
Dim lpBuff As String * 25
Dim ret As Long, ComputerName As String

ret = GetComputerName(lpBuff, 25)
ComputerName = Left(lpBuff, InStr(lpBuff, Chr(0)) - 1)

GetName = ComputerName
End Function

Rate If a users attempts to shutdown/restart their computer while your application is still running

Private Sub Command1_Click()
 AbortSystemShutdown (GetName)
End Sub

Download this snippet    Add to My Saved Code

If a users attempts to shutdown/restart their computer while your application is still running Comments

No comments have been posted about If a users attempts to shutdown/restart their computer while your application is still running. Why not be the first to post a comment about If a users attempts to shutdown/restart their computer while your application is still running.

Post your comment

Subject:
Message:
0/1000 characters