Re: Shell Alloc and UNICODE
- From: Ale <Ale@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Sat, 6 Aug 2005 05:31:03 -0700
Ok!!!!
I'm on correct way...
Thanks
Ale
"Mihai N." wrote:
> =?Utf-8?B?QWxl?= <Ale@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in news:E1489214-2EF7-
> 4B4D-89DD-4173779384B8@xxxxxxxxxxxxx:
>
> > While there are memset/wmemset memcpy/wmemcpy, is there a function to
> > allocate memory while using UNICODE!?
> All memory allocation uses byte counts, by definition.
> So there is nothing special about the UNICODE part. If you want to alloc
> memory for an array of structs, you multiply the size of the array with
> sizeof the struct. Same with Unicode, just multiply with sizeof(WCHAR).
>
> > I've defined this macro:
> > #define ShellAlloc(cb) (SHAlloc(cb*sizeof(TCHAR)))
> Depends. If the string uses generic data types (TCHAR), then what you did is
> ok. SHFileOperation uses generic string types, so probably this is also
> what you need.
>
> If the string is always Unicode (i.e. for COM operations), then you
> have to use sizeof(WCHAR).
>
> And I would try another name for the macro, something like: SHAllocString,
> to make it clear is about strings. You can also do this to have it handy:
> #define SHAllocString(cb) (SHAlloc(cb*sizeof(TCHAR)))
> #define SHAllocStringW(cb) (SHAlloc(cb*sizeof(WCHAR)))
> #define SHAllocStringA(cb) (SHAlloc(cb*sizeof(char)))
>
> You can also alloc 1 more if you want not to take care of the NULL
> explicitelly every single time you alloc something.
>
>
> --
> Mihai Nita [Microsoft MVP, Windows - SDK]
> ------------------------------------------
> Replace _year_ with _ to get the real email
>
.
- Follow-Ups:
- Re: Shell Alloc and UNICODE
- From: Mihai N.
- Re: Shell Alloc and UNICODE
- References:
- Shell Alloc and UNICODE
- From: Ale
- Re: Shell Alloc and UNICODE
- From: Mihai N.
- Shell Alloc and UNICODE
- Prev by Date: Re: Shell Alloc and UNICODE
- Next by Date: COleControl question
- Previous by thread: Re: Shell Alloc and UNICODE
- Next by thread: Re: Shell Alloc and UNICODE
- Index(es):
Relevant Pages
|