|
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?
|
|
|
|
|
|
|
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
|
|
|
|
|
how to get the VARIANT type URL as a CString from OnDocumentComplete in webbrowser2
void MyDialog::OnDocumentCompleteExplorer1(LPDISPATCH pDisp, VARIANT FAR* URL) <br />
{<br />
<br />
}
"URL" here contains the url that has been completed. but it is a variant type. i want to as a CString type so that i can check it. i tried casting but it doesnt work. does anyone knows how to do it?
- MFC style
- winxp
- vc6.0
thanks in advance!
|
|
|
|
|
you can use the V_BSTR macro to get it done. the macro returns a BSTR that you can use to obtain a CString . something like this may help/work:
BSTR bstrUrl = V_BSTR(URL);
CString cstrUrl(bstrUrl);
|
|
|
|
|
awah wrote: "URL" here contains the url that has been completed. but it is a variant type.
A variant type has many different subtypes, one of which is a BSTR. For example:
COleVariant vtURL(URL, VT_BSTRT);
CString strURL = V_BSTRT(&vtURL); Or:
CString strURL(V_BSTR(URL));
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
|
Hello all,
I was wondering if I can use the new CString class that came with VC++2005 but in VC++6...
If this is possible, how should it be done?
As always thank you in advance...
|
|
|
|
|
Joan Murt wrote: I was wondering if I can use the new CString class that came with VC++2005 but in VC++6...
If this is possible, how should it be done?
No, but you could possibly derive your own class from CString , and add methods to it that are similar to those in the VS2005 version.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Just curious - what new features do you want to use?
|
|
|
|
|
CString.tokenize...
I wanted to use that and not a custom made tokenizer...
I'm sure that there are plenty of them here in CP, but well, I have an old app that deserve a little of maintenance... and I've got used to use that tokenizer...
|
|
|
|
|
You can use AfxExtractSubString() in VC6
|
|
|
|
|
Thank you, I'll give it a try...
|
|
|
|
|
Hi....
I want to create dsn at runtime using mfc..
Is there any solution
plz help me!!!!!!
Thanks in advance
|
|
|
|
|
I don't think we can do this.
Note : Please give detail which type of DSN you want to create at run time.
I think u will be aware about System DSN,User DSN,File DSN
Regard's
Kaushik
|
|
|
|
|
I want to use System DSN..
|
|
|
|
|
Use SQLConfigDataSource()
Manish Rastogi
|
|
|
|
|
Hi
I use SQLConfigDataSource() API but it create User DSN & i want to create System DSN so plz help me.....
|
|
|
|
|
Thanks it has been done.............
|
|
|
|
|
But i have to done using Sql database so can it done using same API?
|
|
|
|
|
A DSN does not know/care about the underlying DBMS. The third argument is where you specify the type, and the fourth argument contains the details of that type.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
The third argument is "Microsoft Access Driver (*.mdb)" then what should changes are required?
|
|
|
|
|
I wrote :
SQLConfigDataSource(NULL,ODBC_ADD_SYS_DSN,"Microsoft SQL Driver (*.sql)\0",(LPCSTR)szDesc))
sprintf(szDesc,"DSN=%s: DESCRIPTION=TOC support source: DBQ=%s: FIL=MicrosoftSQL: DEFAULTDIR=D:\\Database:: ","TestDB","root@localhost\\dtest.sql")
but it gives error so plzzzzzzzzz help me what should i changes?
|
|
|
|
|
meenakhisjoshi wrote: SQLConfigDataSource(NULL,ODBC_ADD_SYS_DSN,"Microsoft SQL Driver (*.sql)\0",(LPCSTR)szDesc))
Why the extra \0 character? This statement is missing a semicolon.
meenakhisjoshi wrote: sprintf(szDesc,"DSN=%s: DESCRIPTION=TOC support source: DBQ=%s: FIL=MicrosoftSQL: DEFAULTDIR=D:\\Database:: ","TestDB","root@localhost\\dtest.sql")
If you are using MFC, why not use a CString object rather than mess with sprintf() ? This statement is also missing a semicolon.
meenakhisjoshi wrote: but it gives error...
And that error would be?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|