自己动手实现动态外网ip管理和动态DNS域名解析 (四)

2014-11-24 12:06:12 · 作者: · 浏览: 6
D

#endif // Chinese (P.R.C.) resources

/////////////////////////////////////////////////////////////////////////////

#ifndef APSTUDIO_INVOKED

/////////////////////////////////////////////////////////////////////////////

//

// Generated from the TEXTINCLUDE 3 resource.

//

#define _AFX_NO_SPLITTER_RESOURCES

#define _AFX_NO_OLE_RESOURCES

#define _AFX_NO_TRACKER_RESOURCES

#define _AFX_NO_PROPERTY_RESOURCES

#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_CHS)

LANGUAGE 4, 2

#pragma code_page(936)

#include "res\UpdateIp.rc2" // non-Microsoft Visual C++ edited resources

#include "afxres.rc" // Standard components

#endif

/////////////////////////////////////////////////////////////////////////////

#endif // not APSTUDIO_INVOKED

UpdateIpDlg.h

// UpdateIpDlg.h : header file

//

#pragma once

// CUpdateIpDlg dialog

class CUpdateIpDlg : public CDialog

{

// Construction

public:

CUpdateIpDlg(CWnd* pParent = NULL); // standard constructor

// Dialog Data

enum { IDD = IDD_UPDATEIP_DIALOG };

protected:

virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support

// Implementation

protected:

HICON m_hIcon;

// Generated message map functions

virtual BOOL OnInitDialog();

afx_msg void OnSysCommand(UINT nID, LPARAM lParam);

afx_msg void OnPaint();

afx_msg HCURSOR OnQueryDragIcon();

DECLARE_MESSAGE_MAP()

public:

afx_msg void OnBnClickedBtnStartservice();

afx_msg void OnBnClickedBtnStopservice();

afx_msg void OnTimer(UINT_PTR nIDEvent );

afx_msg void OnDestroy();

BOOL OnEraseBkgnd(CDC* pDC);

int OnCreate(LPCREATESTRUCT lpCreateStruct);

LRESULT OnNotifyIcon(WPARAM wParam,LPARAM IParam);

private:

void startService(int interval);

void stopService();

void startUpdateInstance();

void stopUpdateInstance();

BOOL setAutoStart(BOOL bVal);

void initSettings();

BOOL saveSettings();

CString getSettingFilePath();

void addNotification();

public:

afx_msg void OnBnClickedSave();

private:

int m_nTimer;

BOOL m_bAutoStart;

int m_nUpdateInterval;

int m_bIsRunning;

CString m_strSettingFilepath;

NOTIFYICONDATA NotifyIcon;

};

UpdateIpDlg.cpp

// UpdateIpDlg.cpp : implementation file

//

#include "stdafx.h"

#include "UpdateIp.h"

#include "UpdateIpDlg.h"

#include "lib/happyhttp.h"

#ifdef _DEBUG

#define new DEBUG_NEW

#endif

#define WM_NC (WM_USER+1001)

const int TIMER_UPDATE = 100;

const TCHAR c_szSettingFilename[] = _T("updateip.ini");

const int c_nDefaultUpdate = 300;

const char c_szRequestHost[] = "xx.sinaapp.com"; //换成自己的域名

// CAboutDlg dialog used for App About

class CAboutDlg : public CDialog

{

public:

CAboutDlg();

// Dialog Data

enum { IDD = IDD_ABOUTBOX };

protected:

virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support

// Implementation

protected:

DECLARE_MESSAGE_MAP()

};

CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)

{

}

void CAboutDlg::DoDataExchange(CDataExchange* pDX)

{

CDialog::DoDataExchange(pDX);

}

BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)

END_MESSAGE_MAP()

// CUpdateIpDlg dialog

CUpdateIpDlg::CUpdateIpDlg(CWnd* pParent /*=NULL*/)

: CDialog(CUpdateIpDlg::IDD, pParent)

, m_nTimer(0)

, m_bAutoStart(TRUE)

, m_nUpdateInterval(c_nDefaultU