Windows Installer, Java Installer, Freeware Installer
Home|Contact|Site Map|TOC|Search
Download  Features   Java  Licensing  Purchase  Testimonials  Support  Forums

How do I integrate the Advanced Updater with my application?

Answer:

The Advanced Updater can be easily integrated with your application since you only have to launch it using an adequate command line option.

Here is some sample code written in ATL that integrates the updater with the MainFrame of an application.

#define UPDATER_NAME                   _T("updater.exe")
#define UPDATER_COMMAND_LINE_CHECKNOW  _T("updater.exe /checknow")
#define UPDATER_COMMAND_LINE_OPTIONS   _T("updater.exe /configure %u")
#define UPDATER_COMMAND_LINE_SILENT    _T("updater.exe /silent")
				
class MainFrame : public CFrameWindowImpl<MainFrame>,
                  public CUpdateUI<MainFrame>,
                  public CMessageFilter, public CIdleHandler
{
public:
  DECLARE_FRAME_WND_CLASS(NULL, IDR_MAINFRAME)
  ........
  BEGIN_MSG_MAP(MainFrame)
    MESSAGE_HANDLER(WM_CREATE, OnCreate)
    MESSAGE_HANDLER(WM_TIMER, OnTimer)
    ........
    COMMAND_ID_HANDLER(ID_CHECK_FOR_UPDATES, OnCheckForUpdates)
    COMMAND_ID_HANDLER(ID_UPDATER_OPTIONS, OnUpdaterOptions)
    ........
  END_MSG_MAP()
    ........
  
  LRESULT OnCreate(UINT /*uMsg*/, WPARAM /*wParam*/, 
		      LPARAM /*lParam*/, BOOL& /*bHandled*/)
  { 
    .......
    SetTimer(0, 5000);
    return 0;
  }
			
  void DoRunUpdater(CString aCommandLine) 
   {
    TCHAR path[MAX_PATH];
    ::GetModuleFileName(NULL, path, MAX_PATH);
      			
    CString updaterPath(path);
    int ind = updaterPath.ReverseFind(_T('\\'));
    if (ind > 0)
      updaterPath = updaterPath.Left(ind);
       if (updaterPath[updaterPath.GetLength() - 1] != _T('\\'))
         updaterPath += _T('\\');
    updaterPath += UPDATER_NAME;
      			
    STARTUPINFO si;
    PROCESS_INFORMATION pi;
      			
    ZeroMemory( &si, sizeof(si) );
    si.cb = sizeof(si);
    ZeroMemory( &pi, sizeof(pi) );
      			
    ::CreateProcess(updaterPath, const_cast<LPSTR>((LPCTSTR)aCommandLine), 
      			 NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi);
  }
						
  LRESULT OnTimer(UINT /*uMsg*/, WPARAM /*wParam*/, 
                  LPARAM /*lParam*/, BOOL& /*bHandled*/)
  {										
    KillTimer(0);
    DoRunUpdater(UPDATER_COMMAND_LINE_SILENT);
    return 0;
  }
						
  LRESULT OnCheckForUpdates(WORD /*wNotifyCode*/, WORD /*wID*/, 
			         HWND /*hWndCtl*/, BOOL& /*bHandled*/) 
  {
    DoRunUpdater(UPDATER_COMMAND_LINE_CHECKNOW);
    return 0;
  }
						
  LRESULT OnUpdaterOptions(WORD /*wNotifyCode*/, WORD /*wID*/,
			        HWND /*hWndCtl*/, BOOL& /*bHandled*/)
  {
    CString commandLine;
    commandLine.Format(UPDATER_COMMAND_LINE_OPTIONS, m_hWnd);    
    DoRunUpdater(UPDATER_COMMAND_LINE_OPTIONS);
    return 0;
  }
};
The "/checknow" option

When using this command line option the Advanced Updater will be launched, checks if new updates are available and gives you the possibility to download and install them. In order to launch the Advanced Updater with this option from your application, you could create a menu option.

In the sample code from above this scenario corresponds to the "OnCheckForUpdates" function.

The "/configure [HWND]" option

When using this command line the "Updates Options" configuration dialog is displayed. This dialog allows you to enable or disable the updater, set the check frequency and select the folder where the updates will be downloaded. You could integrate this option in the same mode as explained above, with a menu option.

This command line is used in the above sample code with an additional parameter that specifies the parent window handle for the "Updates Options" dialog. This parameter is of unsigned integer type.

In the example this option corresponds to the "OnUpdaterOptions" function. The "m_hWnd" represents the pointer to the parent window which in this case is the MainFrame.

The "/silent" option

When using this option the Advanced Updater is launched and checks for updates at the interval specified in the "Updates Option" dialog. You can use the updater with this command line every time your application is launched.

This corresponds to the "OnTimer" function from the sample code.

Five seconds after you launch the application, the updater is launched too. This interval is set in the "OnCreate" function.

The updater checks whether is time to verify for new updates depending on the check frequency you entered in the "Updates Option" dialog.

The "DoRunUpdater" function launches the updater with a certain command line option.

NoteIf you are have a java application please follow the following link for some sample code that will help you integrate the updater: Integrate Updater In Java Application .

Privacy Policy | Windows Installer | Search Engine Ranking | Link Analyzer