Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenfreeldrpage.c
Go to the documentation of this file.
00001 /* 00002 * PROJECT: ReactOS Applications 00003 * LICENSE: LGPL - See COPYING in the top level directory 00004 * FILE: base/applications/msconfig/freeldrpage.c 00005 * PURPOSE: Freeloader configuration page message handler 00006 * COPYRIGHT: Copyright 2005-2006 Christoph von Wittich <Christoph@ApiViewer.de> 00007 * 2011 Gregor Schneider <Gregor.Schneider@reactos.org> 00008 */ 00009 00010 #include <precomp.h> 00011 00012 HWND hFreeLdrPage; 00013 HWND hFreeLdrDialog; 00014 00015 typedef struct 00016 { 00017 ULONG TimeOut; 00018 WCHAR szDefaultOS[512]; 00019 ULONG szDefaultPos; 00020 ULONG OSConfigurationCount; 00021 BOOL UseBootIni; 00022 } FREELDR_SETTINGS; 00023 00024 static FREELDR_SETTINGS Settings = { 0, { 0, }, 0, 0, FALSE }; 00025 00026 #define BUFFER_SIZE 512 00027 00028 static BOOL 00029 LoadBootIni(WCHAR *szDrive, HWND hDlg) 00030 { 00031 WCHAR szBuffer[BUFFER_SIZE]; 00032 HWND hDlgCtrl; 00033 FILE * file; 00034 UINT length; 00035 LRESULT pos; 00036 00037 wcscpy(szBuffer, szDrive); 00038 wcscat(szBuffer, L"freeldr.ini"); 00039 00040 file = _wfopen(szBuffer, L"rt"); 00041 if (!file) 00042 { 00043 wcscpy(szBuffer, szDrive); 00044 wcscat(szBuffer, L"boot.ini"); 00045 file = _wfopen(szBuffer, L"rt"); 00046 if (!file) 00047 return FALSE; 00048 } 00049 00050 hDlgCtrl = GetDlgItem(hDlg, IDC_LIST_BOX); 00051 00052 while(!feof(file)) 00053 { 00054 if (fgetws(szBuffer, BUFFER_SIZE, file)) 00055 { 00056 length = wcslen(szBuffer); 00057 if (length > 1) 00058 { 00059 szBuffer[length] = L'\0'; 00060 szBuffer[length - 1] = L'\0'; 00061 00062 pos = SendMessageW(hDlgCtrl, LB_ADDSTRING, 0, (LPARAM)szBuffer); 00063 00064 if (szBuffer[0] == L'[') 00065 continue; 00066 00067 if (!_wcsnicmp(szBuffer, L"timeout=", 8)) 00068 { 00069 Settings.TimeOut = _wtoi(&szBuffer[8]); 00070 continue; 00071 } 00072 00073 if (!_wcsnicmp(szBuffer, L"default=", 8)) 00074 { 00075 wcscpy(Settings.szDefaultOS, &szBuffer[8]); 00076 continue; 00077 } 00078 if (pos != LB_ERR) 00079 SendMessage(hDlgCtrl, LB_SETITEMDATA, pos, 1); // indicate that this item is an boot entry 00080 Settings.OSConfigurationCount++; 00081 } 00082 } 00083 } 00084 00085 fclose(file); 00086 Settings.UseBootIni = TRUE; 00087 00088 pos = SendMessageW(hDlgCtrl, LB_FINDSTRING, 3, (LPARAM)Settings.szDefaultOS); 00089 if (pos != LB_ERR) 00090 { 00091 Settings.szDefaultPos = pos; 00092 SendMessage(hDlgCtrl, LB_SETCURSEL, pos, 0); 00093 } 00094 00095 SetDlgItemInt(hDlg, IDC_TXT_BOOT_TIMEOUT, Settings.TimeOut, FALSE); 00096 if (Settings.OSConfigurationCount < 2) 00097 { 00098 EnableWindow(GetDlgItem(hDlg, IDC_BTN_SET_DEFAULT_BOOT), FALSE); 00099 EnableWindow(GetDlgItem(hDlg, IDC_BTN_MOVE_UP_BOOT_OPTION), FALSE); 00100 EnableWindow(GetDlgItem(hDlg, IDC_BTN_MOVE_DOWN_BOOT_OPTION), FALSE); 00101 } 00102 return TRUE; 00103 } 00104 00105 static BOOL 00106 InitializeFreeLDRDialog(HWND hDlg) 00107 { 00108 WCHAR winDir[PATH_MAX]; 00109 WCHAR* ptr = NULL; 00110 00111 GetWindowsDirectoryW(winDir, PATH_MAX); 00112 ptr = wcschr(winDir, L'\\'); 00113 if (ptr == NULL) 00114 { 00115 return FALSE; 00116 } 00117 ptr[1] = L'\0'; 00118 return LoadBootIni(winDir, hDlg); 00119 } 00120 00121 INT_PTR CALLBACK 00122 FreeLdrPageWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) 00123 { 00124 LRESULT pos; 00125 00126 switch (message) { 00127 case WM_INITDIALOG: 00128 hFreeLdrDialog = hDlg; 00129 SetWindowPos(hDlg, NULL, 10, 32, 0, 0, SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOSIZE | SWP_NOZORDER); 00130 InitializeFreeLDRDialog(hDlg); 00131 return TRUE; 00132 case WM_COMMAND: 00133 switch(HIWORD(wParam)) 00134 { 00135 case LBN_SELCHANGE: 00136 pos = SendMessage((HWND)lParam, LB_GETCURSEL, 0, 0); 00137 if (pos != LB_ERR) 00138 { 00139 LPARAM res = SendMessage((HWND)lParam, LB_GETITEMDATA, pos, 0); 00140 if (!res) //line is not a default one 00141 SendMessage((HWND)lParam, LB_SETCURSEL, Settings.szDefaultPos, 0); 00142 else 00143 Settings.szDefaultPos = pos; 00144 00145 00146 } 00147 break; 00148 } 00149 } 00150 return 0; 00151 } Generated on Sun May 27 2012 04:16:57 for ReactOS by
1.7.6.1
|