For Programmers: Free Programming Magazines  


Home > Archive > VC Language > May 2006 > convert std:string to LPCTSTR









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author convert std:string to LPCTSTR
farseer@optonline.net

2006-05-30, 4:14 am

How can i do this?

i'd like to call the following code:

....
string url = <my urld>;
TCHAR* urlParams = GetParams( );
url.append( (char * ) urlParams );
GotoURL( ( LPCTSTR ) url ); <------THIS IS MY ISSUE
....


static BOOL GotoURL(LPCTSTR lpszUrl)
{
// Try to open hyperlink

SHELLEXECUTEINFO sei;

memset(&sei, 0, sizeof(SHELLEXECUTEINFO));

sei.cbSize = sizeof(SHELLEXECUTEINFO);
sei.fMask = SEE_MASK_FLAG_NO_UI;
sei.lpVerb = _T("open");
//sei.lpFile=_T("iexplore.exe");
sei.lpFile = lpszUrl;
sei.nShow = SW_SHOWMAXIMIZED;
//sei.lpParameters=_T("you url here");

return ShellExecuteEx(&sei);
}

Mark Randall

2006-05-30, 4:14 am

string is a ASCII array, TCHAR is either char or wchar_t depending upon
UNICODE (or is it _UNICODE) is defined.

You will have to define your own tstring based on TCHAR, and then use
c_str()

--
- Mark Randall
http://www.temporal-solutions.co.uk

"We're Systems and Networks..."
"It's our job to know..."
<farseer@optonline.net> wrote in message
news:1148965374.551488.174160@y43g2000cwc.googlegroups.com...
> How can i do this?
>
> i'd like to call the following code:
>
> ...
> string url = <my urld>;
> TCHAR* urlParams = GetParams( );
> url.append( (char * ) urlParams );
> GotoURL( ( LPCTSTR ) url ); <------THIS IS MY ISSUE
> ...
>
>
> static BOOL GotoURL(LPCTSTR lpszUrl)
> {
> // Try to open hyperlink
>
> SHELLEXECUTEINFO sei;
>
> memset(&sei, 0, sizeof(SHELLEXECUTEINFO));
>
> sei.cbSize = sizeof(SHELLEXECUTEINFO);
> sei.fMask = SEE_MASK_FLAG_NO_UI;
> sei.lpVerb = _T("open");
> //sei.lpFile=_T("iexplore.exe");
> sei.lpFile = lpszUrl;
> sei.nShow = SW_SHOWMAXIMIZED;
> //sei.lpParameters=_T("you url here");
>
> return ShellExecuteEx(&sei);
> }
>



David D

2006-05-30, 4:14 am

farseer@optonline.net wrote:
> How can i do this?
>
> i'd like to call the following code:
>
> ...
> string url = <my urld>;
> TCHAR* urlParams = GetParams( );
> url.append( (char * ) urlParams );
> GotoURL( ( LPCTSTR ) url ); <------THIS IS MY ISSUE


GotoURL( url.c_str() ); <---- This should do


> ...
>
>
> static BOOL GotoURL(LPCTSTR lpszUrl)
> {
> // Try to open hyperlink
>
> SHELLEXECUTEINFO sei;
>
> memset(&sei, 0, sizeof(SHELLEXECUTEINFO));
>
> sei.cbSize = sizeof(SHELLEXECUTEINFO);
> sei.fMask = SEE_MASK_FLAG_NO_UI;
> sei.lpVerb = _T("open");
> //sei.lpFile=_T("iexplore.exe");
> sei.lpFile = lpszUrl;
> sei.nShow = SW_SHOWMAXIMIZED;
> //sei.lpParameters=_T("you url here");
>
> return ShellExecuteEx(&sei);
> }
>

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com