error C2440 cannot convert from char to TCHAR
Jeg har lidt problemer med min kode.Får denne fejl:
error C2440: '=' : cannot convert from 'char *' to 'TCHAR *'
i linien:
pEnvCMD = getenv("COMSPEC");
//---------------------------------------------------------------------------
#pragma argsused
#pragma hdrstop
#include "windows.h"
#include <tchar.h>
#include <stdlib.h>
//---------------------------------------------------------------------------
DWORD RunProgram (TCHAR* _tcsFunct, TCHAR* _tcsstrParams, bool hide)
{
STARTUPINFO StartupInfo;
PROCESS_INFORMATION ProcessInfo;
TCHAR Args[4096];
TCHAR *pEnvCMD = NULL;
TCHAR *pDefaultCMD = _T("CMD.EXE");
ULONG rc;
memset(&StartupInfo, 0, sizeof(StartupInfo));
StartupInfo.cb = sizeof(STARTUPINFO);
StartupInfo.dwFlags = STARTF_USESHOWWINDOW;
StartupInfo.wShowWindow = SW_SHOW;
if (hide)
{
StartupInfo.dwFlags = STARTF_USESHOWWINDOW;
StartupInfo.wShowWindow = SW_HIDE;
}
Args[0] = 0;
pEnvCMD = getenv("COMSPEC");
if(pEnvCMD){
_tcscpy(Args, pEnvCMD);
}
else{
_tcscpy(Args, pDefaultCMD);
}
_tcscat(Args, _T(" /c "));
_tcscat(Args, _tcsFunct);
_tcscat(Args, _T(" "));
_tcscat(Args, _tcsstrParams);
if (!CreateProcess( NULL, Args, NULL, NULL, FALSE,
CREATE_NEW_CONSOLE,
NULL,
NULL,
&StartupInfo,
&ProcessInfo))
{
return GetLastError();
}
WaitForSingleObject(ProcessInfo.hProcess, INFINITE);
if(!GetExitCodeProcess(ProcessInfo.hProcess, &rc))
rc = 0;
CloseHandle(ProcessInfo.hThread);
CloseHandle(ProcessInfo.hProcess);
return rc;
}