2000-06-02 01:25:44 +02:00
|
|
|
#include <string.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <ctype.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
#include "winnls.h"
|
|
|
|
#include "winerror.h"
|
2001-11-06 23:31:19 +01:00
|
|
|
#include "winreg.h"
|
2000-06-02 01:25:44 +02:00
|
|
|
|
2000-09-26 02:00:55 +02:00
|
|
|
#include "shlobj.h"
|
2000-06-02 01:25:44 +02:00
|
|
|
#include "shellapi.h"
|
2000-08-14 16:35:01 +02:00
|
|
|
#include "shell32_main.h"
|
2001-08-16 20:49:56 +02:00
|
|
|
#include "undocshell.h"
|
2000-06-13 03:10:29 +02:00
|
|
|
#include "wine/unicode.h"
|
2001-11-06 23:31:19 +01:00
|
|
|
#include "debugtools.h"
|
2000-06-02 01:25:44 +02:00
|
|
|
|
|
|
|
DEFAULT_DEBUG_CHANNEL(shell);
|
|
|
|
|
|
|
|
/************************* STRRET functions ****************************/
|
|
|
|
|
2002-01-18 19:57:43 +01:00
|
|
|
/*
|
2001-11-06 00:55:36 +01:00
|
|
|
* ***** NOTE *****
|
2002-01-18 19:57:43 +01:00
|
|
|
* These routines are identical to StrRetToBuf[AW] in dlls/shlwapi/string.c.
|
|
|
|
* They were duplicated here because not every version of Shlwapi.dll exports
|
|
|
|
* StrRetToBuf[AW]. If you change one routine, change them both. YOU HAVE BEEN
|
2001-11-06 00:55:36 +01:00
|
|
|
* WARNED.
|
|
|
|
* ***** NOTE *****
|
2000-06-02 01:25:44 +02:00
|
|
|
*/
|
2002-01-18 19:57:43 +01:00
|
|
|
|
2000-09-26 02:00:55 +02:00
|
|
|
HRESULT WINAPI StrRetToStrNA (LPVOID dest, DWORD len, LPSTRRET src, const ITEMIDLIST *pidl)
|
2000-06-02 01:25:44 +02:00
|
|
|
{
|
2001-09-07 17:24:25 +02:00
|
|
|
TRACE("dest=0x%p len=0x%lx strret=0x%p pidl=%p stub\n",dest,len,src,pidl);
|
|
|
|
|
|
|
|
switch (src->uType)
|
|
|
|
{
|
|
|
|
case STRRET_WSTR:
|
|
|
|
WideCharToMultiByte(CP_ACP, 0, src->u.pOleStr, -1, (LPSTR)dest, len, NULL, NULL);
|
|
|
|
/* SHFree(src->u.pOleStr); FIXME: is this right? */
|
|
|
|
break;
|
|
|
|
|
|
|
|
case STRRET_CSTRA:
|
|
|
|
lstrcpynA((LPSTR)dest, src->u.cStr, len);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case STRRET_OFFSETA:
|
|
|
|
lstrcpynA((LPSTR)dest, ((LPCSTR)&pidl->mkid)+src->u.uOffset, len);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
FIXME("unknown type!\n");
|
|
|
|
if (len)
|
|
|
|
{
|
|
|
|
*(LPSTR)dest = '\0';
|
|
|
|
}
|
|
|
|
return(FALSE);
|
|
|
|
}
|
|
|
|
return S_OK;
|
2000-06-02 01:25:44 +02:00
|
|
|
}
|
|
|
|
|
2002-01-18 19:57:43 +01:00
|
|
|
/************************************************************************/
|
2001-09-11 01:16:31 +02:00
|
|
|
|
2001-09-07 17:24:25 +02:00
|
|
|
HRESULT WINAPI StrRetToStrNW (LPVOID dest1, DWORD len, LPSTRRET src, const ITEMIDLIST *pidl)
|
2000-06-02 01:25:44 +02:00
|
|
|
{
|
2001-09-07 17:24:25 +02:00
|
|
|
LPWSTR dest = (LPWSTR) dest1;
|
|
|
|
TRACE("dest=0x%p len=0x%lx strret=0x%p pidl=%p stub\n",dest,len,src,pidl);
|
|
|
|
|
|
|
|
switch (src->uType)
|
|
|
|
{
|
|
|
|
case STRRET_WSTR:
|
|
|
|
lstrcpynW((LPWSTR)dest, src->u.pOleStr, len);
|
|
|
|
/* SHFree(src->u.pOleStr); FIXME: is this right? */
|
|
|
|
break;
|
|
|
|
|
|
|
|
case STRRET_CSTRA:
|
|
|
|
if (!MultiByteToWideChar( CP_ACP, 0, src->u.cStr, -1, dest, len ) && len)
|
|
|
|
dest[len-1] = 0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case STRRET_OFFSETA:
|
|
|
|
if (pidl)
|
|
|
|
{
|
|
|
|
if (!MultiByteToWideChar( CP_ACP, 0, ((LPCSTR)&pidl->mkid)+src->u.uOffset, -1,
|
|
|
|
dest, len ) && len)
|
|
|
|
dest[len-1] = 0;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
FIXME("unknown type!\n");
|
|
|
|
if (len)
|
|
|
|
{ *(LPSTR)dest = '\0';
|
|
|
|
}
|
|
|
|
return(FALSE);
|
|
|
|
}
|
|
|
|
return S_OK;
|
2000-06-02 01:25:44 +02:00
|
|
|
}
|
2000-07-26 19:51:32 +02:00
|
|
|
|
2001-09-11 01:16:31 +02:00
|
|
|
|
2002-01-18 19:57:43 +01:00
|
|
|
/*************************************************************************
|
|
|
|
* StrRetToStrN [SHELL32.96]
|
|
|
|
*
|
|
|
|
* converts a STRRET to a normal string
|
|
|
|
*
|
|
|
|
* NOTES
|
|
|
|
* the pidl is for STRRET OFFSET
|
|
|
|
*/
|
2000-09-26 02:00:55 +02:00
|
|
|
HRESULT WINAPI StrRetToStrNAW (LPVOID dest, DWORD len, LPSTRRET src, const ITEMIDLIST *pidl)
|
2000-06-02 01:25:44 +02:00
|
|
|
{
|
2000-08-14 16:35:01 +02:00
|
|
|
if(SHELL_OsIsUnicode())
|
2000-06-02 01:25:44 +02:00
|
|
|
return StrRetToStrNW (dest, len, src, pidl);
|
|
|
|
return StrRetToStrNA (dest, len, src, pidl);
|
|
|
|
}
|
|
|
|
|
|
|
|
/************************* OLESTR functions ****************************/
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
* StrToOleStr [SHELL32.163]
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
int WINAPI StrToOleStrA (LPWSTR lpWideCharStr, LPCSTR lpMultiByteString)
|
|
|
|
{
|
|
|
|
TRACE("(%p, %p %s)\n",
|
|
|
|
lpWideCharStr, lpMultiByteString, debugstr_a(lpMultiByteString));
|
|
|
|
|
|
|
|
return MultiByteToWideChar(0, 0, lpMultiByteString, -1, lpWideCharStr, MAX_PATH);
|
|
|
|
|
|
|
|
}
|
|
|
|
int WINAPI StrToOleStrW (LPWSTR lpWideCharStr, LPCWSTR lpWString)
|
|
|
|
{
|
|
|
|
TRACE("(%p, %p %s)\n",
|
|
|
|
lpWideCharStr, lpWString, debugstr_w(lpWString));
|
|
|
|
|
2000-08-14 16:35:01 +02:00
|
|
|
strcpyW (lpWideCharStr, lpWString );
|
|
|
|
return strlenW(lpWideCharStr);
|
2000-06-02 01:25:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
BOOL WINAPI StrToOleStrAW (LPWSTR lpWideCharStr, LPCVOID lpString)
|
|
|
|
{
|
2000-08-14 16:35:01 +02:00
|
|
|
if (SHELL_OsIsUnicode())
|
2000-06-02 01:25:44 +02:00
|
|
|
return StrToOleStrW (lpWideCharStr, lpString);
|
|
|
|
return StrToOleStrA (lpWideCharStr, lpString);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
* StrToOleStrN [SHELL32.79]
|
|
|
|
* lpMulti, nMulti, nWide [IN]
|
|
|
|
* lpWide [OUT]
|
|
|
|
*/
|
|
|
|
BOOL WINAPI StrToOleStrNA (LPWSTR lpWide, INT nWide, LPCSTR lpStrA, INT nStr)
|
|
|
|
{
|
|
|
|
TRACE("(%p, %x, %s, %x)\n", lpWide, nWide, debugstr_an(lpStrA,nStr), nStr);
|
|
|
|
return MultiByteToWideChar (0, 0, lpStrA, nStr, lpWide, nWide);
|
|
|
|
}
|
|
|
|
BOOL WINAPI StrToOleStrNW (LPWSTR lpWide, INT nWide, LPCWSTR lpStrW, INT nStr)
|
|
|
|
{
|
|
|
|
TRACE("(%p, %x, %s, %x)\n", lpWide, nWide, debugstr_wn(lpStrW, nStr), nStr);
|
|
|
|
|
|
|
|
if (lstrcpynW (lpWide, lpStrW, nWide))
|
|
|
|
{ return lstrlenW (lpWide);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL WINAPI StrToOleStrNAW (LPWSTR lpWide, INT nWide, LPCVOID lpStr, INT nStr)
|
|
|
|
{
|
2000-08-14 16:35:01 +02:00
|
|
|
if (SHELL_OsIsUnicode())
|
2000-06-02 01:25:44 +02:00
|
|
|
return StrToOleStrNW (lpWide, nWide, lpStr, nStr);
|
|
|
|
return StrToOleStrNA (lpWide, nWide, lpStr, nStr);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
* OleStrToStrN [SHELL32.78]
|
|
|
|
*/
|
|
|
|
BOOL WINAPI OleStrToStrNA (LPSTR lpStr, INT nStr, LPCWSTR lpOle, INT nOle)
|
|
|
|
{
|
|
|
|
TRACE("(%p, %x, %s, %x)\n", lpStr, nStr, debugstr_wn(lpOle,nOle), nOle);
|
|
|
|
return WideCharToMultiByte (0, 0, lpOle, nOle, lpStr, nStr, NULL, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL WINAPI OleStrToStrNW (LPWSTR lpwStr, INT nwStr, LPCWSTR lpOle, INT nOle)
|
|
|
|
{
|
|
|
|
TRACE("(%p, %x, %s, %x)\n", lpwStr, nwStr, debugstr_wn(lpOle,nOle), nOle);
|
|
|
|
|
|
|
|
if (lstrcpynW ( lpwStr, lpOle, nwStr))
|
|
|
|
{ return lstrlenW (lpwStr);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL WINAPI OleStrToStrNAW (LPVOID lpOut, INT nOut, LPCVOID lpIn, INT nIn)
|
|
|
|
{
|
2000-08-14 16:35:01 +02:00
|
|
|
if (SHELL_OsIsUnicode())
|
2000-06-02 01:25:44 +02:00
|
|
|
return OleStrToStrNW (lpOut, nOut, lpIn, nIn);
|
|
|
|
return OleStrToStrNA (lpOut, nOut, lpIn, nIn);
|
|
|
|
}
|