pointer problem :)
-
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 aCRegKey
) and uses itsQueryBinaryValue
method. the problem is somehow i just can't pass aBYTE
array to the other process (which calls theCUserBroker
'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 ofCUserBroker::QueryBinaryValue
method, where theBYTE**
pointer points toBadPtr (0x00000000)
immediately. the question: how can i pass aBYTE
array (or any other array) among processes? -
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 aCRegKey
) and uses itsQueryBinaryValue
method. the problem is somehow i just can't pass aBYTE
array to the other process (which calls theCUserBroker
'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 ofCUserBroker::QueryBinaryValue
method, where theBYTE**
pointer points toBadPtr (0x00000000)
immediately. the question: how can i pass aBYTE
array (or any other array) among processes?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.
-
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 aCRegKey
) and uses itsQueryBinaryValue
method. the problem is somehow i just can't pass aBYTE
array to the other process (which calls theCUserBroker
'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 ofCUserBroker::QueryBinaryValue
method, where theBYTE**
pointer points toBadPtr (0x00000000)
immediately. the question: how can i pass aBYTE
array (or any other array) among processes?One way is to use WM_COPYDATA.
Best wishes, Hans
[CodeProject Forum Guidelines] [How To Ask A Question] [My Articles]
-
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 aCRegKey
) and uses itsQueryBinaryValue
method. the problem is somehow i just can't pass aBYTE
array to the other process (which calls theCUserBroker
'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 ofCUserBroker::QueryBinaryValue
method, where theBYTE**
pointer points toBadPtr (0x00000000)
immediately. the question: how can i pass aBYTE
array (or any other array) among processes?thanks, the article was really helpful. i used
BSTR
to pass the array safely among processes. i thought i needed some structure likeBSTR
for this, but couldn't imagine the solution would beBSTR
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