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. pointer problem :)

pointer problem :)

Scheduled Pinned Locked Moved C / C++ / MFC
questionc++windows-admindata-structureshelp
4 Posts 3 Posters 1 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
    ajitatif angajetor
    wrote on last edited by
    #1

    hi everyone, i'm working on a project which includes a DLL and a separate UserBroker (both written in ATL) object which is used for getting/setting registry keys and reading/writing to user directories. (the object will be used in Vista, so this is needed) i want to read some binary data from registry and i have written this function properly: STDMETHODIMP CUserBroker::QueryBinaryValue(BSTR bstrKeyName, BSTR bstrValueName, BYTE **pValue, ULONG *pnBytes) the function body is simple. it just opens the registry key (using a CRegKey) and uses its QueryBinaryValue method. the problem is somehow i just can't pass a BYTE array to the other process (which calls the CUserBroker's method). the call to the method is this: arr = (BYTE *)malloc(1 * sizeof(BYTE)); pub->QueryBinaryValue(ATL::CComBSTR(s_bstrToolBarRegistryKey), ATL::CComBSTR("hop"), &arr, &dwSize); arr = (BYTE *)realloc(&arr[0], (dwSize) * sizeof(BYTE)); pub->QueryBinaryValue(ATL::CComBSTR(s_bstrToolBarRegistryKey), ATL::CComBSTR("hop"), &arr, &dwSize); delete arr; everything works fine until the first line of CUserBroker::QueryBinaryValue method, where the BYTE** pointer points to BadPtr (0x00000000) immediately. the question: how can i pass a BYTE array (or any other array) among processes?

    CPalliniC H A 3 Replies Last reply
    0
    • A ajitatif angajetor

      hi everyone, i'm working on a project which includes a DLL and a separate UserBroker (both written in ATL) object which is used for getting/setting registry keys and reading/writing to user directories. (the object will be used in Vista, so this is needed) i want to read some binary data from registry and i have written this function properly: STDMETHODIMP CUserBroker::QueryBinaryValue(BSTR bstrKeyName, BSTR bstrValueName, BYTE **pValue, ULONG *pnBytes) the function body is simple. it just opens the registry key (using a CRegKey) and uses its QueryBinaryValue method. the problem is somehow i just can't pass a BYTE array to the other process (which calls the CUserBroker's method). the call to the method is this: arr = (BYTE *)malloc(1 * sizeof(BYTE)); pub->QueryBinaryValue(ATL::CComBSTR(s_bstrToolBarRegistryKey), ATL::CComBSTR("hop"), &arr, &dwSize); arr = (BYTE *)realloc(&arr[0], (dwSize) * sizeof(BYTE)); pub->QueryBinaryValue(ATL::CComBSTR(s_bstrToolBarRegistryKey), ATL::CComBSTR("hop"), &arr, &dwSize); delete arr; everything works fine until the first line of CUserBroker::QueryBinaryValue method, where the BYTE** pointer points to BadPtr (0x00000000) immediately. the question: how can i pass a BYTE array (or any other array) among processes?

      CPalliniC Offline
      CPalliniC Offline
      CPallini
      wrote on last edited by
      #2

      HAve a look at this http://msdn.microsoft.com/msdnmag/issues/0900/DataTrans/[^]. :)

      If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.

      In testa che avete, signor di Ceprano?

      1 Reply Last reply
      0
      • A ajitatif angajetor

        hi everyone, i'm working on a project which includes a DLL and a separate UserBroker (both written in ATL) object which is used for getting/setting registry keys and reading/writing to user directories. (the object will be used in Vista, so this is needed) i want to read some binary data from registry and i have written this function properly: STDMETHODIMP CUserBroker::QueryBinaryValue(BSTR bstrKeyName, BSTR bstrValueName, BYTE **pValue, ULONG *pnBytes) the function body is simple. it just opens the registry key (using a CRegKey) and uses its QueryBinaryValue method. the problem is somehow i just can't pass a BYTE array to the other process (which calls the CUserBroker's method). the call to the method is this: arr = (BYTE *)malloc(1 * sizeof(BYTE)); pub->QueryBinaryValue(ATL::CComBSTR(s_bstrToolBarRegistryKey), ATL::CComBSTR("hop"), &arr, &dwSize); arr = (BYTE *)realloc(&arr[0], (dwSize) * sizeof(BYTE)); pub->QueryBinaryValue(ATL::CComBSTR(s_bstrToolBarRegistryKey), ATL::CComBSTR("hop"), &arr, &dwSize); delete arr; everything works fine until the first line of CUserBroker::QueryBinaryValue method, where the BYTE** pointer points to BadPtr (0x00000000) immediately. the question: how can i pass a BYTE array (or any other array) among processes?

        H Offline
        H Offline
        Hans Dietrich
        wrote on last edited by
        #3

        One way is to use WM_COPYDATA.

        Best wishes, Hans


        [CodeProject Forum Guidelines] [How To Ask A Question] [My Articles]

        1 Reply Last reply
        0
        • A ajitatif angajetor

          hi everyone, i'm working on a project which includes a DLL and a separate UserBroker (both written in ATL) object which is used for getting/setting registry keys and reading/writing to user directories. (the object will be used in Vista, so this is needed) i want to read some binary data from registry and i have written this function properly: STDMETHODIMP CUserBroker::QueryBinaryValue(BSTR bstrKeyName, BSTR bstrValueName, BYTE **pValue, ULONG *pnBytes) the function body is simple. it just opens the registry key (using a CRegKey) and uses its QueryBinaryValue method. the problem is somehow i just can't pass a BYTE array to the other process (which calls the CUserBroker's method). the call to the method is this: arr = (BYTE *)malloc(1 * sizeof(BYTE)); pub->QueryBinaryValue(ATL::CComBSTR(s_bstrToolBarRegistryKey), ATL::CComBSTR("hop"), &arr, &dwSize); arr = (BYTE *)realloc(&arr[0], (dwSize) * sizeof(BYTE)); pub->QueryBinaryValue(ATL::CComBSTR(s_bstrToolBarRegistryKey), ATL::CComBSTR("hop"), &arr, &dwSize); delete arr; everything works fine until the first line of CUserBroker::QueryBinaryValue method, where the BYTE** pointer points to BadPtr (0x00000000) immediately. the question: how can i pass a BYTE array (or any other array) among processes?

          A Offline
          A Offline
          ajitatif angajetor
          wrote on last edited by
          #4

          thanks, the article was really helpful. i used BSTR to pass the array safely among processes. i thought i needed some structure like BSTR for this, but couldn't imagine the solution would be BSTR itself :) WM_COPYDATA is useful too, but since my UserBroker does not have a window, i can't send the message to anywhere else. thanks again

          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