Here are the important parts:
When you load extension, do NOT forget SetRestoreCallState!
[code]
Load Me.TExtension1(i)
Me.TExtension1(i).TDN = txtAdd.Text
Me.TExtension1(i).TQueue = 0
Me.TExtension1(i).TExtensionType = TypeDN
Me.TExtension1(i).TAutoRegister = True
Me.TExtension1(i).SetRestoreCallState (True)
[/code]
Here is the eventRegistered function that processes the existing state of DN
(it is rough since I wrote it in about 15 minutes or less...)
[code]
Private Sub TExtension1_TEventRegistered(Index As Integer, EventInfo As DesktopToolkitX.TEventInfo)
'first let's check if agent is logged in or not
Dim count, count2 As Integer
Dim total_count As Integer
Dim userList As DesktopToolkitX.CTKVList
Dim userPair As DesktopToolkitX.CTKVPair
Dim agentStatus As Integer
Dim line As DesktopToolkitX.TLine
Set userList = EventInfo.Extensions
total_count = userList.GetCount
For count = 0 To total_count - 1
Set userPair = userList.Get(count)
If userPair.Key = "AgentStatus" Then
agentStatus = userPair.NumValue
' let's see if we need to log someone out!
If (Me.chkForcedLogout) Then
Select Case agentStatus
'logged out
Case 0:
'logged in
Case 1, 2, 3, 4, 5:
'agent is logged in
gAgentLoginID = EventInfo.AgentID
'check if user checked logout checkmark
' we need to logout this agent
For count2 = 0 To DN_Count - 1
If (Me.TExtension1(count2).TDN = EventInfo.ThisDN) Then
Me.TExtension1(count2).TLogout
End If
Next count2
End Select
End If
Else
If userPair.Key = "conn-1" Then
'let's get the connid
gConnID = userPair.StringValue
If Me.chkForcedRelease.Value = 1 Then
For count2 = 0 To DN_Count - 1
If (Me.TExtension1(count2).TDN = EventInfo.ThisDN) Then
'let's try to release this call
Me.TExtension1(count2).TGetActiveCallObj.THangUp
End If
Next count2
End If
End If
End If
Next
End Sub
[/code]
This should take care of your worries

Happy hunting and if you have more questions, please feel free to post them!!!
Best regards,
Vic