Changed: Use TCHAR functions

This commit is contained in:
kervala 2016-12-10 14:21:20 +01:00
parent 3c9e4e3098
commit 12f39043b0
6 changed files with 25 additions and 33 deletions

View file

@ -1526,6 +1526,7 @@ void CParticleTreeCtrl::insertNewPS(CParticleWorkspace &pws)
{ {
static const TCHAR BASED_CODE szFilter[] = _T("NeL Particle systems (*.ps)|*.ps||"); static const TCHAR BASED_CODE szFilter[] = _T("NeL Particle systems (*.ps)|*.ps||");
CFileDialog fd(TRUE, _T(".ps"), _T("*.ps"), OFN_ALLOWMULTISELECT|OFN_FILEMUSTEXIST, szFilter, this); CFileDialog fd(TRUE, _T(".ps"), _T("*.ps"), OFN_ALLOWMULTISELECT|OFN_FILEMUSTEXIST, szFilter, this);
const uint MAX_NUM_CHAR = 65536; const uint MAX_NUM_CHAR = 65536;
TCHAR filenamesBuf[MAX_NUM_CHAR]; TCHAR filenamesBuf[MAX_NUM_CHAR];
_tcscpy_s(filenamesBuf, MAX_NUM_CHAR, _T("*.ps")); _tcscpy_s(filenamesBuf, MAX_NUM_CHAR, _T("*.ps"));

View file

@ -210,8 +210,8 @@ void CSnapshotToolDlg::toRegistry()
HKEY hKey; HKEY hKey;
if (RegCreateKey(HKEY_CURRENT_USER, NEL_OV_SNAPSHOT_TOOL_REGKEY, &hKey)==ERROR_SUCCESS) if (RegCreateKey(HKEY_CURRENT_USER, NEL_OV_SNAPSHOT_TOOL_REGKEY, &hKey)==ERROR_SUCCESS)
{ {
RegSetValueEx(hKey, _T("InputPath"), 0, REG_SZ, (BYTE*) (LPCTSTR) m_InputPath, m_InputPath.GetLength() + 1); RegSetValueEx(hKey, _T("InputPath"), 0, REG_SZ, (BYTE*) (LPCTSTR) m_InputPath, (m_InputPath.GetLength() + 1) * sizeof(TCHAR));
RegSetValueEx(hKey, _T("OutputPath"), 0, REG_SZ, (BYTE*) (LPCTSTR) m_OutputPath, m_OutputPath.GetLength() + 1); RegSetValueEx(hKey, _T("OutputPath"), 0, REG_SZ, (BYTE*) (LPCTSTR) m_OutputPath, (m_OutputPath.GetLength() + 1) * sizeof(TCHAR));
CString filters; CString filters;
for (uint k = 0; k < (uint) m_Filters.GetCount(); ++k) for (uint k = 0; k < (uint) m_Filters.GetCount(); ++k)
{ {
@ -221,7 +221,7 @@ void CSnapshotToolDlg::toRegistry()
filters += filter; filters += filter;
} }
RegSetValueEx(hKey, _T("Filters"), 0, REG_SZ, (BYTE*) (LPCTSTR) filters, filters.GetLength() + 1); RegSetValueEx(hKey, _T("Filters"), 0, REG_SZ, (BYTE*) (LPCTSTR) filters, (filters.GetLength() + 1) * sizeof(TCHAR));
DWORD recurseSubFolder = m_RecurseSubFolder; DWORD recurseSubFolder = m_RecurseSubFolder;
DWORD dumpTextureSets = m_DumpTextureSets; DWORD dumpTextureSets = m_DumpTextureSets;
DWORD width = (DWORD) m_OutputWidth; DWORD width = (DWORD) m_OutputWidth;

View file

@ -18,7 +18,7 @@
// //
#include "std_afx.h" #include "std_afx.h"
#include <tchar.h>
//#include "nel/3d/register_3d.h" //#include "nel/3d/register_3d.h"
//#include "nel/3d/scene.h" //#include "nel/3d/scene.h"
@ -29,9 +29,9 @@
using namespace NLMISC; using namespace NLMISC;
using namespace std; using namespace std;
int APIENTRY WinMain(HINSTANCE hInstance, int APIENTRY _tWinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, LPTSTR lpCmdLine,
int nCmdShow) int nCmdShow)
{ {
// Register 3d // Register 3d
@ -41,13 +41,13 @@ int APIENTRY WinMain(HINSTANCE hInstance,
// init3d (); // init3d ();
// Remove command line "" // Remove command line ""
char commandLine[512]; TCHAR commandLine[512];
char *commandLinePtr=commandLine; TCHAR *commandLinePtr=commandLine;
strcpy (commandLine, lpCmdLine); _tcscpy (commandLine, lpCmdLine);
if (commandLine[0]=='"') if (commandLine[0]==_T('"'))
commandLinePtr++; commandLinePtr++;
if (commandLinePtr[strlen (commandLinePtr)-1]=='"') if (commandLinePtr[_tcslen (commandLinePtr)-1]==_T('"'))
commandLinePtr[strlen (commandLinePtr)-1]=0; commandLinePtr[_tcslen (commandLinePtr)-1]=0;
// Create a object viewer // Create a object viewer
IObjectViewer *objectViewer=IObjectViewer::getInterface(); IObjectViewer *objectViewer=IObjectViewer::getInterface();
@ -58,11 +58,11 @@ int APIENTRY WinMain(HINSTANCE hInstance,
if (objectViewer->initUI ()) if (objectViewer->initUI ())
{ {
// Argument ? // Argument ?
if (strcmp (commandLinePtr, "")!=0) if (_tcscmp (commandLinePtr, _T(""))!=0)
{ {
// Make a string vector // Make a string vector
vector<string> strVector; vector<string> strVector;
strVector.push_back (commandLinePtr); strVector.push_back (tStrToUtf8(commandLinePtr));
// Try to load a shape // Try to load a shape
if (objectViewer->loadMesh (strVector, "")) if (objectViewer->loadMesh (strVector, ""))

View file

@ -133,7 +133,10 @@ void SetBankPathName (const std::string& path)
HKEY hKey; HKEY hKey;
if (RegCreateKey(HKEY_CURRENT_USER, REGKEY_TILEDIT, &hKey)==ERROR_SUCCESS) if (RegCreateKey(HKEY_CURRENT_USER, REGKEY_TILEDIT, &hKey)==ERROR_SUCCESS)
{ {
RegSetValueEx(hKey, "Bank Path", 0, REG_SZ, (LPBYTE)path.c_str(), path.length()+1); TCHAR buffer[MAX_PATH];
_tcscpy_s(buffer, MAX_PATH, utf8ToTStr(path));
RegSetValueEx(hKey, _T("Bank Path"), 0, REG_SZ, (LPBYTE)buffer, (_tcslen(buffer)+1)*sizeof(TCHAR));
RegCloseKey (hKey); RegCloseKey (hKey);
} }
} }

View file

@ -176,7 +176,7 @@ bool CExportDlg::callChoosePathDlg(CString &dest) const
bi.lpfn = expBrowseCallbackProc; bi.lpfn = expBrowseCallbackProc;
TCHAR sDir[512]; TCHAR sDir[512];
_tcscpy(sDir, (LPCTSTR)RefZoneDir); _tcscpy_s(sDir, 512, (LPCTSTR)RefZoneDir);
bi.lParam = (LPARAM)sDir; bi.lParam = (LPARAM)sDir;
bi.iImage = 0; bi.iImage = 0;

View file

@ -75,17 +75,10 @@ INT_PTR CFileDialogEx::DoModal ()
// Update the path // Update the path
std::string newPath = NLMISC::CFile::getPath (tStrToUtf8(GetPathName())); std::string newPath = NLMISC::CFile::getPath (tStrToUtf8(GetPathName()));
#ifdef _UNICODE TCHAR buffer[MAX_PATH];
ucstring tmp; _tcscpy_s(buffer, MAX_PATH, utf8ToTStr(newPath));
tmp.fromUtf8(newPath);
const uint cs = 2;
#else
std::stringg tmp = newPath;
const uint cs = 1;
#endif
uint length = (tmp.length() + 1) * cs;
RegSetValueEx (hKey, utf8ToTStr(_FileType), 0, REG_SZ, (LPBYTE)tmp.c_str(), length); RegSetValueEx (hKey, utf8ToTStr(_FileType), 0, REG_SZ, (LPBYTE)buffer, (_tcslen(buffer) + 1) * sizeof(TCHAR));
// Update the path list // Update the path list
set<string> oldPath; set<string> oldPath;
@ -101,14 +94,9 @@ INT_PTR CFileDialogEx::DoModal ()
uint index = 0; uint index = 0;
while (ite != oldPath.end ()) while (ite != oldPath.end ())
{ {
#ifdef _UNICODE _tcscpy_s(buffer, MAX_PATH, utf8ToTStr(*ite));
tmp.fromUtf8(*ite);
#else
tmp = *ite;
#endif
length = (tmp.length() + 1) * cs;
RegSetValueEx (hKey, utf8ToTStr(toString(index)), 0, REG_SZ, (LPBYTE)tmp.c_str (), length); RegSetValueEx (hKey, utf8ToTStr(toString(index)), 0, REG_SZ, (LPBYTE)buffer, (_tcslen(buffer) + 1) * sizeof(TCHAR));
ite++; ite++;
index++; index++;
} }