AccessBlog.net

News, links, downloads, tips and tricks on Microsoft Access and related

About Me Search
Alex
Name:Alex Dybenko

Location:Moscow, Russia

Tuesday, September 12, 2023

TeamViewer session is active - another method

 When TeamViewer running as service - connections established by System account, so we can't detect which user has TeamViewer session active. In that case we can use a following function, which looks through TeamViewer log file (logging must be enabled in TeamViewer options). Idea is based on that KB article Log file reading - Incoming connection


Public Function TeamViewerActive() As Boolean

    Dim tvLog As String

    tvLog = "C:\Program Files (x86)\TeamViewer\TeamViewer15_Logfile.log"

    If Len(Dir(tvLog)) = 0 Then Exit Function

    'Get user's process TeamViewer PID

    Dim objServices As Object, objProcessSet As Object, Process As Object

    Set objServices = GetObject("winmgmts:\\.\root\CIMV2")

    Set objProcessSet = objServices.ExecQuery("SELECT * FROM Win32_Process WHERE Name = 'TeamViewer.exe'", , 48)  '

    

    Dim tvPID As Long

    For Each Process In objProcessSet

        Dim ProcessUserName As Variant

        Call Process.GetOwner(ProcessUserName)

        If ProcessUserName = GetWindowsUserName Then

            tvPID = Process.ProcessID

            Exit For

        End If

    Next


    Set objProcessSet = Nothing

    

'no PID - no TeamViewer running

    If tvPID = 0 Then Exit Function

    

    Dim FSO As Object

    Dim strLog As String, a, i As Long

    Set FSO = CreateObject("scripting.FileSystemObject")

    Dim TS As Object 'TextStream

    Set TS = FSO.OpenTextFile(tvLog, 1) 'ForReading

    strLog = TS.ReadAll

    a = Split(strLog, vbNewLine)

    TS.Close


'Get the lastest session

    Dim lngLastStart As Long, strSessionID As String

    For i = 0 To UBound(a)

        If a(i) Like "*  " & tvPID & " *" Then

            If a(i) Like "* CParticipantManagerBase participant *" Then

                lngLastStart = i

            End If

        End If

    Next i

    

    If lngLastStart > 0 Then

'Session was started

        TeamViewerActive = True

'Get session ID

        strSessionID = Mid(a(lngLastStart), InStr(1, a(lngLastStart), " (ID [") + 5)

        strSessionID = Left(strSessionID, InStr(1, strSessionID, "]"))

'Check if that session already ended, if no - then user in TeamViewer session

        For i = lngLastStart To UBound(a)

            If a(i) Like "* CPersistentParticipantManager::RemoveParticipant:*" & Replace(strSessionID, "[", "[[]") & "*" Then

                TeamViewerActive = False

            End If

        Next i

    End If

End Function

Labels: , ,

Saturday, September 02, 2023

How to check if TeamViewer session is active

This function can be used to determine if current user session has active TeamViewer connection. The only way I found so far is to check specific port for established connection using netstat

netstat -nb | find ":5938" | find "ESTABLISHED"

If anything found - Teamviewer is running on PC


netstat -nb | find ":6039" | find "ESTABLISHED"

If anything found - Teamviewer session is active

Using this code GetTcpTable: Local Machine TCP Connection Table you can make TeamviewerSessionIsActive() function, just replace With TcpRow block with following:

Public Function TeamviewerSessionIsActive() As Boolean

With TcpRow

    If ntohs(.dwRemotePort) = 6039 And & _ 

        .dwState = MIB_TCP_STATE_ESTAB Then

        TeamviewerSessionIsActive = True

        Exit Function

    End If

End With

End Function


Labels: , ,

Monday, April 08, 2013

Long life Visual Basic!

Good article  by Chris Boss: Classic Visual Basic’s end marked a key change in software development. I still doing a lot of stuff on VB6 and of course VBA and I hope Microsoft will keep it running on new Windows versions

Labels:

Thursday, August 25, 2011

Workaround for “Win 7 SP1 breaks ADO”

This is a follow-up to Windows 7 SP1 breaks ADODB, here a MS KB article with typelibs, you can download,  which resolves the issue:

An ADO application does not run on down-level operating systems after you recompile it on a computer that is running Windows 7 SP 1 or Windows Server 2008 R2 SP 1 or that has KB983246 installed

Labels: , ,

Monday, May 30, 2011

Classic VB is 20!

Classic VB is 20 and still missed by many. I also still use VB6, and do not see any replacement. VB functions/classes libraries, ActiveX controls, complex user interface forms – this you can easy build in VB6 and use in Access application. What about you?

Labels:

Thursday, March 24, 2011

Is your Application Running under Terminal Services?

Below VBA code to check this, IsRunningInTerminal() function returns True when you Access application runs in Terminal server session:

Private Declare Function GetSystemMetrics _
Lib "user32" (ByVal nIndex As Long) As Long

Public Const SM_REMOTESESSION As Long = &H1000

Public
Function IsRunningInTerminal() As Boolean
   IsRunningInTerminal = _
      (GetSystemMetrics(SM_REMOTESESSION) <> 0)
End Function

Labels: , ,

Wednesday, December 01, 2010

Visual Basic for Windows Phone Developer Tools

Visual Basic for Windows Phone Developer Tools – RTW:  Now we can build applications for Windows Phone 7 using VB.NET. Some sample applications to start with. Time to get new phone…

Labels: ,

Thursday, September 16, 2010

VBA Hover ToolTip Trick

Nice VB/VBA trick - you can hover over variable in VBE, holding Ctrl key down - and you will see last 77 characters of long string, more details at BaconBits.

Labels: , ,

Thursday, April 08, 2010

vbMAPI - Outlook Security Evader

One more way to get rid of Outlook security prompts, now from Wayne Phillips, using his method to run native code in memoryvbMAPI - Outlook Security Evader for Office / VBA and classic VB6. No need to register activeX DLL like for Redemption, you just import several class modules into your VB/VBA project and build your code using these objects, instead of MAPI, and that is!

Labels: ,

Saturday, November 07, 2009

Installing VB6 without Java

This trick should help to install VB6 on Windows 7: Installing VB6 without Java

Labels:

Wednesday, July 29, 2009

VB5/6 Controls and Components

Now at MVPs.org site:

These downloads were all provided by Microsoft for VB5 and/or VB6, and the links will point to download.microsoft.com until Microsoft decides to remove them


Update: some links still on MSDN site, with descriptions.

Labels: