1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
   |  
int CALLBACK ListViewCompareProc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort)
{
 
	bool isAsc = (lParamSort > 0);
	int column = abs(lParamSort) - 1;
 
	LVITEM row1;
	row1.mask =  LVIF_PARAM;
 
	row1.iItem = (int)lParam1;
	ListView_GetItem(DMAppView::_hListView, &row1);
 
	LVITEM row2;
	row2.mask =  LVIF_PARAM;
 
	row2.iItem = (int)lParam2;
	ListView_GetItem(DMAppView::_hListView, &row2);
 
	ProcessInfos *item1 = (ProcessInfos *)row1.lParam;
	ProcessInfos *item2 = (ProcessInfos *)row2.lParam;
 
	switch (column)
	{
		case 0:
		{
			if (isAsc) return generic_stricmp(item1->_procName.c_str(), item2->_procName.c_str());
			else return generic_stricmp(item2->_procName.c_str(), item1->_procName.c_str());
			break;
		}
                //PID
		case 1:
		{			
			if (isAsc) return generic_stricmp(item1->_procId.c_str(), item2->_procId.c_str());
			else return generic_stricmp(item2->_procId.c_str(), item1->_procId.c_str());
			break;
		}
 
		case 2:
		{
			if (isAsc) return generic_stricmp(item1->_protocol.c_str(), item2->_protocol.c_str());
			else return generic_stricmp(item2->_protocol.c_str(), item1->_protocol.c_str());
			break;
		}
               //Local Port
		case 3:
		{
			if (isAsc) return generic_stricmp(item1->_localPort.c_str(), item2->_localPort.c_str());
			else return generic_stricmp(item2->_localPort.c_str(), item1->_localPort.c_str());
			break;
		}
 
		case 4:
		{
			if (isAsc) return generic_stricmp(item1->_localAddr.c_str(), item2->_localAddr.c_str());
			else return generic_stricmp(item2->_localAddr.c_str(), item1->_localAddr.c_str());
			break;
		}
 
		case 5:
		{
			if (isAsc) return generic_stricmp(item1->_remotePort.c_str(), item2->_remotePort.c_str());
			else return generic_stricmp(item2->_remotePort.c_str(), item1->_remotePort.c_str());
			break;
		}
 
		case 6:
		{
			if (isAsc) return generic_stricmp(item1->_remoteAddr.c_str(), item2->_remoteAddr.c_str());
			else return generic_stricmp(item2->_remoteAddr.c_str(), item1->_remoteAddr.c_str());
			break;
		}
 
		case 7:
		{
			if (isAsc) return generic_stricmp(item1->_state.c_str(), item2->_state.c_str());
			else return generic_stricmp(item2->_state.c_str(), item1->_state.c_str());
			break;
		}
 
		case 8:
		{
			if (isAsc) return generic_stricmp(item1->_procPath.c_str(), item2->_procPath.c_str());
			else return generic_stricmp(item2->_procPath.c_str(), item1->_procPath.c_str());
			break;
		}
	}
	return 0;
}; | 
Partager