12 #include "shell32_main.h"
13 #include "undocshell.h"
14 #include "wine/unicode.h"
15 #include "debugtools.h"
17 DEFAULT_DEBUG_CHANNEL(shell);
19 /************************* STRRET functions ****************************/
21 /*************************************************************************
22 * StrRetToStrN [SHELL32.96]
24 * converts a STRRET to a normal string
27 * the pidl is for STRRET OFFSET
30 * This routine is identical to StrRetToBufA in dlls/shlwapi/string.c.
31 * It was duplicated here because not every version of Shlwapi.dll exports
32 * StrRetToBufA. If you change one routine, change them both. YOU HAVE BEEN
36 HRESULT WINAPI StrRetToStrNA (LPVOID dest, DWORD len, LPSTRRET src, const ITEMIDLIST *pidl)
38 TRACE("dest=0x%p len=0x%lx strret=0x%p pidl=%p stub\n",dest,len,src,pidl);
43 WideCharToMultiByte(CP_ACP, 0, src->u.pOleStr, -1, (LPSTR)dest, len, NULL, NULL);
44 /* SHFree(src->u.pOleStr); FIXME: is this right? */
48 lstrcpynA((LPSTR)dest, src->u.cStr, len);
52 lstrcpynA((LPSTR)dest, ((LPCSTR)&pidl->mkid)+src->u.uOffset, len);
56 FIXME("unknown type!\n");
66 /*************************************************************************
67 * StrRetToStrNW [SHELL32.96]
69 * converts a STRRET to a normal string
72 * the pidl is for STRRET OFFSET
75 * This routine is identical to StrRetToBufW in dlls/shlwapi/string.c.
76 * It was duplicated here because not every version of Shlwapi.dll exports
77 * StrRetToBufW. If you change one routine, change them both. YOU HAVE BEEN
82 HRESULT WINAPI StrRetToStrNW (LPVOID dest1, DWORD len, LPSTRRET src, const ITEMIDLIST *pidl)
84 LPWSTR dest = (LPWSTR) dest1;
85 TRACE("dest=0x%p len=0x%lx strret=0x%p pidl=%p stub\n",dest,len,src,pidl);
90 lstrcpynW((LPWSTR)dest, src->u.pOleStr, len);
91 /* SHFree(src->u.pOleStr); FIXME: is this right? */
95 if (!MultiByteToWideChar( CP_ACP, 0, src->u.cStr, -1, dest, len ) && len)
102 if (!MultiByteToWideChar( CP_ACP, 0, ((LPCSTR)&pidl->mkid)+src->u.uOffset, -1,
109 FIXME("unknown type!\n");
111 { *(LPSTR)dest = '\0';
118 /*************************************************************************/
120 HRESULT WINAPI StrRetToStrNAW (LPVOID dest, DWORD len, LPSTRRET src, const ITEMIDLIST *pidl)
122 if(SHELL_OsIsUnicode())
123 return StrRetToStrNW (dest, len, src, pidl);
124 return StrRetToStrNA (dest, len, src, pidl);
127 /************************* OLESTR functions ****************************/
129 /************************************************************************
130 * StrToOleStr [SHELL32.163]
133 int WINAPI StrToOleStrA (LPWSTR lpWideCharStr, LPCSTR lpMultiByteString)
135 TRACE("(%p, %p %s)\n",
136 lpWideCharStr, lpMultiByteString, debugstr_a(lpMultiByteString));
138 return MultiByteToWideChar(0, 0, lpMultiByteString, -1, lpWideCharStr, MAX_PATH);
141 int WINAPI StrToOleStrW (LPWSTR lpWideCharStr, LPCWSTR lpWString)
143 TRACE("(%p, %p %s)\n",
144 lpWideCharStr, lpWString, debugstr_w(lpWString));
146 strcpyW (lpWideCharStr, lpWString );
147 return strlenW(lpWideCharStr);
150 BOOL WINAPI StrToOleStrAW (LPWSTR lpWideCharStr, LPCVOID lpString)
152 if (SHELL_OsIsUnicode())
153 return StrToOleStrW (lpWideCharStr, lpString);
154 return StrToOleStrA (lpWideCharStr, lpString);
157 /*************************************************************************
158 * StrToOleStrN [SHELL32.79]
159 * lpMulti, nMulti, nWide [IN]
162 BOOL WINAPI StrToOleStrNA (LPWSTR lpWide, INT nWide, LPCSTR lpStrA, INT nStr)
164 TRACE("(%p, %x, %s, %x)\n", lpWide, nWide, debugstr_an(lpStrA,nStr), nStr);
165 return MultiByteToWideChar (0, 0, lpStrA, nStr, lpWide, nWide);
167 BOOL WINAPI StrToOleStrNW (LPWSTR lpWide, INT nWide, LPCWSTR lpStrW, INT nStr)
169 TRACE("(%p, %x, %s, %x)\n", lpWide, nWide, debugstr_wn(lpStrW, nStr), nStr);
171 if (lstrcpynW (lpWide, lpStrW, nWide))
172 { return lstrlenW (lpWide);
177 BOOL WINAPI StrToOleStrNAW (LPWSTR lpWide, INT nWide, LPCVOID lpStr, INT nStr)
179 if (SHELL_OsIsUnicode())
180 return StrToOleStrNW (lpWide, nWide, lpStr, nStr);
181 return StrToOleStrNA (lpWide, nWide, lpStr, nStr);
184 /*************************************************************************
185 * OleStrToStrN [SHELL32.78]
187 BOOL WINAPI OleStrToStrNA (LPSTR lpStr, INT nStr, LPCWSTR lpOle, INT nOle)
189 TRACE("(%p, %x, %s, %x)\n", lpStr, nStr, debugstr_wn(lpOle,nOle), nOle);
190 return WideCharToMultiByte (0, 0, lpOle, nOle, lpStr, nStr, NULL, NULL);
193 BOOL WINAPI OleStrToStrNW (LPWSTR lpwStr, INT nwStr, LPCWSTR lpOle, INT nOle)
195 TRACE("(%p, %x, %s, %x)\n", lpwStr, nwStr, debugstr_wn(lpOle,nOle), nOle);
197 if (lstrcpynW ( lpwStr, lpOle, nwStr))
198 { return lstrlenW (lpwStr);
203 BOOL WINAPI OleStrToStrNAW (LPVOID lpOut, INT nOut, LPCVOID lpIn, INT nIn)
205 if (SHELL_OsIsUnicode())
206 return OleStrToStrNW (lpOut, nOut, lpIn, nIn);
207 return OleStrToStrNA (lpOut, nOut, lpIn, nIn);