468,512 Members | 1,372 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,512 developers. It's quick & easy.

Convertion

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;
}

Jul 14 '06 #1
1 3183
oy*********@gmail.com 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
Jul 14 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Petr Studenovsky | last post: by
reply views Thread by Konstantin Kivi | last post: by
6 posts views Thread by Chiller | last post: by
reply views Thread by McKoy | last post: by
4 posts views Thread by juli | last post: by
4 posts views Thread by kaikai | last post: by
24 posts views Thread by ChaosKCW | last post: by
reply views Thread by NPC403 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.