LPCOLESTR?
-
I would like to use the function IDataInitialize::LoadStringFromStorage that takes LPCOLESTR as parameters. The first parameters is a udl file and I have that file in a char*. How to past from my char* to the LPCOLESTR? The second parameter is a LPCOLESTR* how can I get that back to char*? Thanks.
-
I would like to use the function IDataInitialize::LoadStringFromStorage that takes LPCOLESTR as parameters. The first parameters is a udl file and I have that file in a char*. How to past from my char* to the LPCOLESTR? The second parameter is a LPCOLESTR* how can I get that back to char*? Thanks.
Hi! You can use the A2OLE macro to convert the char* string to LPCOLESTR. To get the string back you have to specify the valid pointer to LPCOLESTR and then you can convert the result Unicode string to char*. I don't know who is responsible for allocating memory for the result, so if you have to do that you can create an array of WCHARs. You can find more information about the "String Conversion Macro" in the MSDN. Regards, Alex Gorev, Dundas Software.
-
I would like to use the function IDataInitialize::LoadStringFromStorage that takes LPCOLESTR as parameters. The first parameters is a udl file and I have that file in a char*. How to past from my char* to the LPCOLESTR? The second parameter is a LPCOLESTR* how can I get that back to char*? Thanks.
Hi, Use AnsiToUnicode( ) & UnicodeToAnsi() here are two examples OPENFILENAME ofn; LPOLESTR pszFileNameW; LPMONIKER pmk; .. ...... // Get file name from OpenFile Common Dialog. The ANSI file name will // be placed in ofn.lpstrFile GetOpenFileName(&ofn); .. ...... AnsiToUnicode(ofn.lpstrFile, &pszFileNameW); CreateFileMoniker(pszFileNameW, &pmk); CoTaskMemFree(pszFileNameW); .. ...... COleInPlaceFrame::SetStatusText(LPCOLESTR pszStatusTextW) { LPSTR pszStatusTextA; UnicodeToAnsi(pszStatusTextW, &pszStatusTextA); SetWindowText(m_hwndStatus, pszStatusTextA); CoTaskMemFree(pszStatusTextA); } See Also OLE2CT() Hope That will help Ghazi