Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Convertion

Reply
Thread Tools

Convertion

 
 
oytunyilmaz@gmail.com
Guest
Posts: n/a
 
      07-14-2006
Hi,

I have a problem with passing a parameter of type _TCHAR* to int
System(const char *) function. How can I convert _TCHAR* to const char
* ? The code is below




STDMETHODIMP CCopyPathContextMenu::InvokeCommand(LPCMINVOKECOMM ANDINFO
lpici)
{
_TCHAR* pStrClipboardText = NULL, strTempFileNameBuff[MAX_PATH + 50];
_TCHAR *pCurrent = NULL, *pLast = NULL;
BOOLEAN bMakeCStyleString = ((GetKeyState(VK_CONTROL) & 0x8000) !=
0);
BOOLEAN bMakeShortPath = ((GetKeyState(VK_SHIFT) & 0x8000) != 0);
int nFileCount = 0, i;

switch (LOWORD(lpici->lpVerb)) {
case ID_COPY_PATH:

nFileCount = m_listFileNames.size();
if (nFileCount == 0)
return S_OK;

// The '+ 50' is so that we provide ample room for double
backslashes.
pStrClipboardText = new _TCHAR[nFileCount * (MAX_PATH+50)];
pStrClipboardText[0] = _T('\0');

// Loop through all the files.
for (i = 0; i < nFileCount; i++) {
// Copy the file name into a temporary buffer. If the ALT key is
down,
// convert the long file name to a short one.


_tcscpy(strTempFileNameBuff, m_listFileNames.front().data());


pLast = strTempFileNameBuff;
// If the control key is pressed, change the path so that all the
// backslashes are converted to double backslashes. This is useful
// when pasting a path into C/C++ code, as a single backslash
denotes
// an escape sequence and a double backslash denotes a literal
backslash.

while ((pCurrent = _tcschr(pLast, _T('\\'))) != NULL) {
_tcsncat(pStrClipboardText, pLast, pCurrent - pLast + 1);
pLast = pCurrent + 1;
_tcscat(pStrClipboardText, _T("\\"));
}
_tcscat(pStrClipboardText, pLast);


// If this isn't the last file, add a line break before we add the
next file name.
if (i != (nFileCount - 1))
_tcscat(pStrClipboardText, _T("\r\n"));

m_listFileNames.pop_front();
}


***********
//system(pStrClipboardText);
***********


delete[] pStrClipboardText;
break;
}
return S_OK;
}

 
Reply With Quote
 
 
 
 
Victor Bazarov
Guest
Posts: n/a
 
      07-14-2006
http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:
> I have a problem with passing a parameter of type _TCHAR* to int
> System(const char *) function. How can I convert _TCHAR* to const
> char * ? The code is below
>
> [...]


What's _TCHAR? What's "System" function? They are not part of the
_standard_ C++. You should probably ask in the newsgroup dedicated
to your platform or compiler.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
JSP Script fro currency convertion Steven Java 1 03-09-2005 03:13 AM
type convertion of an unconstrained output in a port map ygrugni@hotmail.com VHDL 8 02-10-2005 06:53 PM
byte to long: convertion problem cccc Java 8 09-21-2004 06:37 PM
Convertion php to asp.net : PB lecture fichier .ini isore ASP .Net 0 07-01-2004 05:52 PM
BMP to GIF convertion Hiranya Samarasekera Java 3 08-27-2003 03:06 PM



Advertisments