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

View file

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

View file

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

View file

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