Click here to Skip to main content
15,881,380 members
Articles / Mobile Apps / Windows Mobile

Access Your Pocket PC Over the Internet

Rate me:
Please Sign up or sign in to vote.
4.92/5 (15 votes)
8 Jan 2009MPL7 min read 55.5K   1.1K   56  
A DynDNS updater for the Compact Framework.
Imports System.IO
Imports System.Reflection

Module modMain
    Public fMain As FrmMain
    Public WithEvents ni As OpenNETCF.Windows.Forms.NotifyIcon

    Sub Main()
        Try

            Globals.getIcons()

            ni = New OpenNETCF.Windows.Forms.NotifyIcon()
            AddHandler ni.Click, AddressOf TrayIcon_Click

            ni.Icon = Globals.AppIcon
            ni.Text = "CompactDDNS"
            ni.Visible = True

            fMain = New FrmMain
            Application.Run(fMain)

            RemoveHandler ni.Click, AddressOf TrayIcon_Click
            ni.Dispose()

        Catch ex As Exception
            Debug.WriteLine("Error on Exit Main - " & ex.Message)
        End Try
        Application.Exit()
    End Sub

    Public Sub TrayIcon_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        fMain.Visible = True
        fMain.Focus()
    End Sub

    Public Sub OnEx(ByVal ex As Exception)
        If Logger.FileName = "" Then
            SystemLogFile = AppPath & "Logs\SystemLog_" & Format(Now.Month, "0#") & Format(Now.Year - 2000, "0#") & ".txt"
            Logger.SetFile(SystemLogFile, True, False)
        End If
        Logger.Log(ex)
    End Sub

    Public Sub Log(ByVal message As String)
        Try
            If LogNetworkEvents Then
                If Logger.FileName = "" Then
                    SystemLogFile = AppPath & "Logs\SystemLog_" & Format(Now.Month, "0#") & Format(Now.Year - 2000, "0#") & ".txt"
                    Logger.SetFile(SystemLogFile, True, False)
                End If
                Logger.Log(message)
            End If
        Catch ex As Exception
            Debug.WriteLine("Log error : " & ex.Message)
        End Try
    End Sub

    Public Function IsFirstRun() As Boolean
        If Not File.Exists(ConfigFile) Then
            Try
                File.Copy(AppPath & "ConfigurationInfo.bak", ConfigFile)
                Return True
            Catch ex As Exception
                OnEx(ex)
                Return True
            End Try
        End If
        Return False
    End Function
End Module

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Mozilla Public License 1.1 (MPL 1.1)


Written By
Product Manager Open Control Pty Ltd
Australia Australia
Control systems engineer turned software developer.

Largely .NET developer with a strong focus on development for windows mobile devices.

Have also started an open source project called 'SCADA.Net' and have added some really cool libraries to the project. Once I get some documentation to go with the project it should be of some interest to anyone interested in control systems. This project can be found at http://sourceforge.net/projects/scadanet/

Comments and Discussions