Working with LPCWSTR

Alan Gamboa <[email protected]> Tue, 15 Oct 2002 13:14:26 -0400
Newsgroups gmane.comp.windows.devel.oledb.devel
Message-ID <[email protected]>
This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.

------_=_NextPart_001_01C2746E.562ABAA0
Content-Type: text/plain;
        charset="iso-8859-1"

I am so used to manipulating CString and char[] variables, I am having
problems working with LPCWSTR variables :)

in my accessor i have

MY_DEFINE_COMMAND_EX(CMyAccessor,L"SELECT blah, SUBSTRING(blah,1,1) FROM
tblBlah")

i have redefined DEFINE_COMMAND_EX as follows:

#define MY_DEFINE_COMMAND_EX(x, wszCommand) \
        typedef x _CommandClass; \
        static HRESULT GetDefaultCommand(LPCWSTR* ppwszCommand) throw () \
        { \
                ParseString(wszCommand); \
                *ppwszCommand = wszCommand; \
                return S_OK; \
        }

here is ParseString():

inline void ParseString(LPCWSTR wszCommand)
{
        //what i want to do!
        CString s = wszCommand;
        s.Replace("SUBSTRING","SUBSTR");
        wszCommand = s;
}

I know the syntax above isn't exactly correct. Besides, I stepped through it
and wszCommand does not come back out.

any direction is appreciated.

Alan Gamboa
CCG Systems, Inc.


You can read messages from the OLEDB_DEV archive, unsubscribe from OLEDB_DEV,
or subscribe to other DevelopMentor lists at http://discuss.develop.com.

------_=_NextPart_001_01C2746E.562ABAA0
Content-Type: text/html;
        charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; =
charset=3Diso-8859-1">
<META NAME=3D"Generator" CONTENT=3D"MS Exchange Server version =
5.5.2448.0">
<TITLE>Working with LPCWSTR</TITLE>
</HEAD>
<BODY>

<P><FONT SIZE=3D2>I am so used to manipulating CString and char[] =
variables, I am having problems working with LPCWSTR variables =
:)</FONT>
</P>

<P><FONT SIZE=3D2>in my accessor i have</FONT>
</P>

<P><FONT SIZE=3D2>MY_DEFINE_COMMAND_EX(CMyAccessor,L&quot;SELECT blah, =
SUBSTRING(blah,1,1) FROM tblBlah&quot;)</FONT>
</P>

<P><FONT SIZE=3D2>i have redefined DEFINE_COMMAND_EX as follows:</FONT>
</P>

<P><FONT SIZE=3D2>#define MY_DEFINE_COMMAND_EX(x, wszCommand) \</FONT>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=3D2>typedef x =
_CommandClass; \</FONT>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=3D2>static =
HRESULT GetDefaultCommand(LPCWSTR* ppwszCommand) throw () \</FONT>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=3D2>{ =
\</FONT>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT =
SIZE=3D2>ParseString(wszCommand); \</FONT>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=3D2>*ppwszCommand =
=3D wszCommand; \</FONT>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=3D2>return S_OK; =
\</FONT>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=3D2>}</FONT>
</P>

<P><FONT SIZE=3D2>here is ParseString():</FONT>
</P>

<P><FONT SIZE=3D2>inline void ParseString(LPCWSTR wszCommand)</FONT>
<BR><FONT SIZE=3D2>{</FONT>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=3D2>//what i =
want to do!</FONT>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=3D2>CString s =
=3D wszCommand;</FONT>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT =
SIZE=3D2>s.Replace(&quot;SUBSTRING&quot;,&quot;SUBSTR&quot;);</FONT>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT =
SIZE=3D2>wszCommand =3D s;</FONT>
<BR><FONT SIZE=3D2>}</FONT>
</P>

<P><FONT SIZE=3D2>I know the syntax above isn't exactly correct. =
Besides, I stepped through it and wszCommand does not come back =
out.</FONT>
</P>

<P><FONT SIZE=3D2>any direction is appreciated.</FONT>
</P>

<P><FONT SIZE=3D2>Alan Gamboa</FONT>
<BR><FONT SIZE=3D2>CCG Systems, Inc.</FONT>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
</P>

</BODY>
You can read messages from the OLEDB_DEV archive, unsubscribe from OLEDB_DEV,
or subscribe to other DevelopMentor lists at http://discuss.develop.com.
</HTML>
------_=_NextPart_001_01C2746E.562ABAA0--