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. Interprocess cmm, using shared DLL

Interprocess cmm, using shared DLL

Scheduled Pinned Locked Moved C / C++ / MFC
question
7 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.
  • A Offline
    A Offline
    Anders Gustafsson
    wrote on last edited by
    #1

    Hi! I have an app that uses Crystal Reports for reports. Some functions cannot be easily realised in crystal, so I thought about calling my main app for that work. Now, I can add custom fn's to Crystal, by writing a U25 DLL. The idea I tested was to have a function in this DLL that gets called from my main app and there deposits, in shared storage, the addresses I need to call to get my data. When the DLL gets loaded from Crystal, then it calls my app through those pointers. I have tested it and it works, but I have been told in is a bad idea. Suggestions?

    M K 2 Replies Last reply
    0
    • A Anders Gustafsson

      Hi! I have an app that uses Crystal Reports for reports. Some functions cannot be easily realised in crystal, so I thought about calling my main app for that work. Now, I can add custom fn's to Crystal, by writing a U25 DLL. The idea I tested was to have a function in this DLL that gets called from my main app and there deposits, in shared storage, the addresses I need to call to get my data. When the DLL gets loaded from Crystal, then it calls my app through those pointers. I have tested it and it works, but I have been told in is a bad idea. Suggestions?

      M Offline
      M Offline
      Matthew Faithfull
      wrote on last edited by
      #2

      As a general rule this sort of thing is considered unsafe and using Sockets or COM IPC from your Dll would be preferred as more robust and flexible than rolling your own solution in shared memory. I have used COM Connection Points in the past to communicate between a Dll loaded into the Microsoft Management Console and an external process. Not easy but it worked and was pleasingly fast.

      Nothing is exactly what it seems but everything with seems can be unpicked.

      A 1 Reply Last reply
      0
      • M Matthew Faithfull

        As a general rule this sort of thing is considered unsafe and using Sockets or COM IPC from your Dll would be preferred as more robust and flexible than rolling your own solution in shared memory. I have used COM Connection Points in the past to communicate between a Dll loaded into the Microsoft Management Console and an external process. Not easy but it worked and was pleasingly fast.

        Nothing is exactly what it seems but everything with seems can be unpicked.

        A Offline
        A Offline
        Anders Gustafsson
        wrote on last edited by
        #3

        OK. Not sure what to do at this point. Implementing COM for this seems an awful lot of work for such a simple task. Any good pointers where to get started?

        M 1 Reply Last reply
        0
        • A Anders Gustafsson

          Hi! I have an app that uses Crystal Reports for reports. Some functions cannot be easily realised in crystal, so I thought about calling my main app for that work. Now, I can add custom fn's to Crystal, by writing a U25 DLL. The idea I tested was to have a function in this DLL that gets called from my main app and there deposits, in shared storage, the addresses I need to call to get my data. When the DLL gets loaded from Crystal, then it calls my app through those pointers. I have tested it and it works, but I have been told in is a bad idea. Suggestions?

          K Offline
          K Offline
          KarstenK
          wrote on last edited by
          #4

          It is better that the dll has its own data, and the dll makes it own copies of the data. Preprocess the data in the App and THAN call the dll to finish the job. Try to develop a data model which is clearly structered!! A clear structure helps you to develop good code and debug it easy. Ask a friend/colegue for a half hour to discuss it. This is really worth it.:cool:

          Greetings from Germany

          A 1 Reply Last reply
          0
          • K KarstenK

            It is better that the dll has its own data, and the dll makes it own copies of the data. Preprocess the data in the App and THAN call the dll to finish the job. Try to develop a data model which is clearly structered!! A clear structure helps you to develop good code and debug it easy. Ask a friend/colegue for a half hour to discuss it. This is really worth it.:cool:

            Greetings from Germany

            A Offline
            A Offline
            Anders Gustafsson
            wrote on last edited by
            #5

            I am discussing it, here ;) Problem is that there are aspects of the data model that I cannot control since I do not have access to the Crystal Reports sources. The crystal reports viewer is for all intents and purposes a black box. Only way to extend it is to create a custom DLL that gets registered with Crystal and called at runtime. So, preprocessing in the app is really what I do, let me elaborate. The functions I need are along the lines of "workdays", input in the report is two dates. The result is not just a range, but it must take into account the employee-specific calendar. Alternatively could I duplicate this logic in the DLL, but then again would I have to have a separate Db connection (with a separate login) for the report. So when I call "Arbetsdagar(date,date) from within my crystal report definition, crystal calls the DLL and it is just a wrapper that calls the real function in the app.

            1 Reply Last reply
            0
            • A Anders Gustafsson

              OK. Not sure what to do at this point. Implementing COM for this seems an awful lot of work for such a simple task. Any good pointers where to get started?

              M Offline
              M Offline
              Matthew Faithfull
              wrote on last edited by
              #6

              That's going to depend a lot on what you know and what your requirements are. On one hand if it works leave it be. On the other it does sound like a temporary solution so perhaps try some separate experiments with COM, ATL makes this easy, to see if you can find a replacement architecture that you're happy with. If you want to avoid COM give Socket comms a try, there's loads of examples available. This has the added advantage that you can transparently run your application on the same or a separate machine. Either way CP is probably going to be the best place to find examples. If you've managed to write your own shared memory exchange system that works you'll have nothing to fear from either of these approaches and probably don't need advice from me.:)

              Nothing is exactly what it seems but everything with seems can be unpicked.

              A 1 Reply Last reply
              0
              • M Matthew Faithfull

                That's going to depend a lot on what you know and what your requirements are. On one hand if it works leave it be. On the other it does sound like a temporary solution so perhaps try some separate experiments with COM, ATL makes this easy, to see if you can find a replacement architecture that you're happy with. If you want to avoid COM give Socket comms a try, there's loads of examples available. This has the added advantage that you can transparently run your application on the same or a separate machine. Either way CP is probably going to be the best place to find examples. If you've managed to write your own shared memory exchange system that works you'll have nothing to fear from either of these approaches and probably don't need advice from me.:)

                Nothing is exactly what it seems but everything with seems can be unpicked.

                A Offline
                A Offline
                Anders Gustafsson
                wrote on last edited by
                #7

                Well, it is a commercial app, so I'd rather not do anything dangerous ;) I have been banging my head against the limitations of Crystal Reports for the last 10 years ;) And we do some pretty cool stuff, manipulating the innards of the reports ar runtime, using the CR apis. The New CR apis are all COM anyway so I had to learn those. I found a good, two-part article on COM here and I am currently reading it. It might be that implementing a small COM server in my app might be worth the peace of mind here. App and report will always be on the same machine so.. Also, COM feels quite logical as it is just a (synchronous) function call.

                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