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||");
CFileDialog fd(TRUE, _T(".ps"), _T("*.ps"), OFN_ALLOWMULTISELECT|OFN_FILEMUSTEXIST, szFilter, this);
const uint MAX_NUM_CHAR = 65536;
TCHAR filenamesBuf[MAX_NUM_CHAR];
_tcscpy_s(filenamesBuf, MAX_NUM_CHAR, _T("*.ps"));

View file

@ -210,8 +210,8 @@ void CSnapshotToolDlg::toRegistry()
HKEY hKey;
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("OutputPath"), 0, REG_SZ, (BYTE*) (LPCTSTR) m_OutputPath, m_OutputPath.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) * sizeof(TCHAR));
CString filters;
for (uint k = 0; k < (uint) m_Filters.GetCount(); ++k)
{
@ -221,7 +221,7 @@ void CSnapshotToolDlg::toRegistry()
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 dumpTextureSets = m_DumpTextureSets;
DWORD width = (DWORD) m_OutputWidth;

View file

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

View file

@ -133,7 +133,10 @@ void SetBankPathName (const std::string& path)
HKEY hKey;
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);
}
}

View file

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

View file

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