Get rid of TCHAR variables. Use WCHAR instead.

svn path=/trunk/; revision=23219
This commit is contained in:
Hervé Poussineau 2006-07-21 22:15:21 +00:00
parent a6bd824e02
commit c1d9e2bb6c
4 changed files with 83 additions and 86 deletions

View file

@ -30,8 +30,8 @@ HINSTANCE hDllInstance;
static BOOL
SearchDriver(
IN PDEVINSTDATA DevInstData,
IN LPCTSTR Directory OPTIONAL,
IN LPCTSTR InfFile OPTIONAL);
IN LPCWSTR Directory OPTIONAL,
IN LPCWSTR InfFile OPTIONAL);
/*
* @implemented
@ -250,14 +250,14 @@ UpdateDriverForPlugAndPlayDevicesA(
static BOOL
SearchDriver(
IN PDEVINSTDATA DevInstData,
IN LPCTSTR Directory OPTIONAL,
IN LPCTSTR InfFile OPTIONAL)
IN LPCWSTR Directory OPTIONAL,
IN LPCWSTR InfFile OPTIONAL)
{
SP_DEVINSTALL_PARAMS DevInstallParams = {0,};
SP_DEVINSTALL_PARAMS_W DevInstallParams = {0,};
BOOL ret;
DevInstallParams.cbSize = sizeof(SP_DEVINSTALL_PARAMS);
if (!SetupDiGetDeviceInstallParams(DevInstData->hDevInfo, &DevInstData->devInfoData, &DevInstallParams))
DevInstallParams.cbSize = sizeof(SP_DEVINSTALL_PARAMS_W);
if (!SetupDiGetDeviceInstallParamsW(DevInstData->hDevInfo, &DevInstData->devInfoData, &DevInstallParams))
{
TRACE("SetupDiGetDeviceInstallParams() failed with error 0x%lx\n", GetLastError());
return FALSE;
@ -267,20 +267,20 @@ SearchDriver(
if (InfFile)
{
DevInstallParams.Flags |= DI_ENUMSINGLEINF;
_tcsncpy(DevInstallParams.DriverPath, InfFile, MAX_PATH);
wcsncpy(DevInstallParams.DriverPath, InfFile, MAX_PATH);
}
else if (Directory)
{
DevInstallParams.Flags &= ~DI_ENUMSINGLEINF;
_tcsncpy(DevInstallParams.DriverPath, Directory, MAX_PATH);
wcsncpy(DevInstallParams.DriverPath, Directory, MAX_PATH);
}
else
{
DevInstallParams.Flags &= ~DI_ENUMSINGLEINF;
*DevInstallParams.DriverPath = _T('\0');
*DevInstallParams.DriverPath = '\0';
}
ret = SetupDiSetDeviceInstallParams(
ret = SetupDiSetDeviceInstallParamsW(
DevInstData->hDevInfo,
&DevInstData->devInfoData,
&DevInstallParams);
@ -319,20 +319,20 @@ SearchDriver(
}
static BOOL
IsDots(IN LPCTSTR str)
IsDots(IN LPCWSTR str)
{
if(_tcscmp(str, _T(".")) && _tcscmp(str, _T(".."))) return FALSE;
if(wcscmp(str, L".") && wcscmp(str, L"..")) return FALSE;
return TRUE;
}
static LPCTSTR
GetFileExt(IN LPTSTR FileName)
static LPCWSTR
GetFileExt(IN LPWSTR FileName)
{
LPCTSTR Dot;
LPCWSTR Dot;
Dot = _tcsrchr(FileName, _T('.'));
Dot = wcsrchr(FileName, '.');
if (!Dot)
return _T("");
return L"";
return Dot;
}
@ -340,40 +340,40 @@ GetFileExt(IN LPTSTR FileName)
static BOOL
SearchDriverRecursive(
IN PDEVINSTDATA DevInstData,
IN LPCTSTR Path)
IN LPCWSTR Path)
{
WIN32_FIND_DATA wfd;
TCHAR DirPath[MAX_PATH];
TCHAR FileName[MAX_PATH];
TCHAR FullPath[MAX_PATH];
TCHAR LastDirPath[MAX_PATH] = _T("");
TCHAR PathWithPattern[MAX_PATH];
WIN32_FIND_DATAW wfd;
WCHAR DirPath[MAX_PATH];
WCHAR FileName[MAX_PATH];
WCHAR FullPath[MAX_PATH];
WCHAR LastDirPath[MAX_PATH] = L"";
WCHAR PathWithPattern[MAX_PATH];
BOOL ok = TRUE;
BOOL retval = FALSE;
HANDLE hFindFile = INVALID_HANDLE_VALUE;
_tcscpy(DirPath, Path);
wcscpy(DirPath, Path);
if (DirPath[_tcsclen(DirPath) - 1] != '\\')
_tcscat(DirPath, _T("\\"));
if (DirPath[wcslen(DirPath) - 1] != '\\')
wcscat(DirPath, L"\\");
_tcscpy(PathWithPattern, DirPath);
_tcscat(PathWithPattern, _T("\\*"));
wcscpy(PathWithPattern, DirPath);
wcscat(PathWithPattern, L"\\*");
for (hFindFile = FindFirstFile(PathWithPattern, &wfd);
for (hFindFile = FindFirstFileW(PathWithPattern, &wfd);
ok && hFindFile != INVALID_HANDLE_VALUE;
ok = FindNextFile(hFindFile, &wfd))
ok = FindNextFileW(hFindFile, &wfd))
{
_tcscpy(FileName, wfd.cFileName);
wcscpy(FileName, wfd.cFileName);
if (IsDots(FileName))
continue;
if (wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
{
/* Recursive search */
_tcscpy(FullPath, DirPath);
_tcscat(FullPath, FileName);
wcscpy(FullPath, DirPath);
wcscat(FullPath, FileName);
if (SearchDriverRecursive(DevInstData, FullPath))
{
retval = TRUE;
@ -382,13 +382,13 @@ SearchDriverRecursive(
}
else
{
LPCTSTR pszExtension = GetFileExt(FileName);
LPCWSTR pszExtension = GetFileExt(FileName);
if ((_tcsicmp(pszExtension, _T(".inf")) == 0) && (_tcscmp(LastDirPath, DirPath) != 0))
if ((wcsicmp(pszExtension, L".inf") == 0) && (wcscmp(LastDirPath, DirPath) != 0))
{
_tcscpy(LastDirPath, DirPath);
wcscpy(LastDirPath, DirPath);
if (_tcsclen(DirPath) > MAX_PATH)
if (wcslen(DirPath) > MAX_PATH)
/* Path is too long to be searched */
continue;
@ -422,11 +422,11 @@ ScanFoldersForDriver(
/* We need to check all specified directories to be
* sure to find the best driver for the device.
*/
LPCTSTR Path;
for (Path = DevInstData->CustomSearchPath; *Path != '\0'; Path += _tcslen(Path) + 1)
LPCWSTR Path;
for (Path = DevInstData->CustomSearchPath; *Path != '\0'; Path += wcslen(Path) + 1)
{
TRACE("Search driver in %S\n", Path);
if (_tcslen(Path) == 2 && Path[1] == ':')
if (wcslen(Path) == 2 && Path[1] == ':')
{
if (SearchDriverRecursive(DevInstData, Path))
result = TRUE;
@ -449,13 +449,13 @@ PrepareFoldersToScan(
IN BOOL IncludeCustomPath,
IN HWND hwndCombo OPTIONAL)
{
TCHAR drive[] = {'?',':',0};
WCHAR drive[] = {'?',':',0};
DWORD dwDrives = 0;
DWORD i;
UINT nType;
DWORD CustomTextLength = 0;
DWORD LengthNeeded = 0;
LPTSTR Buffer;
LPWSTR Buffer;
/* Calculate length needed to store the search paths */
if (IncludeRemovableDevices)
@ -465,7 +465,7 @@ PrepareFoldersToScan(
{
if (dwDrives & i)
{
nType = GetDriveType(drive);
nType = GetDriveTypeW(drive);
if (nType == DRIVE_REMOVABLE || nType == DRIVE_CDROM)
{
LengthNeeded += 3;
@ -484,7 +484,7 @@ PrepareFoldersToScan(
DevInstData->CustomSearchPath = Buffer = HeapAlloc(
GetProcessHeap(),
0,
(LengthNeeded + 1) * sizeof(TCHAR));
(LengthNeeded + 1) * sizeof(WCHAR));
if (!Buffer)
{
TRACE("HeapAlloc() failed\n");
@ -499,19 +499,19 @@ PrepareFoldersToScan(
{
if (dwDrives & i)
{
nType = GetDriveType(drive);
nType = GetDriveTypeW(drive);
if (nType == DRIVE_REMOVABLE || nType == DRIVE_CDROM)
{
Buffer += 1 + _stprintf(Buffer, drive);
Buffer += 1 + swprintf(Buffer, drive);
}
}
}
}
if (IncludeCustomPath)
{
Buffer += 1 + ComboBox_GetText(hwndCombo, Buffer, CustomTextLength);
Buffer += 1 + GetWindowTextW(hwndCombo, Buffer, CustomTextLength);
}
*Buffer = _T('\0');
*Buffer = '\0';
return TRUE;
}
@ -522,7 +522,7 @@ InstallCurrentDriver(
{
BOOL ret;
TRACE("Installing driver %S: %S\n", DevInstData->drvInfoData.MfgName, DevInstData->drvInfoData.Description);
TRACE("Installing driver %s: %s\n", DevInstData->drvInfoData.MfgName, DevInstData->drvInfoData.Description);
ret = SetupDiCallClassInstaller(
DIF_SELECTBESTCOMPATDRV,
@ -733,7 +733,7 @@ DevInstallW(
}
}
TRACE("Installing %S (%S)\n", DevInstData->buffer, InstanceId);
TRACE("Installing %s (%S)\n", DevInstData->buffer, InstanceId);
/* Search driver in default location and removable devices */
if (!PrepareFoldersToScan(DevInstData, FALSE, FALSE, NULL))

View file

@ -1,7 +1,5 @@
<module name="newdev" type="win32dll" installbase="system32" installname="newdev.dll">
<include base="newdev">.</include>
<define name="UNICODE" />
<define name="_UNICODE" />
<importlibrary definition="newdev.spec.def" />
<define name="_WIN32_IE">0x0600</define>
<define name="_WIN32_WINNT">0x0501</define>

View file

@ -1,6 +1,7 @@
#ifndef __NEWDEV_PRIVATE_H
#define __NEWDEV_PRIVATE_H
#define COBJMACROS
#include <windows.h>
#include <windowsx.h>
#include <commctrl.h>
@ -9,7 +10,6 @@
#include <setupapi.h>
#include <cfgmgr32.h>
#include <shlobj.h>
#include <tchar.h>
#include <wine/debug.h>
#include <stdio.h>
@ -29,7 +29,7 @@ typedef struct _DEVINSTDATA
SP_DEVINFO_DATA devInfoData;
SP_DRVINFO_DATA drvInfoData;
LPTSTR CustomSearchPath; /* MULTI_SZ string */
LPWSTR CustomSearchPath; /* MULTI_SZ string */
} DEVINSTDATA, *PDEVINSTDATA;
#define WM_SEARCH_FINISHED (WM_USER + 10)

View file

@ -237,8 +237,8 @@ PopulateCustomPathCombo(
HKEY hKey = NULL;
DWORD dwRegType;
DWORD dwPathLength;
LPTSTR Buffer = NULL;
LPCTSTR Path;
LPWSTR Buffer = NULL;
LPCWSTR Path;
LONG rc;
(void)ComboBox_ResetContent(hwndCombo);
@ -255,9 +255,9 @@ PopulateCustomPathCombo(
TRACE("RegOpenKeyEx() failed with error 0x%lx\n", rc);
goto cleanup;
}
rc = RegQueryValueEx(
rc = RegQueryValueExW(
hKey,
_T("Installation Sources"),
L"Installation Sources",
NULL,
&dwRegType,
NULL,
@ -269,15 +269,15 @@ PopulateCustomPathCombo(
}
/* Allocate enough space to add 2 NULL chars at the end of the string */
Buffer = HeapAlloc(GetProcessHeap(), 0, dwPathLength + 2 * sizeof(TCHAR));
Buffer = HeapAlloc(GetProcessHeap(), 0, dwPathLength + 2 * sizeof(WCHAR));
if (!Buffer)
{
TRACE("HeapAlloc() failed\n");
goto cleanup;
}
rc = RegQueryValueEx(
rc = RegQueryValueExW(
hKey,
_T("Installation Sources"),
L"Installation Sources",
NULL,
NULL,
(LPBYTE)Buffer,
@ -290,7 +290,7 @@ PopulateCustomPathCombo(
Buffer[dwPathLength] = Buffer[dwPathLength + 1] = '\0';
/* Populate combo box */
for (Path = Buffer; *Path; Path += _tcslen(Path) + 1)
for (Path = Buffer; *Path; Path += wcslen(Path) + 1)
{
(void)ComboBox_AddString(hwndCombo, Path);
if (Path == Buffer)
@ -307,10 +307,10 @@ static VOID
SaveCustomPath(
IN HWND hwndCombo)
{
LPTSTR CustomPath = NULL;
LPWSTR CustomPath = NULL;
DWORD CustomPathLength;
LPTSTR Buffer = NULL;
LPTSTR pBuffer; /* Pointer into Buffer */
LPWSTR Buffer = NULL;
LPWSTR pBuffer; /* Pointer into Buffer */
int ItemsCount, Length;
DWORD i;
DWORD TotalLength = 0;
@ -320,13 +320,13 @@ SaveCustomPath(
/* Get custom path */
Length = ComboBox_GetTextLength(hwndCombo) + 1;
CustomPath = HeapAlloc(GetProcessHeap(), 0, Length * sizeof(TCHAR));
CustomPath = HeapAlloc(GetProcessHeap(), 0, Length * sizeof(WCHAR));
if (!CustomPath)
{
TRACE("HeapAlloc() failed\n");
goto cleanup;
}
CustomPathLength = ComboBox_GetText(hwndCombo, CustomPath, Length) + 1;
CustomPathLength = GetWindowTextW(hwndCombo, CustomPath, Length) + 1;
/* Calculate length of the buffer */
ItemsCount = ComboBox_GetCount(hwndCombo);
@ -348,7 +348,7 @@ SaveCustomPath(
TotalLength++; /* Final NULL char */
/* Allocate buffer */
Buffer = HeapAlloc(GetProcessHeap(), 0, (CustomPathLength + TotalLength + 1) * sizeof(TCHAR));
Buffer = HeapAlloc(GetProcessHeap(), 0, (CustomPathLength + TotalLength + 1) * sizeof(WCHAR));
if (!Buffer)
{
TRACE("HeapAlloc() failed\n");
@ -365,7 +365,7 @@ SaveCustomPath(
TRACE("ComboBox_GetLBText() failed\n");
goto cleanup;
}
else if (UseCustomPath && _tcsicmp(CustomPath, pBuffer) == 0)
else if (UseCustomPath && wcsicmp(CustomPath, pBuffer) == 0)
UseCustomPath = FALSE;
pBuffer += 1 + Length;
}
@ -378,7 +378,7 @@ SaveCustomPath(
}
TotalLength += CustomPathLength;
_tcscpy(Buffer, CustomPath);
wcscpy(Buffer, CustomPath);
/* Save the buffer */
/* RegSetKeyValue would have been better... */
@ -393,13 +393,13 @@ SaveCustomPath(
TRACE("RegOpenKeyEx() failed with error 0x%lx\n", rc);
goto cleanup;
}
rc = RegSetValueEx(
rc = RegSetValueExW(
hKey,
_T("Installation Sources"),
L"Installation Sources",
0,
REG_MULTI_SZ,
(const BYTE*)Buffer,
TotalLength * sizeof(TCHAR));
TotalLength * sizeof(WCHAR));
if (rc != ERROR_SUCCESS)
{
TRACE("RegSetValueEx() failed with error 0x%lx\n", rc);
@ -595,21 +595,20 @@ CHSourceDlgProc(
pidl = SHBrowseForFolder(&bi);
if (pidl)
{
TCHAR Directory[MAX_PATH];
WCHAR Directory[MAX_PATH];
IMalloc* malloc;
if (SHGetPathFromIDList(pidl, Directory))
if (SHGetPathFromIDListW(pidl, Directory))
{
/* Set the IDC_COMBO_PATH text */
ComboBox_SetText(GetDlgItem(hwndDlg, IDC_COMBO_PATH), Directory);
SetWindowTextW(GetDlgItem(hwndDlg, IDC_COMBO_PATH), Directory);
}
/* Free memory, if possible */
if (SUCCEEDED(SHGetMalloc(&malloc)))
{
FIXME("Memory leak!\n");
//malloc->Free(pidl);
//malloc->Release();
IMalloc_Free(malloc, pidl);
IMalloc_Release(malloc);
}
return TRUE;
}
@ -1223,23 +1222,23 @@ FinishDlgProc(
static HFONT
CreateTitleFont(VOID)
{
NONCLIENTMETRICS ncm;
LOGFONT LogFont;
NONCLIENTMETRICSW ncm;
LOGFONTW LogFont;
HDC hdc;
INT FontSize;
HFONT hFont;
ncm.cbSize = sizeof(NONCLIENTMETRICS);
ncm.cbSize = sizeof(NONCLIENTMETRICSW);
SystemParametersInfo(SPI_GETNONCLIENTMETRICS, 0, &ncm, 0);
LogFont = ncm.lfMessageFont;
LogFont.lfWeight = FW_BOLD;
_tcscpy(LogFont.lfFaceName, _T("MS Shell Dlg"));
wcscpy(LogFont.lfFaceName, L"MS Shell Dlg");
hdc = GetDC(NULL);
FontSize = 12;
LogFont.lfHeight = 0 - GetDeviceCaps (hdc, LOGPIXELSY) * FontSize / 72;
hFont = CreateFontIndirect(&LogFont);
hFont = CreateFontIndirectW(&LogFont);
ReleaseDC(NULL, hdc);
return hFont;