locked
[UWP][C#]How to check user install, open, time of app still on device and review my app? RRS feed

  • Question

  • Hi everybody!

    How to check user install, open, time of app still on device and review my app?

    Thank you!

    Saturday, July 22, 2017 12:33 AM

Answers

  • I've done it in VB.NET, Windows Form.
    Please search how to get Process (ID, Name, etc).  A Hub app can know Process Name in every some intervals (e.g. 1000 msec), it can know whether app registered in a list of a Hub app is running.

    my code (VB.NET, Windows Form):
    There are  two DataGridView.  One(dgv_App) is for app registered, and the other(dgv_Process) is for storing Process(ID and Name) in every one second. 
    my App can know if app registered are in running, by comparing dgv_App and dgv_Process in every one second.
    	' --- プロセスを取得: dgv_Process に格納
    	Public Sub prc_Get_Process()
    		' --- dgv_Process クリア:行を削除
    		For idx As Integer = 0 To frm_Main.dgv_Process.Rows.Count - 1
    			frm_Main.dgv_Process.Rows.RemoveAt(0)
    		Next
    		' ---▼ 全てのプロセスを調べて、dgv_Process に格納
    		Dim myRow As Integer = 0
    		Dim proc As System.Diagnostics.Process      ' --◀ プロセス
    		For Each proc In System.Diagnostics.Process.GetProcesses()
    			' --- dgv_ProcInfo にプロセス情報を格納(表示)
    			frm_Main.dgv_Process.Rows.Add()  ' --◀ 行を追加
    			frm_Main.dgv_Process(0, myRow).Value = proc.Id          ' -- 列0: プロセスID
    			frm_Main.dgv_Process(1, myRow).Value = proc.ProcessName ' -- 列1: プロセス名
    			' ---
    			myRow += 1
    		Next  ' --▲ ループの終端
    		' --- 後始末: 位置調整, ソート
    		frm_Main.dgv_Process.Sort(frm_Main.dgv_Process.Columns(1), System.ComponentModel.ListSortDirection.Ascending)
    		If (My.Settings.dgvProcessLocation.IsEmpty) Then
    			frm_Main.dgv_Process.Location = New Point(290, 120)
    		Else
    			frm_Main.dgv_Process.Location = New Point(My.Settings.dgvProcessLocation)
    		End If
    	End Sub
    	' --- 指定されたプロセスが起動していればTrue: dgv_APP と dgv_Process の比較
    	Public Sub prc_Check_AppRunning()
    		Me.IsAppRunning = False ' -- 初期値として False をセット
    		With frm_Main
    			' ---▼▼ dgv_App ループ
    			For appRow As Integer = 0 To .dgv_App.Rows.Count - 1
    				If (.dgv_App(0, appRow).Value = False) Then
    					Continue For ' --▲▲
    				End If
    				' -- exe ファイル名を取得
    				Dim processName As String _
    					= System.IO.Path.GetFileNameWithoutExtension(.dgv_App(2, appRow).Value)
    				' ---▼ dgv_Process ループ
    				For prcRow As Integer = 0 To .dgv_Process.Rows.Count - 1
    					If (processName = .dgv_Process(1, prcRow).Value) Then   ' -- 列1:ソフト名(拡張子なし)
    						' --- プロセスが合致すれば True
    						.dgv_Process.FirstDisplayedScrollingRowIndex = prcRow
    						.dgv_Process(0, prcRow).Style.BackColor = Me.SelectionBkColor   ' -- 選択状態の背景色
    						.dgv_Process(1, prcRow).Style.BackColor = Me.SelectionBkColor
    						.dgv_App(2, appRow).Selected = True   ' -- 該当セル選択状態にする
    						.dgv_App.DefaultCellStyle.SelectionForeColor = Color.Black
    						Me.IsAppRunning = True    ' --◀ 起動中なので True
    						Exit Sub  ' --▶▶ 処理を抜ける
    					End If
    				Next prcRow
    			Next appRow
    			' ---
    			.dgv_Process.ClearSelection()
    		End With
    	End Sub

    Ashidacchi

    Sunday, July 23, 2017 2:39 AM

All replies

  • In advance, sorry if I'm misunderstanding your question.
    It would be possible for your app to know when it is opened and closed, but would not possible for your app to know when it is installed itself (it cannot do nothing until installing and opening it). 

    Ashidacchi

    Sunday, July 23, 2017 2:05 AM
  • I want to create a Hub App. in that Hub have a list of other app. I want to know other app are open? are close? are and how long other app install until now. That information of other app will show in Hub App

    Sunday, July 23, 2017 2:09 AM
  • 1. It is possible for a Hub app to know when other app (registered in a list in a Hub app) is opened and closed by checking Process in some interval.
    2. I have no idea how to know if other app installed, so no idea how long other app install until now.   

    Ashidacchi

    Sunday, July 23, 2017 2:26 AM
  • 1. It is possible for a Hub app to know when other app (registered in a list in a Hub app) is opened and closed by checking Process in some interval. 
    Do you have sample or document for this!

    Sunday, July 23, 2017 2:28 AM
  • I've done it in VB.NET, Windows Form.
    Please search how to get Process (ID, Name, etc).  A Hub app can know Process Name in every some intervals (e.g. 1000 msec), it can know whether app registered in a list of a Hub app is running.

    my code (VB.NET, Windows Form):
    There are  two DataGridView.  One(dgv_App) is for app registered, and the other(dgv_Process) is for storing Process(ID and Name) in every one second. 
    my App can know if app registered are in running, by comparing dgv_App and dgv_Process in every one second.
    	' --- プロセスを取得: dgv_Process に格納
    	Public Sub prc_Get_Process()
    		' --- dgv_Process クリア:行を削除
    		For idx As Integer = 0 To frm_Main.dgv_Process.Rows.Count - 1
    			frm_Main.dgv_Process.Rows.RemoveAt(0)
    		Next
    		' ---▼ 全てのプロセスを調べて、dgv_Process に格納
    		Dim myRow As Integer = 0
    		Dim proc As System.Diagnostics.Process      ' --◀ プロセス
    		For Each proc In System.Diagnostics.Process.GetProcesses()
    			' --- dgv_ProcInfo にプロセス情報を格納(表示)
    			frm_Main.dgv_Process.Rows.Add()  ' --◀ 行を追加
    			frm_Main.dgv_Process(0, myRow).Value = proc.Id          ' -- 列0: プロセスID
    			frm_Main.dgv_Process(1, myRow).Value = proc.ProcessName ' -- 列1: プロセス名
    			' ---
    			myRow += 1
    		Next  ' --▲ ループの終端
    		' --- 後始末: 位置調整, ソート
    		frm_Main.dgv_Process.Sort(frm_Main.dgv_Process.Columns(1), System.ComponentModel.ListSortDirection.Ascending)
    		If (My.Settings.dgvProcessLocation.IsEmpty) Then
    			frm_Main.dgv_Process.Location = New Point(290, 120)
    		Else
    			frm_Main.dgv_Process.Location = New Point(My.Settings.dgvProcessLocation)
    		End If
    	End Sub
    	' --- 指定されたプロセスが起動していればTrue: dgv_APP と dgv_Process の比較
    	Public Sub prc_Check_AppRunning()
    		Me.IsAppRunning = False ' -- 初期値として False をセット
    		With frm_Main
    			' ---▼▼ dgv_App ループ
    			For appRow As Integer = 0 To .dgv_App.Rows.Count - 1
    				If (.dgv_App(0, appRow).Value = False) Then
    					Continue For ' --▲▲
    				End If
    				' -- exe ファイル名を取得
    				Dim processName As String _
    					= System.IO.Path.GetFileNameWithoutExtension(.dgv_App(2, appRow).Value)
    				' ---▼ dgv_Process ループ
    				For prcRow As Integer = 0 To .dgv_Process.Rows.Count - 1
    					If (processName = .dgv_Process(1, prcRow).Value) Then   ' -- 列1:ソフト名(拡張子なし)
    						' --- プロセスが合致すれば True
    						.dgv_Process.FirstDisplayedScrollingRowIndex = prcRow
    						.dgv_Process(0, prcRow).Style.BackColor = Me.SelectionBkColor   ' -- 選択状態の背景色
    						.dgv_Process(1, prcRow).Style.BackColor = Me.SelectionBkColor
    						.dgv_App(2, appRow).Selected = True   ' -- 該当セル選択状態にする
    						.dgv_App.DefaultCellStyle.SelectionForeColor = Color.Black
    						Me.IsAppRunning = True    ' --◀ 起動中なので True
    						Exit Sub  ' --▶▶ 処理を抜ける
    					End If
    				Next prcRow
    			Next appRow
    			' ---
    			.dgv_Process.ClearSelection()
    		End With
    	End Sub

    Ashidacchi

    Sunday, July 23, 2017 2:39 AM
  • Thank you Ashidacchi!
    Sunday, July 23, 2017 2:51 AM