Announcement

Collapse

Forum Guidelines

This forum is for finished source code that is working properly. If you have questions about this or any other source code, please post it in one of the Discussion Forums, not here.
See more
See less

PB/DLL32: List all Open Files in Win95/98

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

    PB/DLL32: List all Open Files in Win95/98

    Code:
    ' List open files on Windows 95/98
    #COMPILE EXE
    #INCLUDE "WIN32API.INC"
     
    FUNCTION PBMAIN()
        DIM regs AS DIOC_REGISTERS
        DIM hVWin32 AS LONG
        DIM buf AS ASCIIZ * %MAX_PATH
        DIM cb AS LONG
        DIM i AS LONG
        DIM a AS STRING
     
        hVWin32 = CreateFile("\\.\vwin32", 0, 0, BYVAL %NULL, 0, %FILE_FLAG_DELETE_ON_CLOSE, %NULL)
        i = 0
        DO
            LSET regs = STRING$(SIZEOF(regs), 0)
            regs.regEBX = 3            ' Drive ID (A-1,B-2,C-3,...)
            regs.regEDX = VARPTR(buf)  ' File NAME
            regs.regECX = &H0486D      ' GET opened file
            regs.regEAX = &H0440D      ' IOCTL FOR block devices
            regs.regESI = i            ' Zero-based file ID
      
            CALL DeviceIoControl(hVWin32, %VWIN32_DIOC_DOS_IOCTL, regs, SIZEOF(regs), regs, SIZEOF(regs), cb, BYVAL %NULL)
      
            IF (regs.regFlags AND &H01) THEN EXIT LOOP
            a = a & TRIM$(buf) & $CRLF
            INCR i
        LOOP
     
        IF i THEN
            OPEN "OPENFILE.DAT" FOR OUTPUT AS #1
            PRINT #1, a
            CLOSE #1
            MessageBox GetFocus(), "Success!" & $CRLF & FORMAT$(i) & " open files enumerated", "EnumFiles(Win9x)", %MB_ICONINFORMATION
        END IF
    END FUNCTION
    Lance
    PowerBASIC Support

    Lance
    mailto:[email protected]

    #2
    Hi Lance,

    I've got a function which pretty much does what this one does. I works fine in Win95/98, but the OpenVWin32() function returns %INVALID_HANDLE_VALUE when I try and run it under Windows 2000.

    Do you know of a work-around for this at all?

    I haven't tried it under NT, but I guess I'll get the same results - shame when my project's primary platform is NT!

    Thanks in advance,

    Dorian.


    ------------------

    Comment


      #3
      The code is not NT compatible, sorry.

      Please post questions in the appropriate forum... the Source Code forum is not the correct place for discussions. Thanks!

      ------------------
      Lance
      PowerBASIC Support
      mailto:[email protected][email protected]</A>
      Lance
      mailto:[email protected]

      Comment

      Working...
      X
      😀
      🥰
      🤢
      😎
      😡
      👍
      👎