1 //####COPYRIGHTBEGIN####
3 // ----------------------------------------------------------------------------
4 // Copyright (C) 1998, 1999, 2000 Red Hat, Inc.
6 // This program is part of the eCos host tools.
8 // This program is free software; you can redistribute it and/or modify it
9 // under the terms of the GNU General Public License as published by the Free
10 // Software Foundation; either version 2 of the License, or (at your option)
13 // This program is distributed in the hope that it will be useful, but WITHOUT
14 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
18 // You should have received a copy of the GNU General Public License along with
19 // this program; if not, write to the Free Software Foundation, Inc.,
20 // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 // ----------------------------------------------------------------------------
24 //####COPYRIGHTEND####
25 // PkgAdmin.cpp : Defines the class behaviors for the application.
29 #include "CSHDialog.h"
30 #include "eCosDialog.h"
33 #include "PkgAdminDlg.h"
39 static char THIS_FILE[] = __FILE__;
42 /////////////////////////////////////////////////////////////////////////////
45 BEGIN_MESSAGE_MAP(CPkgAdminApp, CWinApp)
46 //{{AFX_MSG_MAP(CPkgAdminApp)
47 // NOTE - the ClassWizard will add and remove mapping macros here.
48 // DO NOT EDIT what you see in these blocks of generated code!
50 ON_COMMAND(ID_HELP, CWinApp::OnHelp)
53 /////////////////////////////////////////////////////////////////////////////
54 // CPkgAdminApp construction
56 CPkgAdminApp::CPkgAdminApp()
58 // TODO: add construction code here,
59 // Place all significant initialization in InitInstance
62 /////////////////////////////////////////////////////////////////////////////
63 // The one and only CPkgAdminApp object
67 /////////////////////////////////////////////////////////////////////////////
68 // CPkgAdminApp initialization
70 BOOL CPkgAdminApp::InitInstance()
73 ::GetModuleFileName(::GetModuleHandle(NULL),strCSHFile.GetBuffer(1+MAX_PATH),MAX_PATH);
74 strCSHFile.ReleaseBuffer();
75 strCSHFile.ReplaceExtension(_T(".chm"));
76 CCSHDialog::SetCSHFilePath(strCSHFile);
78 extern UINT arPkgAdminDialogMap[];
79 CeCosDialog::AddDialogMap(arPkgAdminDialogMap);
81 SetRegistryKey (_T("Red Hat\\eCos"));
83 // Standard initialization
84 // If you are not using these features and wish to reduce the size
85 // of your final executable, you should remove from the following
86 // the specific initialization routines you do not need.
87 LPCTSTR pszRepositoryKeyName=_T("Software\\Red Hat\\eCos\\Common\\Repository");
88 LPCTSTR pszRepositoryValueName=_T("Folder");
90 CFileName strRepository;
92 CRegKeyEx k(HKEY_CURRENT_USER,pszRepositoryKeyName, KEY_READ);
93 if(k.QueryValue(pszRepositoryValueName, strRepository)){
94 if ((strRepository + _T("ecc")).IsDir () && ! (strRepository + _T("packages")).IsDir ()) {
95 strRepository += _T("ecc");
97 strRepository += _T("packages");
102 CPkgAdminDlg dlg(strRepository);
103 dlg.m_hIcon = LoadIcon(IDR_PKGADMIN_MAINFRAME);
106 int nResponse = dlg.DoModal();
108 dlg.m_strRepository.Replace(_TCHAR('/'),_TCHAR('\\'));
109 int nIndex=dlg.m_strRepository.ReverseFind(_TCHAR('\\'));
111 CRegKeyEx k(HKEY_CURRENT_USER,pszRepositoryKeyName, KEY_WRITE);
112 k.SetValue(dlg.m_strRepository.Left(nIndex), pszRepositoryValueName);
115 // Since the dialog has been closed, return FALSE so that we exit the
116 // application, rather than start the application's message pump.