3 * PROJECT: ReactOS System Control Panel Applet
4 * LICENSE: GPL - See COPYING in the top level directory
5 * FILE: dll/cpl/sysdm/startrec.c
6 * PURPOSE: Computer settings for startup and recovery
7 * COPYRIGHT: Copyright 2006 Ged Murphy <gedmurphy@gmail.com>
8 * Copyright 2006 Christoph von Wittich <Christoph@ApiViewer.de>
14 static TCHAR m_szFreeldrIni
[MAX_PATH
+ 15];
16 void SetTimeout(HWND hwndDlg
, int Timeout
)
20 EnableWindow(GetDlgItem(hwndDlg
, IDC_STRRECLISTUPDWN
), FALSE
);
24 EnableWindow(GetDlgItem(hwndDlg
, IDC_STRRECLISTUPDWN
), TRUE
);
26 SendDlgItemMessage(hwndDlg
, IDC_STRRECLISTUPDWN
, UDM_SETPOS
, (WPARAM
) 0, (LPARAM
) MAKELONG((short) Timeout
, 0));
29 /* Property page dialog callback */
31 StartRecDlgProc(HWND hwndDlg
,
37 TCHAR szDefaultOS
[MAX_PATH
];
38 TCHAR szDefaultOSName
[MAX_PATH
];
42 UNREFERENCED_PARAMETER(lParam
);
50 /* get Path to freeldr.ini or boot.ini */
51 szSystemDrive
= HeapAlloc(GetProcessHeap(), 0, MAX_PATH
* sizeof(TCHAR
));
52 if (szSystemDrive
!= NULL
)
54 dwBufSize
= GetEnvironmentVariable(_T("SystemDrive"), szSystemDrive
, MAX_PATH
);
55 if (dwBufSize
> MAX_PATH
)
60 szTmp
= HeapReAlloc(GetProcessHeap(), 0, szSystemDrive
, dwBufSize
* sizeof(TCHAR
));
64 szSystemDrive
= szTmp
;
66 dwBufSize2
= GetEnvironmentVariable(_T("SystemDrive"), szSystemDrive
, dwBufSize
);
67 if (dwBufSize2
> dwBufSize
|| dwBufSize2
== 0)
70 else if (dwBufSize
== 0)
73 HeapFree(GetProcessHeap(), 0, szSystemDrive
);
77 if (szSystemDrive
!= NULL
)
79 if (m_szFreeldrIni
!= NULL
)
81 _tcscpy(m_szFreeldrIni
, szSystemDrive
);
82 _tcscat(m_szFreeldrIni
, _T("\\freeldr.ini"));
83 if (!PathFileExists(m_szFreeldrIni
))
85 _tcscpy(m_szFreeldrIni
, szSystemDrive
);
86 _tcscat(m_szFreeldrIni
, _T("\\boot.ini"));
89 HeapFree(GetProcessHeap(), 0, szSystemDrive
);
93 SetDlgItemText(hwndDlg
, IDC_STRRECDUMPFILE
, _T("%SystemRoot%\\MiniDump"));
95 /* load settings from freeldr.ini */
96 GetPrivateProfileString(_T("boot loader"), _T("default"), NULL
, szDefaultOS
, MAX_PATH
, m_szFreeldrIni
);
97 GetPrivateProfileString(_T("operating systems"), szDefaultOS
, NULL
, szDefaultOSName
, MAX_PATH
, m_szFreeldrIni
);
98 SendDlgItemMessage(hwndDlg
, IDC_STRECOSCOMBO
, CB_ADDSTRING
, (WPARAM
)0, (LPARAM
)szDefaultOSName
);
99 SendDlgItemMessage(hwndDlg
, IDC_STRECOSCOMBO
, CB_SETCURSEL
, (WPARAM
)0, (LPARAM
)0);
102 iTimeout
= GetPrivateProfileInt(_T("boot loader"), _T("timeout"), 0, m_szFreeldrIni
);
103 SetTimeout(hwndDlg
, iTimeout
);
105 SendDlgItemMessage(hwndDlg
, IDC_STRECLIST
, BM_SETCHECK
, (WPARAM
)BST_CHECKED
, (LPARAM
)0);
112 switch(LOWORD(wParam
))
116 ShellExecute(0, _T("open"), _T("notepad"), m_szFreeldrIni
, NULL
, SW_SHOWNORMAL
);
122 if (SendDlgItemMessage(hwndDlg
, IDC_STRECLIST
, BM_GETCHECK
, (WPARAM
)0, (LPARAM
)0) == BST_CHECKED
)
123 iTimeout
= SendDlgItemMessage(hwndDlg
, IDC_STRRECLISTUPDWN
, UDM_GETPOS
, (WPARAM
)0, (LPARAM
)0);
126 _stprintf(szTimeout
, _T("%i"), iTimeout
);
127 WritePrivateProfileString(_T("boot loader"), _T("timeout"), szTimeout
, m_szFreeldrIni
);
138 if (SendDlgItemMessage(hwndDlg
, IDC_STRECLIST
, BM_GETCHECK
, (WPARAM
)0, (LPARAM
)0) == BST_CHECKED
)
139 SetTimeout(hwndDlg
, 30);
141 SetTimeout(hwndDlg
, 0);