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. C / C++ / MFC
  4. Simple IPC / Functioncall in different address space

Simple IPC / Functioncall in different address space

Scheduled Pinned Locked Moved C / C++ / MFC
questionhelpc++htmldatabase
5 Posts 3 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.
  • N Offline
    N Offline
    nobaq
    wrote on last edited by
    #1

    Hello, I'm writing on a database application where the data is stored as HTML code (incl. images, JavaScripts and StyleSheets) in an SQlite database. The data is displayed in an MFC application with CHtmlView. I can't use dynamic document writing via OnBeforeNavigate2 because I need my images and scripts to be stored in the database too. So I have written a very simple "Asynchronous Pluggable Protocol" for this. I need to register this handler (a DLL) globally with regsvr32. But now I do not want to split my application logic into the exe and the DLL; instead, I want the whole application logic to reside in the MFC exe. Including the load procedure for a specific HTML page/images from the database. So my idea is: In my app, I navigate with CHtmlView to myapp://. Then my protocol handler is called. This DLL now requests the actual data from the running MFC application. The MFC app in turn loads the specific data from the SQLite database and passes the data back to the DLL. The big question now is: What is the simplest method (IPC) to request data (up to a few MB) from a running application? A great thing would be if the DLL could just call a defined function from the running exe like:

    void getContent(int pageID, char *buffer, int *len);

    or better:

    void GetContent(char *url, char *buffer, int *len);

    But I guess this is not easy. So I rely in IPC. But IPC is a very complex topic; I have no experience with it in Windows. Additionally, synchronization is a complicated issue too. How would you solve this problem? Is there a simple method that fits to my description? WM_COPYDATA would be possible but unfortunately the Pluggable Protocol does not have a message queue. And I also need to pass the URL to the application when requesting a specified content. Thank you for any hints! Niki

    C 1 Reply Last reply
    0
    • N nobaq

      Hello, I'm writing on a database application where the data is stored as HTML code (incl. images, JavaScripts and StyleSheets) in an SQlite database. The data is displayed in an MFC application with CHtmlView. I can't use dynamic document writing via OnBeforeNavigate2 because I need my images and scripts to be stored in the database too. So I have written a very simple "Asynchronous Pluggable Protocol" for this. I need to register this handler (a DLL) globally with regsvr32. But now I do not want to split my application logic into the exe and the DLL; instead, I want the whole application logic to reside in the MFC exe. Including the load procedure for a specific HTML page/images from the database. So my idea is: In my app, I navigate with CHtmlView to myapp://. Then my protocol handler is called. This DLL now requests the actual data from the running MFC application. The MFC app in turn loads the specific data from the SQLite database and passes the data back to the DLL. The big question now is: What is the simplest method (IPC) to request data (up to a few MB) from a running application? A great thing would be if the DLL could just call a defined function from the running exe like:

      void getContent(int pageID, char *buffer, int *len);

      or better:

      void GetContent(char *url, char *buffer, int *len);

      But I guess this is not easy. So I rely in IPC. But IPC is a very complex topic; I have no experience with it in Windows. Additionally, synchronization is a complicated issue too. How would you solve this problem? Is there a simple method that fits to my description? WM_COPYDATA would be possible but unfortunately the Pluggable Protocol does not have a message queue. And I also need to pass the URL to the application when requesting a specified content. Thank you for any hints! Niki

      C Offline
      C Offline
      Code o mat
      wrote on last edited by
      #2

      How about using sockets or pipes?

      > The problem with computers is that they do what you tell them to do and not what you want them to do. <

      N 1 Reply Last reply
      0
      • C Code o mat

        How about using sockets or pipes?

        > The problem with computers is that they do what you tell them to do and not what you want them to do. <

        N Offline
        N Offline
        nobaq
        wrote on last edited by
        #3

        Hi, The main problem is that I have no experience with these. But at first glance they seem to be too complicated. I need no Networking support, it should just go fast & simple. Sockets are really oversized for that. Problem with shared memory: I need complex caching structures and synchronization. I would seek for an IPC method that works very simple like a remote-process function call and which is blocking: I request something in my MFC app and get the answer directly; the DLL should be blocking while this process is done. I have experimented with WM_COPYDATA. But here I need to create a dummy window inside my DLL, send WM_COPYDATA to my MFC app to request the data and in turn send another WM_COPYDATA back to the DLL with the actual data. Too much complexity and oversize :( I also need to copy the data a few times. Named Pipes: I do not know them exactly but is this really simple for my case? How do I manage the server part in my MFC app? Do I need a separate thread for this? Does this work when there are requests done simultanely? Niki

        Richard Andrew x64R 1 Reply Last reply
        0
        • N nobaq

          Hi, The main problem is that I have no experience with these. But at first glance they seem to be too complicated. I need no Networking support, it should just go fast & simple. Sockets are really oversized for that. Problem with shared memory: I need complex caching structures and synchronization. I would seek for an IPC method that works very simple like a remote-process function call and which is blocking: I request something in my MFC app and get the answer directly; the DLL should be blocking while this process is done. I have experimented with WM_COPYDATA. But here I need to create a dummy window inside my DLL, send WM_COPYDATA to my MFC app to request the data and in turn send another WM_COPYDATA back to the DLL with the actual data. Too much complexity and oversize :( I also need to copy the data a few times. Named Pipes: I do not know them exactly but is this really simple for my case? How do I manage the server part in my MFC app? Do I need a separate thread for this? Does this work when there are requests done simultanely? Niki

          Richard Andrew x64R Offline
          Richard Andrew x64R Offline
          Richard Andrew x64
          wrote on last edited by
          #4

          Sure it can get complicated, but that's where you earn your money. Don't wimp out!

          N 1 Reply Last reply
          0
          • Richard Andrew x64R Richard Andrew x64

            Sure it can get complicated, but that's where you earn your money. Don't wimp out!

            N Offline
            N Offline
            nobaq
            wrote on last edited by
            #5

            I HAVE THE SOLUTION!!! The DLL is loaded into the same address space of my application!! So I can just use pointers in normal WM_USER messages and I do not need any IPC!! :) And the best thing: I do not need synchronizing; this is done automatically: I just send a WM_USER with SendMessage to my view window which reads the data from the database and passes a pointer to that data to the DLL. The good thing: SendMessage is blocking while this is done so I do not need to lock my database variables with critical sections. And if there is another request in parallel, it is spooled automatically by the windows messaging system and SendMessage is blocking again. Please correct me if I am wrong. Regards, Niki

            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