On 18.06.2009 00:51, Adrian Buehlmann wrote:
> I'm looking at 
> http://bitbucket.org/tortoisehg/crew/src/e214839bf369/win32/shellext/ContextMenu.cpp#cl-445
> 
> we have
> 
> STDMETHODIMP
> CShellExt::GetCommandString(
>     UINT_PTR idCmd, UINT uFlags, UINT FAR *reserved,
>     LPSTR pszName, UINT cchMax)
> {
>     *pszName = 0;
>     char *psz;
> 
>     TDEBUG_TRACE(
>         "CShellExt::GetCommandString: idCmd = " << idCmd
>         << ", uFlags = " << uFlags
>     );
>     MenuIdCmdMap::iterator iter = MenuIdMap.find(static_cast<UINT>(idCmd));
>     if (iter != MenuIdMap.end())
>     {
>         TDEBUG_TRACE(
>             "CShellExt::GetCommandString: name = " << iter->second.name);
>         psz = (char*)iter->second.helpText.c_str();
>     }
>     else
>     {
>         TDEBUG_TRACE(
>             "CShellExt::GetCommandString: can't find idCmd " << idCmd);
>         psz = "";
>     }
> 
>     if (uFlags & GCS_UNICODE)
>     {
>         wcscpy((wchar_t*)pszName, _WCSTR(psz));
>     }
>     else
>     {
>         strcpy((char*)pszName, psz);
>     }
>     return NOERROR;
> }
> 
> Can someone explain what _WCSTR() does?
> 
> http://msdn.microsoft.com/en-us/library/bb776083(VS.85).aspx specifies
> that if uFlags & GCS_UNICODE, a "unicode" string must be copied into
> pszName (I assume a wstring is meant with that).
> 
> But how do we get that wstring?
> 
> See also
> http://bitbucket.org/tortoisehg/crew/changeset/70f7297adda2/
> 
> Usage of _WCTSR() seems to go back to
> http://bitbucket.org/tortoisehg/crew/src/c3caaf07dbcc/tortoise/shellext/ContextMenu.cpp#cl-260
> (TK Soh's initial commit)
> 
> 

On second look, the implementation of this function looks
rather broken.

The spec wants

uFlags
    Flags specifying the information to return. This parameter can have one of 
the following values.

    GCS_HELPTEXTA
        Sets pszName to an ANSI string containing the help text for the command.
    GCS_HELPTEXTW
        Sets pszName to a Unicode string containing the help text for the 
command.
    GCS_VALIDATEA
        Returns S_OK if the menu item exists, or S_FALSE otherwise.
    GCS_VALIDATEW
        Returns S_OK if the menu item exists, or S_FALSE otherwise.
    GCS_VERBA
        Sets pszName to an ANSI string containing the language-independent 
command name for the menu item.
    GCS_VERBW
        Sets pszName to a Unicode string containing the language-independent 
command name for the menu item.


we always seem return helpText, no matter what uFlags is.


------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables unlimited
royalty-free distribution of the report engine for externally facing 
server and web deployment.
http://p.sf.net/sfu/businessobjects
_______________________________________________
Tortoisehg-develop mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tortoisehg-develop

Reply via email to