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. COM
  4. Newbie - Memory sharing in COM

Newbie - Memory sharing in COM

Scheduled Pinned Locked Moved COM
questioncomsysadminperformancehelp
6 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.
  • J Offline
    J Offline
    jayart
    wrote on last edited by
    #1

    Hi, I have a doubt regarding memory sharing in a COM object. Background: Recently we shifted to VS2005. Hence the dll written in VC6 is no longer directly useful. I might have to write a COM wrapper to access this dll. The application would be working with huge files and I want only a single copy maintained across my application. The dll should actually read the file and after the error checking send the a pointer of the memory to my application. My question: 1) Is it possible to do it with COM? 2) What would happen if my COM object memory is on a remote server? 3) Does the COM object copy the memory and send it to the requested application or does it just pass the reference. My intention is to maintain a single place of memory where the file data would be read and used. Please let me know how can I achieve this through COM. Any links would be useful. Regards, Arti Gujare

    L 1 Reply Last reply
    0
    • J jayart

      Hi, I have a doubt regarding memory sharing in a COM object. Background: Recently we shifted to VS2005. Hence the dll written in VC6 is no longer directly useful. I might have to write a COM wrapper to access this dll. The application would be working with huge files and I want only a single copy maintained across my application. The dll should actually read the file and after the error checking send the a pointer of the memory to my application. My question: 1) Is it possible to do it with COM? 2) What would happen if my COM object memory is on a remote server? 3) Does the COM object copy the memory and send it to the requested application or does it just pass the reference. My intention is to maintain a single place of memory where the file data would be read and used. Please let me know how can I achieve this through COM. Any links would be useful. Regards, Arti Gujare

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      ArtiGujare wrote:

      Recently we shifted to VS2005.

      I believe you meant "it's managed code now"

      ArtiGujare wrote:

      Recently we shifted to VS2005. Hence the dll written in VC6 is no longer directly useful. I might have to write a COM wrapper to access this dll

      Do you really need COm wrapper or P/Invoke helps ? http://www.google.co.in/search?hl=en&q=P%2FInvoke&btnG=Search&meta=[^]

      S o h a i l K a d i w a l a
      To Err Is Human; to Debug, Divine

      J 1 Reply Last reply
      0
      • L Lost User

        ArtiGujare wrote:

        Recently we shifted to VS2005.

        I believe you meant "it's managed code now"

        ArtiGujare wrote:

        Recently we shifted to VS2005. Hence the dll written in VC6 is no longer directly useful. I might have to write a COM wrapper to access this dll

        Do you really need COm wrapper or P/Invoke helps ? http://www.google.co.in/search?hl=en&q=P%2FInvoke&btnG=Search&meta=[^]

        S o h a i l K a d i w a l a
        To Err Is Human; to Debug, Divine

        J Offline
        J Offline
        jayart
        wrote on last edited by
        #3

        Thankyou Sohail. I am a newbie to COM. When I said we shifted to VS2005 I meant that the application using the dll was previosly written in VC6 and dll too was written in VC6. Now the application has to be written in VS2005 and still use the VC6 dll. My typical use case is: 1) Application send the file name to the dll. 2) dll reads the file at that mentioned filepath and does some file checks 3) if the file is in expected format, the dll returns the pointer pointing to the file data to the applictaion. Can I achieve this using P/Invoke? Regards, Arti Gujare

        L T 2 Replies Last reply
        0
        • J jayart

          Thankyou Sohail. I am a newbie to COM. When I said we shifted to VS2005 I meant that the application using the dll was previosly written in VC6 and dll too was written in VC6. Now the application has to be written in VS2005 and still use the VC6 dll. My typical use case is: 1) Application send the file name to the dll. 2) dll reads the file at that mentioned filepath and does some file checks 3) if the file is in expected format, the dll returns the pointer pointing to the file data to the applictaion. Can I achieve this using P/Invoke? Regards, Arti Gujare

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          P/Invoke is a way of invoking unmanaged code from within .NET (a rough description, for more and precise detials see MSDN :) ) If the code you have ported to VS 2005 is still unmanaged code then I don't see any reason why it's not working with your old VC6 DLL. If your application when written in VS2005, is ported and made to be .NET complaint then please read on topics related to 'how to call unmanaged code/dll from within managed code' this will lead you to P/Invoke somewhere http://en.wikipedia.org/wiki/P/invoke[^] http://msdn.microsoft.com/msdnmag/issues/03/07/NET/[^] http://msdn2.microsoft.com/en-us/library/aa446536.aspx[^] Please read about P/Invoke basic and you will be able to decide based on your project needs what to use - P/Invoke or a COM wrapper I hope this helps.

          S o h a i l K a d i w a l a
          To Err Is Human; to Debug, Divine

          1 Reply Last reply
          0
          • J jayart

            Thankyou Sohail. I am a newbie to COM. When I said we shifted to VS2005 I meant that the application using the dll was previosly written in VC6 and dll too was written in VC6. Now the application has to be written in VS2005 and still use the VC6 dll. My typical use case is: 1) Application send the file name to the dll. 2) dll reads the file at that mentioned filepath and does some file checks 3) if the file is in expected format, the dll returns the pointer pointing to the file data to the applictaion. Can I achieve this using P/Invoke? Regards, Arti Gujare

            T Offline
            T Offline
            Tim Paaschen
            wrote on last edited by
            #5

            VS2005 provides several programming languages. I assume that you continue to use C++. In this case you can just use your unmanaged DLL (written in VC6) as you have done before. It's your choice to make the application managed or unmanaged. If you make the application managed (C++/CLI), you may have to take special care when you are marshalling data (e.g. pointers or strings) from your unmanaged code to the managed one. P/Invoke will only be required, if you you change the programming language for your application to a pure managed language, e.g. C#. If you are doing this, I recommend to have a look at http://pinvoke.net/.

            Regards, Tim

            G 1 Reply Last reply
            0
            • T Tim Paaschen

              VS2005 provides several programming languages. I assume that you continue to use C++. In this case you can just use your unmanaged DLL (written in VC6) as you have done before. It's your choice to make the application managed or unmanaged. If you make the application managed (C++/CLI), you may have to take special care when you are marshalling data (e.g. pointers or strings) from your unmanaged code to the managed one. P/Invoke will only be required, if you you change the programming language for your application to a pure managed language, e.g. C#. If you are doing this, I recommend to have a look at http://pinvoke.net/.

              Regards, Tim

              G Offline
              G Offline
              guestcat
              wrote on last edited by
              #6

              Hi, i can suggest a simple solution for the problem. you can check the value returned from your dll and open the file using .net classes.

              ^-^ @|@ - redCat

              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