August 06, 2004

registering a satelliteforms conduit using the palm CDK in dot net

for google's reference, if you ever need to register a satellite forms conduit from dot net use the palm cdk 4.03 and the following code:

' find out if the conduit is already registered
Public ReadOnly Property IsConduitRegistered() As Boolean
	Get
		Try
			Dim CondMgr As New PDStandardLib.PDCondMgr
			Dim ids() As Integer = CType(CondMgr.GetConduitList(), Integer())

			If ids Is Nothing Then
				Return False
			Else
				' sort sort it for the binary search
				Array.Sort(ids)
				' if the id exists in the array the conduit is registered
				Return (0 < Array.BinarySearch(ids, PALM_CREATOR_INTEGER))
			End If
		Catch ex As Exception
			Return False
		End Try
	End Get
End Property

' register the palm sync conduit
Public Sub RegisterConduit()
	Try
		Dim CondInfo As PDStandardLib.PDConduitInfo

		' remove any old conduit registration
		If Me.IsConduitRegistered Then
			Me.UnregisterConduit()
		End If

		' Set the conduit entries 
		CondInfo = New PDStandardLib.PDConduitInfo
		With CondInfo
			.FileName = Environment.SystemDirectory & "\" & SF_SYNC_DLL
			.CreatorID = PALM_CREATOR_INTEGER
			.HandHeldDB = "SatFormsEE"
			.DeskTopDataDirectory = "SatFormsEE"
			.DeskTopDataFile = "SatFormsEE"
			.DisplayName = "TecSync"
			.Priority = 2
		End With

		With New PDStandardLib.PDCondMgr
			' register it...
			.RegisterConduit(CondInfo)

			' refresh the list so it'll appear
			With New PDStandardLib.PDHotSyncUtility
				.RefreshConduitInfo()
			End With

			' ... and then test that we can retrieve it
			CondInfo = CType(.GetConduitInfo(PALM_CREATOR_INTEGER), PDStandardLib.PDConduitInfo)
			If CondInfo Is Nothing Then
				Throw New ApplicationException("The conduit seemed to register correctly but could not be retrieved afterwards. ")
			End If
		End With
	Catch ex As System.Runtime.InteropServices.COMException
		Throw New ApplicationException("Could not register the TecSync Palm conduit. The ConduitManager had a problem. " & ex.Message)
	Catch ex As ApplicationException
		Throw New ApplicationException("Could not register the TecSync Palm conduit. " & ex.Message)
	End Try
End Sub

' unregister the palm sync conduit
Public Sub UnregisterConduit()
	Try
		' unregister it 
		With New PDStandardLib.PDCondMgr
			.UnregisterConduit(PALM_CREATOR_INTEGER)
		End With
		' then refresh the list so it'll disapear
		With New PDStandardLib.PDHotSyncUtility
			.RefreshConduitInfo()
		End With
	Catch ex As System.Runtime.InteropServices.COMException
		Throw New ApplicationException("Coundn't unregister the TecSync Palm conduit. " & ex.Message)
	End Try
End Sub
Posted by drewish at August 6, 2004 02:53 AM

Trackback Pings

TrackBack URL for this entry:
http://drewish.com/mt/mt-tb.cgi/1161

Comments

Post a comment

Thanks for signing in, . Now you can comment. (sign out)

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)


Remember me?


Creative Commons License xml feed