Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. ATL / WTL / STL
  4. windows Visual Studio C++/Visual Basic file locking

windows Visual Studio C++/Visual Basic file locking

Scheduled Pinned Locked Moved ATL / WTL / STL
csharpc++visual-studioquestion
4 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Alan Kurlansky
    wrote on last edited by
    #1

    What would be the best way to have a C++ program write(append) to a file and at the same time have a Visual basic program read sequentially all that's been written and when it reaches EOF wait for more? How would file/record locking be used to accomplish this?

    _ C C 3 Replies Last reply
    0
    • A Alan Kurlansky

      What would be the best way to have a C++ program write(append) to a file and at the same time have a Visual basic program read sequentially all that's been written and when it reaches EOF wait for more? How would file/record locking be used to accomplish this?

      _ Offline
      _ Offline
      _Superman_
      wrote on last edited by
      #2

      A named pipe would be a good candidate for this requirement. The C++ program can create and write to the pipe - CreateNamedPipe/WriteFile. The VB program can open and read from the pipe - CreateNamedPipe/ReadFile.

      «_Superman_»
      I love work. It gives me something to do between weekends.

      Microsoft MVP (Visual C++)

      Polymorphism in C

      1 Reply Last reply
      0
      • A Alan Kurlansky

        What would be the best way to have a C++ program write(append) to a file and at the same time have a Visual basic program read sequentially all that's been written and when it reaches EOF wait for more? How would file/record locking be used to accomplish this?

        C Offline
        C Offline
        Cool_Dev
        wrote on last edited by
        #3

        for your info only - memory mapped files is another option you can have, though its complex than using named pipes.
        Creating Named Shared Memory

        VB sample for Shared Memory Through Memory-Mapped Files

        1 Reply Last reply
        0
        • A Alan Kurlansky

          What would be the best way to have a C++ program write(append) to a file and at the same time have a Visual basic program read sequentially all that's been written and when it reaches EOF wait for more? How would file/record locking be used to accomplish this?

          C Offline
          C Offline
          cmk
          wrote on last edited by
          #4

          Options in increasing order of complexity/robustness: - Those mentioned, uncontrolled access by both apps/threads. - LockFileEx() / UnlockFileEx() - OS level read/write locking, critical if multiple threads will be appending. - Transactional NTFS - TxF API to perform transacted reads/writes, critical if multiple writes to different data sources (file, registry, database) may need to be rolled back and readers need consistant view across all.

          ...cmk The idea that I can be presented with a problem, set out to logically solve it with the tools at hand, and wind up with a program that could not be legally used because someone else followed the same logical steps some years ago and filed for a patent on it is horrifying. - John Carmack

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups