Here is 'brute force' VC6 macro which works on single .cpp or .h file opened in editor by commenting include by include and running compile:
Sub RemoveNotUsedIncludes()
'Check if already processed; Exit if so
ActiveDocument.Selection.FindText "//INCLUDE NOT USED", dsMatchFromStart
IF ActiveDocument.Selection <> "" THEN
ActiveDocument.Selection.SetBookmark
MsgBox "Already checked"
ActiveDocument.Selection.ClearBookmark
EXIT SUB
END IF
'Find first #include; Exit if not found
ActiveDocument.Selection.FindText "#include", dsMatchFromStart
IF ActiveDocument.Selection = "" THEN
MsgBox "No #include found"
EXIT SUB
END IF
Dim FirstIncludeLine
FirstIncludeLine = ActiveDocument.Selection.CurrentLine
FOR i=1 TO 200
'Test build
ActiveDocument.Selection.SetBookmark
ActiveDocument.Selection = "//CHECKING... #include"
Build
ActiveDocument.Undo
ActiveDocument.Selection.ClearBookmark
IF Errors = 0 THEN
'If build failed add comment
ActiveDocument.Selection.EndOfLine
ActiveDocument.Selection = " //INCLUDE NOT USED"
END IF
'Find next include
ActiveDocument.Selection.EndOfLine
ActiveDocument.Selection.FindText "#include"
'If all includes tested exit
IF ActiveDocument.Selection.CurrentLine = FirstIncludeLine THEN EXIT FOR
NEXT
End Sub
Of case it could be improved to work on whole project.