Convertion

O

oytunyilmaz

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(LPCMINVOKECOMMANDINFO
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;
}
 
V

Victor Bazarov

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,263
Messages
2,571,062
Members
48,769
Latest member
Clifft

Latest Threads

Top