XKeymacs for 64bit Windows
Révision | dd6b078bb17f6a03cf8e6a5c3413e17e91550dcc (tree) |
---|---|
l'heure | 2011-05-27 08:36:10 |
Auteur | Kazuhiro Fujieda <fujieda@user...> |
Commiter | Kazuhiro Fujieda |
Rewrite CProfile::GetTaskList.
Delete PROCESS_SIZE macro. Make m_TaskList and m_dwTasks in CProfile
private. GetTaskList operates them directly. Remove arguments and
the return value of it. Remove code to delete directory names in it.
@@ -1108,7 +1108,7 @@ void CProfile::InitApplicationList(CComboBox *const cApplicationList) | ||
1108 | 1108 | { |
1109 | 1109 | cApplicationList->ResetContent(); |
1110 | 1110 | |
1111 | - m_dwTasks = GetTaskList(m_TaskList, MAX_TASKS); | |
1111 | + GetTaskList(); | |
1112 | 1112 | |
1113 | 1113 | EnumWindows(EnumWindowsProc, (LPARAM)cApplicationList); |
1114 | 1114 |
@@ -1171,39 +1171,24 @@ void CProfile::InitApplicationList(CComboBox *const cApplicationList) | ||
1171 | 1171 | cApplicationList->SelectString(-1, CString(MAKEINTRESOURCE(IDS_DEFAULT_TITLE))); |
1172 | 1172 | } |
1173 | 1173 | |
1174 | -DWORD CProfile::GetTaskList(PTASK_LIST pTask, const DWORD dwNumTasks) | |
1174 | +void CProfile::GetTaskList() | |
1175 | 1175 | { |
1176 | - for (int i = 0; i < MAX_TASKS; ++i) { | |
1177 | - ZeroMemory(&pTask[i], sizeof(PTASK_LIST)); | |
1178 | - } | |
1176 | + ZeroMemory(m_TaskList, sizeof(m_TaskList)); | |
1179 | 1177 | |
1180 | 1178 | HANDLE hProcessSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); |
1181 | - if (hProcessSnap == (HANDLE)-1) { | |
1182 | - return 0; | |
1183 | - } | |
1179 | + if (hProcessSnap == (HANDLE)-1) | |
1180 | + return; | |
1184 | 1181 | |
1185 | - DWORD dwTaskCount = 0; | |
1182 | + m_dwTasks = 0; | |
1186 | 1183 | PROCESSENTRY32 processEntry32 = {sizeof(PROCESSENTRY32)}; |
1187 | 1184 | if (Process32First(hProcessSnap, &processEntry32)) { |
1188 | 1185 | do { |
1189 | - LPTSTR pCurChar = NULL; | |
1190 | - for (pCurChar = processEntry32.szExeFile + lstrlen(processEntry32.szExeFile); *pCurChar != _T('\\') && pCurChar != processEntry32.szExeFile; --pCurChar) { | |
1191 | - ; | |
1192 | - } | |
1193 | - if (*pCurChar == _T('\\')) { | |
1194 | - ++pCurChar; | |
1195 | - } | |
1196 | - | |
1197 | - lstrcpy(pTask->ProcessName, pCurChar); | |
1198 | - pTask->dwProcessId = processEntry32.th32ProcessID; | |
1199 | - | |
1200 | - ++dwTaskCount; | |
1201 | - ++pTask; | |
1202 | - } while (dwTaskCount < dwNumTasks && Process32Next(hProcessSnap, &processEntry32)); | |
1186 | + lstrcpy(m_TaskList[m_dwTasks].ProcessName, processEntry32.szExeFile); | |
1187 | + m_TaskList[m_dwTasks++].dwProcessId = processEntry32.th32ProcessID; | |
1188 | + } while (m_dwTasks < MAX_TASKS && Process32Next(hProcessSnap, &processEntry32)); | |
1203 | 1189 | } |
1204 | 1190 | |
1205 | 1191 | CloseHandle(hProcessSnap); |
1206 | - return dwTaskCount; | |
1207 | 1192 | } |
1208 | 1193 | |
1209 | 1194 | // return application index |
@@ -12,11 +12,9 @@ | ||
12 | 12 | #include <winperf.h> // for Windows NT |
13 | 13 | #include "resource.h" |
14 | 14 | |
15 | -#define PROCESS_SIZE MAX_PATH | |
16 | - | |
17 | 15 | struct TASK_LIST { |
18 | 16 | DWORD dwProcessId; |
19 | - CHAR ProcessName[PROCESS_SIZE]; | |
17 | + CHAR ProcessName[MAX_PATH]; | |
20 | 18 | }; |
21 | 19 | typedef TASK_LIST *PTASK_LIST; |
22 | 20 |
@@ -206,8 +204,6 @@ public: | ||
206 | 204 | static void GetApplicationTitle(CComboBox *cApplicationList, CString &rList, int nIndex = -1); |
207 | 205 | static BOOL IsDefault(CString sz); |
208 | 206 | static int GetApplicationIndex(CString szApplicationName, BOOL bSaveAndValidate, int *nSettingStyle); |
209 | - static TASK_LIST m_TaskList[MAX_TASKS]; | |
210 | - static DWORD m_dwTasks; | |
211 | 207 | static void InitApplicationList(CComboBox *cApplicationList); |
212 | 208 | static int GetSavedSettingCount(); |
213 | 209 | static void ClearData(CString szCurrentApplication); |
@@ -242,7 +238,9 @@ private: | ||
242 | 238 | static void SetDllData(); |
243 | 239 | static CXkeymacsData m_XkeymacsData[MAX_APP]; |
244 | 240 | static void DeleteAllRegistryData(); |
245 | - static DWORD GetTaskList(PTASK_LIST pTask, DWORD dwNumTasks); | |
241 | + static TASK_LIST m_TaskList[MAX_TASKS]; | |
242 | + static DWORD m_dwTasks; | |
243 | + static void GetTaskList(); | |
246 | 244 | static BOOL IsCommandType(int nCommandType, LPCTSTR szKeyBind); |
247 | 245 | static int KeyBind2Key(LPCTSTR szKey); |
248 | 246 | static int KeyBind2CommandType(LPCTSTR szKeyBind); |