| 1477 | } |
| 1478 | |
| 1479 | BFP_EXPORT void BFP_CALLTYPE BfpProcess_GetMainWindowTitle(BfpProcess* process, char* outTitle, int* inOutTitleSize, BfpProcessResult* outResult) |
| 1480 | { |
| 1481 | HWND mainWindow = NULL; |
| 1482 | |
| 1483 | // |
| 1484 | { |
| 1485 | AutoCrit autoCrit(gBfpCritSect); |
| 1486 | |
| 1487 | if ((gMainWindowCache.mLastUpdate == 0) || (BFTickCount() - gMainWindowCache.mLastUpdate > 100)) |
| 1488 | { |
| 1489 | gMainWindowCache.mMap.Clear(); |
| 1490 | ::EnumWindows(EnumWndProc, 0); |
| 1491 | gMainWindowCache.mLastUpdate = BFTickCount(); |
| 1492 | } |
| 1493 | |
| 1494 | gMainWindowCache.mMap.TryGetValue(process->mProcessId, &mainWindow); |
| 1495 | } |
| 1496 | |
| 1497 | /*EnumWndData enumWndData; |
| 1498 | enumWndData.mBestHandle = NULL; |
| 1499 | enumWndData.mProcessId = process->mProcessId;*/ |
| 1500 | |
| 1501 | String title; |
| 1502 | |
| 1503 | if (mainWindow != NULL) |
| 1504 | { |
| 1505 | int wantSize = 128; |
| 1506 | |
| 1507 | while (true) |
| 1508 | { |
| 1509 | WCHAR* str = new WCHAR[wantSize]; |
| 1510 | |
| 1511 | int size = ::GetWindowTextW(mainWindow, str, wantSize) + 1; |
| 1512 | |
| 1513 | if (size <= 0) |
| 1514 | { |
| 1515 | delete str; |
| 1516 | break; |
| 1517 | } |
| 1518 | |
| 1519 | if (size <= wantSize) |
| 1520 | { |
| 1521 | title = UTF8Encode(str); |
| 1522 | delete str; |
| 1523 | break; |
| 1524 | } |
| 1525 | |
| 1526 | delete str; |
| 1527 | wantSize = size; |
| 1528 | } |
| 1529 | } |
| 1530 | |
| 1531 | TryStringOut(title, outTitle, inOutTitleSize, (BfpResult*)outResult); |
| 1532 | } |
| 1533 | |
| 1534 | BFP_EXPORT void BFP_CALLTYPE BfpProcess_GetProcessName(BfpProcess* process, char* outName, int* inOutNameSize, BfpProcessResult* outResult) |
| 1535 | { |
nothing calls this directly
no test coverage detected