CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 2010
    Posts
    1

    Question Lock And Unlock multiple Directories

    Hi friends i need your help, please! im trying to lock and unlock multiple directories (folders) (im creating a folder lock), I can block many folders but only unlock one, when trying to unlock another one vb6 tells me: err 75. I understand that this happens because it's saving or creating the file in only one registry location and need store in a Collection list, but i dont know how (i have no idea). I use this code:

    Private Const FILE_LIST_DIRECTORY = &H1
    Private Const FILE_SHARE_READ = &H1&
    Private Const FILE_SHARE_DELETE = &H4&
    Private Const OPEN_EXISTING = 3
    Private Const FILE_FLAG_BACKUP_SEMANTICS = &H2000000
    Private Declare Function CreateFile Lib "kernel32" Alias "CreateFileA" (ByVal lpFileName As String, ByVal dwDesiredAccess As Long, ByVal dwShareMode As Long, ByVal PassZero As Long, ByVal dwCreationDisposition As Long, ByVal dwFlagsAndAttributes As Long, ByVal PassZero As Long) As Long
    Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long

    Dim File_Share_Flag As Long
    Dim hDir As Long


    Private Sub mnublock_Click()

    'Block code
    Dim PathDir As String
    PathDir = itemData + Ext
    hDir = CreateFile(PathDir, FILE_LIST_DIRECTORY, File_Share_Flag, _
    ByVal 0&, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, ByVal 0&)

    End Sub


    Private Sub mnuUnblock_Click()
    'Unblock code
    CloseHandle hDir
    End Sub

    * Note: itemData read a .ini file, the .ini values are set in a Listbox, some like this:

    itemData = ReadINI("My files protected", "File" & CStr(Counter), iniPath & "data.ini")


    The problem is when try unlock all the previous locked folders, only one can be unlocked
    thanks a lot for the help And sorry for my poor English

  2. #2
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: Lock And Unlock multiple Directories

    Convert the FILE LIST and process one at a time. Unless the * flag will work
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured