| 199 | } |
| 200 | |
| 201 | static int check_swap(printInfoStruct& printInfo) |
| 202 | { |
| 203 | // Needs explicit cast: http://msinilo.pl/blog2/post/p1348/ |
| 204 | PENUM_PAGE_FILE_CALLBACKW pageFileCallback = (PENUM_PAGE_FILE_CALLBACKW)EnumPageFilesProc; |
| 205 | std::vector<pageFileInfo> pageFiles; |
| 206 | |
| 207 | if(!EnumPageFilesW(pageFileCallback, &pageFiles)) { |
| 208 | printErrorInfo(); |
| 209 | return 3; |
| 210 | } |
| 211 | |
| 212 | for (int i = 0; i < pageFiles.size(); i++) { |
| 213 | printInfo.tSwap += round(pageFiles.at(i).totalSwap / pow(1024.0, printInfo.unit)); |
| 214 | printInfo.aSwap += round(pageFiles.at(i).availableSpwap / pow(1024.0, printInfo.unit)); |
| 215 | } |
| 216 | |
| 217 | if (printInfo.aSwap > 0 && printInfo.tSwap > 0) |
| 218 | printInfo.percentFree = 100.0 * printInfo.aSwap / printInfo.tSwap; |
| 219 | else |
| 220 | printInfo.percentFree = 0; |
| 221 | |
| 222 | return -1; |
| 223 | } |
| 224 | |
| 225 | int wmain(int argc, WCHAR **argv) |
| 226 | { |
no test coverage detected