Announcement

Collapse
No announcement yet.

Windows defender - compile ListView sample

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Windows defender - compile ListView sample

    I've tried removing manifest, renamed .bas file and compiled in different folders.
    Windows 10 defender takes 5 seconds or more to compile the PowerBASIC DDT listview sample.
    I've tried excluding files/folders processes and Windows 10 defender still takes a long time.
    Tried on different machines and defender is always slow compiling this.

    Turn off Windows 10 defender and it instantly compiles.
    Big programs compile quickly.

    Any ideas, why defender hesitates on this code? c:\pbwin10\samples\ddt\listview\listview.bas

    Too little code for a listview?

    Code:
    '====================================================================
    '
    '   ListView.bas example for PowerBASIC for Windows
    '   Copyright (c) 2009 - 2011 PowerBASIC, Inc.
    '   All Rights Reserved.
    '
    '   Example of using a subitems in a ListView control
    '   Also see the \Samples\DDT\Toolbar for another ListView
    '   sample application.
    '
    '====================================================================
    
    #COMPILER PBWIN 10
    #COMPILE EXE
    #DIM ALL
    
    ' Add the XP Manifest resrouce file
    #RESOURCE MANIFEST, 1, "XPTheme.xml"
    
    #INCLUDE ONCE "win32api.inc"
    
    ' Old Listview callback procedure pointer
    GLOBAL OldLVProc AS LONG
    
    %LVROWS = 200            ' Number of rows in the ListView
    %LVCOLS = 3              ' Number of columns in the ListView
    
    %ID_LABEL    = 1000      ' Id of the label control
    %ID_LISTVIEW = 1001      ' id of the ListView control
    
    ' Application main entry point
    FUNCTION PBMAIN () AS LONG
      LOCAL hDlg  AS LONG    ' Handle to the dialog
      LOCAL i     AS LONG    ' Column counter variable
      LOCAL j     AS LONG    ' Row counter variable
    
      DIALOG NEW 0, "ListView Subitem Example", , , 314, 215, _
        %WS_POPUP OR %WS_BORDER OR %WS_DLGFRAME OR %WS_CAPTION OR _
        %WS_SYSMENU OR %WS_MINIMIZEBOX OR %WS_CLIPSIBLINGS OR %WS_VISIBLE _
        OR %DS_MODALFRAME OR %DS_3DLOOK OR %DS_NOFAILCREATE OR %DS_SETFONT, _
        %WS_EX_CONTROLPARENT OR %WS_EX_LEFT OR %WS_EX_LTRREADING OR _
        %WS_EX_RIGHTSCROLLBAR, TO hDlg
    
      CONTROL ADD LABEL, hDlg, %ID_LABEL, _
        "Use the Mouse, Arrow keys, PgUp, PgDn, Home, and End keys to navigate the ListView.", _
        1, 1, 313, 8, %SS_CENTER
      CONTROL SET COLOR hDlg, %ID_LABEL, %RGB_FIREBRICK, -1
    
      CONTROL ADD LISTVIEW, hDlg, %ID_LISTVIEW, "", 1, 14, 312, 200, _
        %WS_CHILD OR %WS_VISIBLE OR %WS_TABSTOP OR %LVS_REPORT OR %LVS_SHOWSELALWAYS OR %LVS_SINGLESEL
    
      ' Add some sample text to the ListView
      FOR i= 1 TO %LVCOLS
        LISTVIEW INSERT COLUMN hDlg, %ID_LISTVIEW, i, "Column #"+FORMAT$(i), 100, 0
      NEXT i
    
      FOR i=1 TO %LVROWS
        LISTVIEW INSERT ITEM hDlg, %ID_LISTVIEW, i, 0, "Row #"+FORMAT$(i, "000")+" Item #01"
        FOR j = 2 TO %LVCOLS
          LISTVIEW SET TEXT  hDlg, %ID_LISTVIEW, i, j, "Row #"+FORMAT$(i, "000")+" Item #"+FORMAT$(j, "00")
        NEXT j
      NEXT i
    
      DIALOG SHOW MODAL hDlg, CALL DlgProc
    END FUNCTION
    
    ' Dialog box callback procedure
    CALLBACK FUNCTION DlgProc
    
      SELECT CASE AS LONG CB.MSG
        CASE %WM_INITDIALOG
          ' Subclass the listview control so we can receive %WM_LButtonDown and %WM_KeyDown messages
          OldLVProc = SetWindowLongW(GetDlgItem(CB.HNDL, %ID_LISTVIEW), %GWL_WNDPROC, BYVAL CODEPTR(LVProc))
    
        CASE %WM_DESTROY
          ' Restore the listview controls original callback procedure
          SetWindowLongW(GetDlgItem(CB.HNDL, %ID_LISTVIEW), %GWL_WNDPROC, OldLVProc)
    
      END SELECT
    END FUNCTION
    
    ' ListView callback procedure
    FUNCTION LVProc(BYVAL hWnd AS LONG, BYVAL wMsg AS LONG, BYVAL wParam AS LONG, BYVAL lParam AS LONG) AS LONG
      STATIC COL      AS LONG            ' Selected column
      STATIC ROW      AS LONG            ' Selected row
      LOCAL  c        AS LONG            ' Number of rows per page
      LOCAL  LVHT     AS LVHITTESTINFO   ' Contains information about a mouse clik on the ListView
    
      SELECT CASE AS LONG wMsg
    
        CASE %WM_LBUTTONDOWN
          lvht.pt.x = LO(WORD, lparam)   ' X coordinate of mouse left button down
          lvht.pt.y = HI(WORD, lparam)   ' Y coordinate of mouse left button down
    
          ' Find the listview item and subitem at these X, Y coordinates
          SendMessageW(hwnd, %LVM_SUBITEMHITTEST, BYVAL 0, BYVAL VARPTR(LVHT))
    
          ' Did we find a listview item at these coordinates?
          IF lVHT.iItem <> -1 THEN
            ' Update the ListView with the new selection
            UpdateLVSelect(GetParent(hWnd), ROW, COL, lVHT.iItem+1 , LVHT.iSubItem+1)
          END IF
    
          ' We handled this message, so we need to return a zero
          ' and not call the the original listview callback.
          FUNCTION = 0
          EXIT FUNCTION
    
        CASE %WM_KEYDOWN
          SELECT CASE AS LONG wParam
    
            CASE %VK_UP
              ' Update the ListView with the new selection
              UpdateLVSelect(GetParent(hWnd), ROW, COL, ROW-1, COL)
    
            CASE %VK_DOWN
              ' Update the ListView with the new selection
              UpdateLVSelect(GetParent(hWnd), ROW, COL, ROW+1, COL)
    
            CASE %VK_RIGHT
              ' Update the ListView with the new selection
              UpdateLVSelect(GetParent(hWnd), ROW, COL, ROW, COL+1)
    
            CASE %VK_LEFT
              ' Update the ListView with the new selection
              UpdateLVSelect(GetParent(hWnd), ROW, COL, ROW, COL-1)
    
            CASE %VK_PGUP
              ' Get the number of rows per page in the ListView
              c = SendMessageW(hWnd, %LVM_GETCOUNTPERPAGE, 0, 0)
              ' Update the ListView with the new selection
              UpdateLVSelect(GetParent(hWnd), ROW, COL, ROW-c, COL)
    
            CASE %VK_PGDN
              ' Get the number of rows per page in the ListView
              c = SendMessageW(hWnd, %LVM_GETCOUNTPERPAGE, 0, 0)
              ' Update the ListView with the new selection
              UpdateLVSelect(GetParent(hWnd), ROW, COL, ROW+c, COL)
    
            CASE %VK_HOME
              ' Update the ListView with the new selection
              UpdateLVSelect(GetParent(hWnd), ROW, COL, 1, 1)
    
            CASE %VK_END
              ' Update the ListView with the new selection
              UpdateLVSelect(GetParent(hWnd), ROW, COL, %LVROWS, 1)
    
          END SELECT
    
          ' We handled this message, so we need to return a zero
          ' and not call the the original listview callback.
          FUNCTION = 0
          EXIT FUNCTION
    
      END SELECT
    
      ' if we did not handle this message, pass the message on to the
      ' original callback for the listview control.
      FUNCTION = CallWindowProcW(OldLVProc, hWnd, wMsg, wParam, lParam)
    END FUNCTION
    
    ' Unselect the previous listview selection, select the new item and then ensure the new
    ' item is visible.
    SUB UpdateLVSelect(BYVAL hDlg AS LONG, BYREF ROW AS LONG, BYREF COL AS LONG, BYVAL NewRow AS LONG, BYVAL NewCol AS LONG)
    
      ' Make sure the new row is within range
      IF NewRow < 1 THEN
        NewRow = 1
      ELSEIF NewRow > %LVROWS THEN
        NewRow = %LVROWS
      END IF
    
      ' Make sure the new column is within range
      IF NewCol < 1 THEN
        NewCol = 1
      ELSEIF NewCol > %LVCOLS THEN
        NewCol = %LVCOLS
      END IF
    
      ' If the previous and new selection are the same then do nothing
      IF (ROW = NewRow) AND (COL = NewCol) THEN EXIT SUB
    
      ' Unselect the previous selection, required when seleting subitems
      ' even if the ListView contains the %LVS_SINGLESEL style
      LISTVIEW UNSELECT hDlg, %ID_LISTVIEW, ROW, COL
    
      ' Update the Row and Column variables
      ROW = NewRow
      COL = NewCol
    
      ' Select the new ListView item
      LISTVIEW SELECT hDlg, %ID_LISTVIEW, ROW, COL
    
      ' Ensure the new ListView item is visible
      LISTVIEW VISIBLE hDlg, %ID_LISTVIEW, ROW
    END SUB
    https://duckduckgo.com instead of google

  • #2
    Mike, I haven't a clue but I sure would like to know the answer to this. My 552,000 line app takes 32+ seconds to compile with Defender turned on and my app directory excluded in Defender.

    Comment


    • #3
      I think Defender will avoid scanning excluded directories but to prevent the slow compile you need to turn off Real Time Protection.

      You can do that manually through Settings but you can also use Powershell commands as detailed here.
      Also here
      Rgds, Dave

      Comment


      • #4
        Jim,

        That is about a 1,000,000 lines per minute. My much smaller programs compile in under a 1/10th of second (larger error due to overhead) for about 10,000 lines per minute.

        So are you bragging, complaining, or just saying Defender is not causing you a problem? BTW I do not have any excluded directories and Defender does not affect compile time here.

        Mike,

        Wording?? Defender does not compile (that I know of), PB does. Also, what is a long time? (and number of lines?)

        Cheers,
        Dale

        Comment


        • #5
          Thanks Dave

          I just checked with Real Time Protection off. Only saved me 2 seconds. I haven't tried turning Windows Defender off.

          Dale, I am hoping for 1,000,000 lines per second for Christmas. Ha Ha

          BTW, we all knew what Mike meant to say.

          Comment


          • #6
            Dale,
            I posted the program, the link to the program and said 5-seconds.
            The program listview.bas is in the \pbwin10\samples\ddt\listview folder.

            Dave,
            I don't have to turn off real-time protection for big programs, but thanks for showing an easy way to do it.
            https://duckduckgo.com instead of google

            Comment


            • #7
              The code posted is reported by the IDE here as compiled at 32400 lines per minute, I have Defender and no special settings.
              Dale

              Comment


              • #8
                Thanks,
                It must be something on the 3 machines that I tested it on that is different?
                1 running windows 1809 and 2 others running windows 1803. Strange.
                https://duckduckgo.com instead of google

                Comment


                • #9
                  I don't pay for expensive components to have them wasted with junk AV scanners. I keep MalwareBytes for on demand scanning but do not run active AV detection. It comes at the price that you must be careful what you download and must have any risks turned off with your email. As far as incoming email, if you don't know who or what it is, delete it and save yourself the problem.
                  hutch at movsd dot com
                  The MASM Forum

                  www.masm32.com

                  Comment


                  • #10
                    Thanks, Steve.
                    I am taking your advise.
                    Might run real-time protection of Malwarebytes if surfing (paid version.)
                    Last edited by Mike Doty; 13 Dec 2018, 02:17 PM.
                    https://duckduckgo.com instead of google

                    Comment


                    • #11
                      Latest update,
                      After extracting all needed constants, subs, functions, interfaces, GUIDs, types, and unions from José includes, my 32+ second compiling 552,000 line app turned into a < 200,000 line app that takes 22 seconds to compile. All images (icons and bitmaps) are contained in a DLL so the final program size was 31 MB and now is 3.5 MB. There has to be something else that I'm missing.

                      Comment


                      • #12
                        All,
                        I'm starting to think it is a problem with some COM interfaces and active x controls that may be slowing the compile down. My xBot app is only 8 times smaller and really burns through the compile. It uses just 3 COM interfaces.

                        Primary source: C:\PBWin70\Samples\SDK\xBot\xBot_X01.bas {23208 total lines}
                        Target compilation: xBot.exe
                        Compile time: 0.1 seconds, at 27849600 lines/minute

                        Comment

                        Working...
                        X