Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenuserprofile.c
Go to the documentation of this file.
00001 /* 00002 * PROJECT: ReactOS System Control Panel Applet 00003 * LICENSE: GPL - See COPYING in the top level directory 00004 * FILE: dll/cpl/sysdm/userprofile.c 00005 * PURPOSE: Computer settings for networking 00006 * COPYRIGHT: Copyright Thomas Weidenmueller <w3seek@reactos.org> 00007 * Copyright 2006 Ged Murphy <gedmurphy@gmail.com> 00008 * 00009 */ 00010 00011 #include "precomp.h" 00012 00013 00014 static VOID 00015 SetListViewColumns(HWND hwndListView) 00016 { 00017 LV_COLUMN column; 00018 RECT rect; 00019 TCHAR szStr[32]; 00020 00021 GetClientRect(hwndListView, &rect); 00022 00023 SendMessage(hwndListView, LVM_SETEXTENDEDLISTVIEWSTYLE, 0, LVS_EX_FULLROWSELECT); 00024 00025 memset(&column, 0x00, sizeof(column)); 00026 column.mask = LVCF_FMT | LVCF_WIDTH | LVCF_SUBITEM | LVCF_TEXT; 00027 column.fmt = LVCFMT_LEFT; 00028 column.cx = (INT)((rect.right - rect.left) * 0.40); 00029 column.iSubItem = 0; 00030 LoadString(hApplet, IDS_USERPROFILE_NAME, szStr, 32); 00031 column.pszText = szStr; 00032 (void)ListView_InsertColumn(hwndListView, 0, &column); 00033 00034 column.fmt = LVCFMT_RIGHT; 00035 column.cx = (INT)((rect.right - rect.left) * 0.15); 00036 column.iSubItem = 1; 00037 LoadString(hApplet, IDS_USERPROFILE_SIZE, szStr, 32); 00038 column.pszText = szStr; 00039 (void)ListView_InsertColumn(hwndListView, 1, &column); 00040 00041 column.fmt = LVCFMT_LEFT; 00042 column.cx = (INT)((rect.right - rect.left) * 0.15); 00043 column.iSubItem = 2; 00044 LoadString(hApplet, IDS_USERPROFILE_TYPE, szStr, 32); 00045 column.pszText = szStr; 00046 (void)ListView_InsertColumn(hwndListView, 2, &column); 00047 00048 column.fmt = LVCFMT_LEFT; 00049 column.cx = (INT)((rect.right - rect.left) * 0.15); 00050 column.iSubItem = 3; 00051 LoadString(hApplet, IDS_USERPROFILE_STATUS, szStr, 32); 00052 column.pszText = szStr; 00053 (void)ListView_InsertColumn(hwndListView, 3, &column); 00054 00055 column.fmt = LVCFMT_LEFT; 00056 column.cx = (INT)((rect.right - rect.left) * 0.15) - GetSystemMetrics(SM_CYHSCROLL); 00057 column.iSubItem = 4; 00058 LoadString(hApplet, IDS_USERPROFILE_MODIFIED, szStr, 32); 00059 column.pszText = szStr; 00060 (void)ListView_InsertColumn(hwndListView, 4, &column); 00061 } 00062 00063 00064 static VOID 00065 AddUserProfile(HWND hwndListView, 00066 LPTSTR lpProfileSid) 00067 { 00068 LV_ITEM lvi; 00069 00070 memset(&lvi, 0x00, sizeof(lvi)); 00071 lvi.mask = LVIF_TEXT | LVIF_STATE; 00072 lvi.pszText = lpProfileSid; 00073 lvi.state = 0; 00074 ListView_InsertItem(hwndListView, &lvi); 00075 } 00076 00077 00078 static VOID 00079 AddUserProfiles(HWND hwndListView) 00080 { 00081 HKEY hKeyUserProfiles; 00082 DWORD dwIndex; 00083 TCHAR szProfileSid[64]; 00084 DWORD dwSidLength; 00085 FILETIME ftLastWrite; 00086 00087 if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, 00088 _T("Software\\Microsoft\\Windows NT\\CurrentVersion\\ProfileList"), 00089 0, 00090 KEY_READ, 00091 &hKeyUserProfiles)) 00092 return; 00093 00094 for (dwIndex = 0; ; dwIndex++) 00095 { 00096 dwSidLength = 64; 00097 if (RegEnumKeyEx(hKeyUserProfiles, 00098 dwIndex, 00099 szProfileSid, 00100 &dwSidLength, 00101 NULL, 00102 NULL, 00103 NULL, 00104 &ftLastWrite)) 00105 break; 00106 00107 AddUserProfile(hwndListView, szProfileSid); 00108 } 00109 00110 RegCloseKey(hKeyUserProfiles); 00111 } 00112 00113 00114 static VOID 00115 OnInitDialog(HWND hwndDlg) 00116 { 00117 /* Initialize the list view control */ 00118 SetListViewColumns(GetDlgItem(hwndDlg, IDC_USERPROFILE_LIST)); 00119 00120 AddUserProfiles(GetDlgItem(hwndDlg, IDC_USERPROFILE_LIST)); 00121 00122 /* Disable the "Delete" and "Copy To" buttons if the user is not an admin */ 00123 if (!IsUserAnAdmin()) 00124 { 00125 EnableWindow(GetDlgItem(hwndDlg, IDC_USERPROFILE_DELETE), FALSE); 00126 EnableWindow(GetDlgItem(hwndDlg, IDC_USERPROFILE_COPY), FALSE); 00127 } 00128 } 00129 00130 00131 /* Property page dialog callback */ 00132 INT_PTR CALLBACK 00133 UserProfileDlgProc(HWND hwndDlg, 00134 UINT uMsg, 00135 WPARAM wParam, 00136 LPARAM lParam) 00137 { 00138 switch (uMsg) 00139 { 00140 case WM_INITDIALOG: 00141 OnInitDialog(hwndDlg); 00142 break; 00143 00144 case WM_COMMAND: 00145 if ((LOWORD(wParam) == IDOK) || (LOWORD(wParam) == IDCANCEL)) 00146 { 00147 EndDialog(hwndDlg, 00148 LOWORD(wParam)); 00149 return TRUE; 00150 } 00151 break; 00152 00153 case WM_NOTIFY: 00154 { 00155 NMHDR *nmhdr = (NMHDR *)lParam; 00156 00157 if (nmhdr->idFrom == IDC_USERACCOUNT_LINK && nmhdr->code == NM_CLICK) 00158 { 00159 ShellExecute(hwndDlg, 00160 TEXT("open"), 00161 TEXT("rundll32.exe"), 00162 TEXT("shell32.dll, Control_RunDLL nusrmgr.cpl"), 00163 NULL, 00164 SW_SHOWNORMAL); 00165 } 00166 break; 00167 } 00168 } 00169 00170 return FALSE; 00171 } Generated on Sat May 26 2012 04:19:46 for ReactOS by
1.7.6.1
|