[SERVMAN]

- TCHAR -> WCHAR

svn path=/trunk/; revision=67095
This commit is contained in:
Ged Murphy 2015-04-08 17:30:38 +00:00
parent 6de5a3ef96
commit 4fe24fa539
12 changed files with 419 additions and 404 deletions

View file

@ -22,14 +22,14 @@ AboutDialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
IDC_LICENSE_EDIT); IDC_LICENSE_EDIT);
if (hLicenseEditWnd) if (hLicenseEditWnd)
{ {
LPTSTR lpString; LPWSTR lpString;
if (AllocAndLoadString(&lpString, if (AllocAndLoadString(&lpString,
hInstance, hInstance,
IDS_LICENSE)) IDS_LICENSE))
{ {
SetWindowText(hLicenseEditWnd, SetWindowTextW(hLicenseEditWnd,
lpString); lpString);
LocalFree(lpString); LocalFree(lpString);
} }

View file

@ -12,11 +12,11 @@
typedef struct _CREATE_DATA typedef struct _CREATE_DATA
{ {
HWND hSelf; HWND hSelf;
LPTSTR ServiceName; LPWSTR ServiceName;
LPTSTR DisplayName; LPWSTR DisplayName;
LPTSTR BinPath; LPWSTR BinPath;
LPTSTR Description; LPWSTR Description;
LPTSTR Options; LPWSTR Options;
} CREATE_DATA, *PCREATE_DATA; } CREATE_DATA, *PCREATE_DATA;
@ -30,28 +30,28 @@ DoCreate(PCREATE_DATA Data)
BOOL bRet = FALSE; BOOL bRet = FALSE;
/* open handle to the SCM */ /* open handle to the SCM */
hSCManager = OpenSCManager(NULL, hSCManager = OpenSCManagerW(NULL,
NULL, NULL,
SC_MANAGER_ALL_ACCESS); SC_MANAGER_ALL_ACCESS);
if (hSCManager) if (hSCManager)
{ {
hSc = CreateService(hSCManager, hSc = CreateServiceW(hSCManager,
Data->ServiceName, Data->ServiceName,
Data->DisplayName, Data->DisplayName,
SERVICE_ALL_ACCESS, SERVICE_ALL_ACCESS,
SERVICE_WIN32_OWN_PROCESS, SERVICE_WIN32_OWN_PROCESS,
SERVICE_DEMAND_START, SERVICE_DEMAND_START,
SERVICE_ERROR_NORMAL, SERVICE_ERROR_NORMAL,
Data->BinPath, Data->BinPath,
NULL, NULL,
NULL, NULL,
NULL, NULL,
NULL, NULL,
NULL); NULL);
if (hSc) if (hSc)
{ {
LPTSTR lpSuccess; LPWSTR lpSuccess;
/* Set the service description as CreateService /* Set the service description as CreateService
does not do this for us */ does not do this for us */
@ -78,29 +78,29 @@ DoCreate(PCREATE_DATA Data)
return bRet; return bRet;
} }
static LPTSTR static LPWSTR
GetStringFromDialog(PCREATE_DATA Data, GetStringFromDialog(PCREATE_DATA Data,
UINT id) UINT id)
{ {
HWND hwnd; HWND hwnd;
LPTSTR lpString = NULL; LPWSTR lpString = NULL;
INT iLen = 0; INT iLen = 0;
hwnd = GetDlgItem(Data->hSelf, hwnd = GetDlgItem(Data->hSelf,
id); id);
if (hwnd) if (hwnd)
{ {
iLen = GetWindowTextLength(hwnd); iLen = GetWindowTextLengthW(hwnd);
if (iLen) if (iLen)
{ {
lpString = (LPTSTR)HeapAlloc(ProcessHeap, lpString = (LPWSTR)HeapAlloc(ProcessHeap,
0, 0,
(iLen + 1) * sizeof(TCHAR)); (iLen + 1) * sizeof(WCHAR));
if (lpString) if (lpString)
{ {
GetWindowText(hwnd, GetWindowTextW(hwnd,
lpString, lpString,
iLen + 1); iLen + 1);
} }
} }
} }
@ -167,34 +167,33 @@ CreateHelpDialogProc(HWND hDlg,
{ {
HWND hHelp; HWND hHelp;
HICON hIcon = NULL; HICON hIcon = NULL;
TCHAR Buf[1000]; WCHAR Buf[1000];
switch (message) switch (message)
{ {
case WM_INITDIALOG: case WM_INITDIALOG:
{ {
hIcon = (HICON) LoadImage(hInstance, hIcon = (HICON) LoadImageW(hInstance,
MAKEINTRESOURCE(IDI_SM_ICON), MAKEINTRESOURCE(IDI_SM_ICON),
IMAGE_ICON, IMAGE_ICON,
16, 16,
16, 16,
0); 0);
SendMessage(hDlg, SendMessageW(hDlg,
WM_SETICON, WM_SETICON,
ICON_SMALL, ICON_SMALL,
(LPARAM)hIcon); (LPARAM)hIcon);
hHelp = GetDlgItem(hDlg, hHelp = GetDlgItem(hDlg,
IDC_CREATE_HELP); IDC_CREATE_HELP);
LoadString(hInstance, LoadStringW(hInstance,
IDS_HELP_OPTIONS, IDS_HELP_OPTIONS,
Buf, Buf,
sizeof(Buf) / sizeof(TCHAR)); sizeof(Buf) / sizeof(WCHAR));
SetWindowText(hHelp, SetWindowTextW(hHelp, Buf);
Buf);
return TRUE; return TRUE;
} }

View file

@ -29,7 +29,7 @@ DoDeleteService(PMAIN_WND_INFO Info,
{ {
if (DeleteService(hSc)) if (DeleteService(hSc))
{ {
LPTSTR lpSuccess; LPWSTR lpSuccess;
/* report success to user */ /* report success to user */
if (AllocAndLoadString(&lpSuccess, if (AllocAndLoadString(&lpSuccess,
@ -74,44 +74,44 @@ DeleteDialogProc(HWND hDlg,
{ {
case WM_INITDIALOG: case WM_INITDIALOG:
{ {
LPTSTR lpDescription; LPWSTR lpDescription;
Info = (PMAIN_WND_INFO)lParam; Info = (PMAIN_WND_INFO)lParam;
if (Info != NULL) if (Info != NULL)
{ {
SetWindowLongPtr(hDlg, SetWindowLongPtrW(hDlg,
GWLP_USERDATA, GWLP_USERDATA,
(LONG_PTR)Info); (LONG_PTR)Info);
hIcon = (HICON)LoadImage(hInstance, hIcon = (HICON)LoadImageW(hInstance,
MAKEINTRESOURCE(IDI_SM_ICON), MAKEINTRESOURCE(IDI_SM_ICON),
IMAGE_ICON, IMAGE_ICON,
16, 16,
16, 16,
0); 0);
if (hIcon) if (hIcon)
{ {
SendMessage(hDlg, SendMessageW(hDlg,
WM_SETICON, WM_SETICON,
ICON_SMALL, ICON_SMALL,
(LPARAM)hIcon); (LPARAM)hIcon);
DestroyIcon(hIcon); DestroyIcon(hIcon);
} }
SendDlgItemMessage(hDlg, SendDlgItemMessageW(hDlg,
IDC_DEL_NAME, IDC_DEL_NAME,
WM_SETTEXT, WM_SETTEXT,
0, 0,
(LPARAM)Info->pCurrentService->lpDisplayName); (LPARAM)Info->pCurrentService->lpDisplayName);
lpDescription = GetServiceDescription(Info->pCurrentService->lpServiceName); lpDescription = GetServiceDescription(Info->pCurrentService->lpServiceName);
if (lpDescription) if (lpDescription)
{ {
SendDlgItemMessage(hDlg, SendDlgItemMessageW(hDlg,
IDC_DEL_DESC, IDC_DEL_DESC,
WM_SETTEXT, WM_SETTEXT,
0, 0,
(LPARAM)lpDescription); (LPARAM)lpDescription);
HeapFree(ProcessHeap, HeapFree(ProcessHeap,
0, 0,
lpDescription); lpDescription);

View file

@ -9,20 +9,20 @@
#include "precomp.h" #include "precomp.h"
LPTSTR LPWSTR
TV1_GetDependants(PSERVICEPROPSHEET pDlgInfo, TV1_GetDependants(PSERVICEPROPSHEET pDlgInfo,
SC_HANDLE hService) SC_HANDLE hService)
{ {
LPQUERY_SERVICE_CONFIG lpServiceConfig; LPQUERY_SERVICE_CONFIG lpServiceConfig;
LPTSTR lpStr = NULL; LPWSTR lpStr = NULL;
DWORD bytesNeeded; DWORD bytesNeeded;
DWORD bytes; DWORD bytes;
/* Get the info for this service */ /* Get the info for this service */
if (!QueryServiceConfig(hService, if (!QueryServiceConfigW(hService,
NULL, NULL,
0, 0,
&bytesNeeded) && &bytesNeeded) &&
GetLastError() == ERROR_INSUFFICIENT_BUFFER) GetLastError() == ERROR_INSUFFICIENT_BUFFER)
{ {
lpServiceConfig = HeapAlloc(ProcessHeap, lpServiceConfig = HeapAlloc(ProcessHeap,
@ -30,10 +30,10 @@ TV1_GetDependants(PSERVICEPROPSHEET pDlgInfo,
bytesNeeded); bytesNeeded);
if (lpServiceConfig) if (lpServiceConfig)
{ {
if (QueryServiceConfig(hService, if (QueryServiceConfigW(hService,
lpServiceConfig, lpServiceConfig,
bytesNeeded, bytesNeeded,
&bytesNeeded)) &bytesNeeded))
{ {
/* Does this service have any dependencies? */ /* Does this service have any dependencies? */
if (lpServiceConfig->lpDependencies && if (lpServiceConfig->lpDependencies &&
@ -43,7 +43,7 @@ TV1_GetDependants(PSERVICEPROPSHEET pDlgInfo,
bytes = 0; bytes = 0;
/* Work out how many bytes we need to hold the list */ /* Work out how many bytes we need to hold the list */
while (TRUE) for (;;)
{ {
bytes++; bytes++;
@ -57,7 +57,7 @@ TV1_GetDependants(PSERVICEPROPSHEET pDlgInfo,
} }
/* Allocate and copy the list */ /* Allocate and copy the list */
bytes *= sizeof(TCHAR); bytes *= sizeof(WCHAR);
lpStr = HeapAlloc(ProcessHeap, lpStr = HeapAlloc(ProcessHeap,
0, 0,
bytes); bytes);
@ -82,24 +82,24 @@ TV1_GetDependants(PSERVICEPROPSHEET pDlgInfo,
VOID VOID
TV1_AddDependantsToTree(PSERVICEPROPSHEET pDlgInfo, TV1_AddDependantsToTree(PSERVICEPROPSHEET pDlgInfo,
HTREEITEM hParent, HTREEITEM hParent,
LPTSTR lpServiceName) LPWSTR lpServiceName)
{ {
SC_HANDLE hSCManager; SC_HANDLE hSCManager;
SC_HANDLE hService; SC_HANDLE hService;
LPQUERY_SERVICE_CONFIG lpServiceConfig; LPQUERY_SERVICE_CONFIG lpServiceConfig;
LPTSTR lpDependants; LPWSTR lpDependants;
LPTSTR lpStr; LPWSTR lpStr;
LPTSTR lpNoDepends; LPWSTR lpNoDepends;
BOOL bHasChildren; BOOL bHasChildren;
hSCManager = OpenSCManager(NULL, hSCManager = OpenSCManagerW(NULL,
NULL, NULL,
SC_MANAGER_ALL_ACCESS); SC_MANAGER_ALL_ACCESS);
if (hSCManager) if (hSCManager)
{ {
hService = OpenService(hSCManager, hService = OpenServiceW(hSCManager,
lpServiceName, lpServiceName,
SERVICE_QUERY_STATUS | SERVICE_ENUMERATE_DEPENDENTS | SERVICE_QUERY_CONFIG); SERVICE_QUERY_STATUS | SERVICE_ENUMERATE_DEPENDENTS | SERVICE_QUERY_CONFIG);
if (hService) if (hService)
{ {
/* Get a list of service dependents */ /* Get a list of service dependents */
@ -179,7 +179,7 @@ TV1_AddDependantsToTree(PSERVICEPROPSHEET pDlgInfo,
BOOL BOOL
TV1_Initialize(PSERVICEPROPSHEET pDlgInfo, TV1_Initialize(PSERVICEPROPSHEET pDlgInfo,
LPTSTR lpServiceName) LPWSTR lpServiceName)
{ {
BOOL bRet = FALSE; BOOL bRet = FALSE;

View file

@ -120,11 +120,11 @@ TV2_GetDependants(LPWSTR lpServiceName,
VOID VOID
TV2_AddDependantsToTree(PSERVICEPROPSHEET pDlgInfo, TV2_AddDependantsToTree(PSERVICEPROPSHEET pDlgInfo,
HTREEITEM hParent, HTREEITEM hParent,
LPTSTR lpServiceName) LPWSTR lpServiceName)
{ {
LPENUM_SERVICE_STATUSW lpServiceStatus; LPENUM_SERVICE_STATUSW lpServiceStatus;
LPTSTR lpNoDepends; LPWSTR lpNoDepends;
DWORD count, i; DWORD count, i;
BOOL bHasChildren; BOOL bHasChildren;
@ -175,7 +175,7 @@ TV2_AddDependantsToTree(PSERVICEPROPSHEET pDlgInfo,
BOOL BOOL
TV2_Initialize(PSERVICEPROPSHEET pDlgInfo, TV2_Initialize(PSERVICEPROPSHEET pDlgInfo,
LPTSTR lpServiceName) LPWSTR lpServiceName)
{ {
BOOL bRet = FALSE; BOOL bRet = FALSE;

View file

@ -9,12 +9,12 @@
#include "precomp.h" #include "precomp.h"
#include <commdlg.h> //#include <commdlg.h>
#include <cderr.h> //#include <cderr.h>
static DWORD static DWORD
GetTextFromListView(PMAIN_WND_INFO Info, GetTextFromListView(PMAIN_WND_INFO Info,
TCHAR Text[500], LPWSTR Text,
INT row, INT row,
INT col) INT col)
{ {
@ -26,22 +26,21 @@ GetTextFromListView(PMAIN_WND_INFO Info,
item.iSubItem = col; item.iSubItem = col;
item.pszText = Text; item.pszText = Text;
item.cchTextMax = 500; item.cchTextMax = 500;
NumChars = (INT)SendMessage(Info->hListView, NumChars = (INT)SendMessageW(Info->hListView,
LVM_GETITEMTEXT, LVM_GETITEMTEXTW,
row, row,
(LPARAM)&item); (LPARAM)&item);
return NumChars; return NumChars;
} }
static BOOL static BOOL
SaveServicesToFile(PMAIN_WND_INFO Info, SaveServicesToFile(PMAIN_WND_INFO Info,
LPCTSTR pszFileName) LPCWSTR pszFileName)
{ {
HANDLE hFile; HANDLE hFile;
BOOL bSuccess = FALSE; BOOL bSuccess = FALSE;
hFile = CreateFile(pszFileName, hFile = CreateFileW(pszFileName,
GENERIC_WRITE, GENERIC_WRITE,
0, 0,
NULL, NULL,
@ -51,9 +50,9 @@ SaveServicesToFile(PMAIN_WND_INFO Info,
if(hFile != INVALID_HANDLE_VALUE) if(hFile != INVALID_HANDLE_VALUE)
{ {
TCHAR LVText[500]; WCHAR LVText[500];
TCHAR newl[2] = {_T('\r'), _T('\n')}; WCHAR newl[2] = {L'\r', L'\n'};
TCHAR tab = _T('\t'); WCHAR tab = L'\t';
DWORD dwTextLength, dwWritten; DWORD dwTextLength, dwWritten;
INT NumListedServ = 0; INT NumListedServ = 0;
INT i, k; INT i, k;
@ -72,13 +71,13 @@ SaveServicesToFile(PMAIN_WND_INFO Info,
{ {
WriteFile(hFile, WriteFile(hFile,
LVText, LVText,
sizeof(TCHAR) * dwTextLength, sizeof(WCHAR) * dwTextLength,
&dwWritten, &dwWritten,
NULL); NULL);
WriteFile(hFile, WriteFile(hFile,
&tab, &tab,
sizeof(TCHAR), sizeof(WCHAR),
&dwWritten, &dwWritten,
NULL); NULL);
} }
@ -99,17 +98,18 @@ SaveServicesToFile(PMAIN_WND_INFO Info,
VOID ExportFile(PMAIN_WND_INFO Info) VOID ExportFile(PMAIN_WND_INFO Info)
{ {
OPENFILENAME ofn; OPENFILENAMEW ofn;
TCHAR szFileName[MAX_PATH] = _T(""); WCHAR szFileName[MAX_PATH];
ZeroMemory(&ofn, sizeof(ofn)); ZeroMemory(&ofn, sizeof(ofn));
szFileName[0] = UNICODE_NULL;
ofn.lStructSize = sizeof(OPENFILENAME); ofn.lStructSize = sizeof(OPENFILENAME);
ofn.hwndOwner = Info->hMainWnd; ofn.hwndOwner = Info->hMainWnd;
ofn.lpstrFilter = _T("Text (Tab Delimited)(*.txt)\0*.txt\0Text (Comma Delimited)(*.csv)\0*.csv\0"); ofn.lpstrFilter = L"Text (Tab Delimited)(*.txt)\0*.txt\0Text (Comma Delimited)(*.csv)\0*.csv\0";
ofn.lpstrFile = szFileName; ofn.lpstrFile = szFileName;
ofn.nMaxFile = MAX_PATH; ofn.nMaxFile = MAX_PATH;
ofn.lpstrDefExt = _T("txt"); ofn.lpstrDefExt = L"txt";
ofn.Flags = OFN_EXPLORER | OFN_PATHMUSTEXIST | OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT; ofn.Flags = OFN_EXPLORER | OFN_PATHMUSTEXIST | OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT;
if(GetSaveFileName(&ofn)) if(GetSaveFileName(&ofn))
@ -119,5 +119,5 @@ VOID ExportFile(PMAIN_WND_INFO Info)
} }
if (CommDlgExtendedError() != CDERR_GENERALCODES) if (CommDlgExtendedError() != CDERR_GENERALCODES)
MessageBox(NULL, _T("Export to file failed"), NULL, 0); MessageBoxW(NULL, L"Export to file failed", NULL, 0);
} }

View file

@ -123,13 +123,13 @@ ChangeListViewText(PMAIN_WND_INFO Info,
case LVDESC: case LVDESC:
{ {
LPTSTR lpDescription; LPWSTR lpDescription;
lpDescription = GetServiceDescription(pService->lpServiceName); lpDescription = GetServiceDescription(pService->lpServiceName);
lvItem.pszText = lpDescription; lvItem.pszText = lpDescription;
SendMessage(Info->hListView, SendMessage(Info->hListView,
LVM_SETITEMTEXT, LVM_SETITEMTEXTW,
lvItem.iItem, lvItem.iItem,
(LPARAM) &lvItem); (LPARAM) &lvItem);
@ -141,14 +141,14 @@ ChangeListViewText(PMAIN_WND_INFO Info,
case LVSTATUS: case LVSTATUS:
{ {
TCHAR szStatus[64]; WCHAR szStatus[64];
if (pService->ServiceStatusProcess.dwCurrentState == SERVICE_RUNNING) if (pService->ServiceStatusProcess.dwCurrentState == SERVICE_RUNNING)
{ {
LoadString(hInstance, LoadStringW(hInstance,
IDS_SERVICES_STARTED, IDS_SERVICES_STARTED,
szStatus, szStatus,
sizeof(szStatus) / sizeof(TCHAR)); sizeof(szStatus) / sizeof(WCHAR));
} }
else else
{ {
@ -156,17 +156,17 @@ ChangeListViewText(PMAIN_WND_INFO Info,
} }
lvItem.pszText = szStatus; lvItem.pszText = szStatus;
SendMessage(Info->hListView, SendMessageW(Info->hListView,
LVM_SETITEMTEXT, LVM_SETITEMTEXT,
lvItem.iItem, lvItem.iItem,
(LPARAM) &lvItem); (LPARAM) &lvItem);
} }
break; break;
case LVSTARTUP: case LVSTARTUP:
{ {
LPQUERY_SERVICE_CONFIG lpServiceConfig; LPQUERY_SERVICE_CONFIGW lpServiceConfig;
LPTSTR lpStartup = NULL; LPWSTR lpStartup = NULL;
DWORD StringId = 0; DWORD StringId = 0;
lpServiceConfig = GetServiceConfig(pService->lpServiceName); lpServiceConfig = GetServiceConfig(pService->lpServiceName);
@ -187,10 +187,10 @@ ChangeListViewText(PMAIN_WND_INFO Info,
StringId); StringId);
lvItem.pszText = lpStartup; lvItem.pszText = lpStartup;
SendMessage(Info->hListView, SendMessageW(Info->hListView,
LVM_SETITEMTEXT, LVM_SETITEMTEXTW,
lvItem.iItem, lvItem.iItem,
(LPARAM)&lvItem); (LPARAM)&lvItem);
LocalFree(lpStartup); LocalFree(lpStartup);
HeapFree(ProcessHeap, HeapFree(ProcessHeap,
@ -207,10 +207,10 @@ ChangeListViewText(PMAIN_WND_INFO Info,
if (lpServiceConfig) if (lpServiceConfig)
{ {
lvItem.pszText = lpServiceConfig->lpServiceStartName; lvItem.pszText = lpServiceConfig->lpServiceStartName;
SendMessage(Info->hListView, SendMessageW(Info->hListView,
LVM_SETITEMTEXT, LVM_SETITEMTEXT,
lvItem.iItem, lvItem.iItem,
(LPARAM)&lvItem); (LPARAM)&lvItem);
HeapFree(ProcessHeap, HeapFree(ProcessHeap,
0, 0,
@ -226,7 +226,7 @@ BOOL
RefreshServiceList(PMAIN_WND_INFO Info) RefreshServiceList(PMAIN_WND_INFO Info)
{ {
ENUM_SERVICE_STATUS_PROCESS *pService; ENUM_SERVICE_STATUS_PROCESS *pService;
LVITEM lvItem; LVITEMW lvItem;
DWORD NumServices; DWORD NumServices;
DWORD Index; DWORD Index;
@ -246,7 +246,7 @@ RefreshServiceList(PMAIN_WND_INFO Info)
pService = &Info->pAllServices[Index]; pService = &Info->pAllServices[Index];
/* set the display name */ /* set the display name */
ZeroMemory(&lvItem, sizeof(LVITEM)); ZeroMemory(&lvItem, sizeof(LVITEMW));
lvItem.mask = LVIF_TEXT | LVIF_PARAM; lvItem.mask = LVIF_TEXT | LVIF_PARAM;
lvItem.pszText = pService->lpDisplayName; lvItem.pszText = pService->lpDisplayName;
@ -267,7 +267,7 @@ RefreshServiceList(PMAIN_WND_INFO Info)
} }
/* turn redraw flag on. */ /* turn redraw flag on. */
SendMessage (Info->hListView, SendMessageW(Info->hListView,
WM_SETREDRAW, WM_SETREDRAW,
TRUE, TRUE,
0); 0);
@ -288,12 +288,12 @@ InitListViewImage(PMAIN_WND_INFO Info)
1); 1);
if (hSmall) if (hSmall)
{ {
hSmIconItem = LoadImage(hInstance, hSmIconItem = LoadImageW(hInstance,
MAKEINTRESOURCE(IDI_SM_ICON), MAKEINTRESOURCE(IDI_SM_ICON),
IMAGE_ICON, IMAGE_ICON,
16, 16,
16, 16,
0); 0);
if (hSmIconItem) if (hSmIconItem)
{ {
ImageList_AddIcon(hSmall, ImageList_AddIcon(hSmall,
@ -313,12 +313,12 @@ InitListViewImage(PMAIN_WND_INFO Info)
1); 1);
if (hLarge) if (hLarge)
{ {
hLgIconItem = LoadImage(hInstance, hLgIconItem = LoadImageW(hInstance,
MAKEINTRESOURCE(IDI_SM_ICON), MAKEINTRESOURCE(IDI_SM_ICON),
IMAGE_ICON, IMAGE_ICON,
32, 32,
32, 32,
0); 0);
if (hLgIconItem) if (hLgIconItem)
{ {
ImageList_AddIcon(hLarge, ImageList_AddIcon(hLarge,
@ -334,25 +334,25 @@ InitListViewImage(PMAIN_WND_INFO Info)
BOOL BOOL
CreateListView(PMAIN_WND_INFO Info) CreateListView(PMAIN_WND_INFO Info)
{ {
LVCOLUMN lvc = { 0 }; LVCOLUMNW lvc = { 0 };
TCHAR szTemp[256]; WCHAR szTemp[256];
Info->hListView = CreateWindowEx(WS_EX_CLIENTEDGE, Info->hListView = CreateWindowExW(WS_EX_CLIENTEDGE,
WC_LISTVIEW, WC_LISTVIEWW,
NULL, NULL,
WS_CHILD | WS_VISIBLE | LVS_REPORT | WS_BORDER | WS_CHILD | WS_VISIBLE | LVS_REPORT | WS_BORDER |
LBS_NOTIFY | LVS_SORTASCENDING | LBS_NOREDRAW, LBS_NOTIFY | LVS_SORTASCENDING | LBS_NOREDRAW,
0, 0, 0, 0, 0, 0, 0, 0,
Info->hMainWnd, Info->hMainWnd,
(HMENU) IDC_SERVLIST, (HMENU) IDC_SERVLIST,
hInstance, hInstance,
NULL); NULL);
if (Info->hListView == NULL) if (Info->hListView == NULL)
{ {
MessageBox(Info->hMainWnd, MessageBoxW(Info->hMainWnd,
_T("Could not create List View."), L"Could not create List View.",
_T("Error"), L"Error",
MB_OK | MB_ICONERROR); MB_OK | MB_ICONERROR);
return FALSE; return FALSE;
} }
@ -366,10 +366,10 @@ CreateListView(PMAIN_WND_INFO Info)
/* name */ /* name */
lvc.iSubItem = LVNAME; lvc.iSubItem = LVNAME;
lvc.cx = 150; lvc.cx = 150;
LoadString(hInstance, LoadStringW(hInstance,
IDS_FIRSTCOLUMN, IDS_FIRSTCOLUMN,
szTemp, szTemp,
sizeof(szTemp) / sizeof(TCHAR)); sizeof(szTemp) / sizeof(WCHAR));
lvc.pszText = szTemp; lvc.pszText = szTemp;
(void)ListView_InsertColumn(Info->hListView, (void)ListView_InsertColumn(Info->hListView,
0, 0,
@ -378,10 +378,10 @@ CreateListView(PMAIN_WND_INFO Info)
/* description */ /* description */
lvc.iSubItem = LVDESC; lvc.iSubItem = LVDESC;
lvc.cx = 240; lvc.cx = 240;
LoadString(hInstance, LoadStringW(hInstance,
IDS_SECONDCOLUMN, IDS_SECONDCOLUMN,
szTemp, szTemp,
sizeof(szTemp) / sizeof(TCHAR)); sizeof(szTemp) / sizeof(WCHAR));
lvc.pszText = szTemp; lvc.pszText = szTemp;
(void)ListView_InsertColumn(Info->hListView, (void)ListView_InsertColumn(Info->hListView,
1, 1,
@ -390,10 +390,10 @@ CreateListView(PMAIN_WND_INFO Info)
/* status */ /* status */
lvc.iSubItem = LVSTATUS; lvc.iSubItem = LVSTATUS;
lvc.cx = 55; lvc.cx = 55;
LoadString(hInstance, LoadStringW(hInstance,
IDS_THIRDCOLUMN, IDS_THIRDCOLUMN,
szTemp, szTemp,
sizeof(szTemp) / sizeof(TCHAR)); sizeof(szTemp) / sizeof(WCHAR));
lvc.pszText = szTemp; lvc.pszText = szTemp;
(void)ListView_InsertColumn(Info->hListView, (void)ListView_InsertColumn(Info->hListView,
2, 2,
@ -402,10 +402,10 @@ CreateListView(PMAIN_WND_INFO Info)
/* startup type */ /* startup type */
lvc.iSubItem = LVSTARTUP; lvc.iSubItem = LVSTARTUP;
lvc.cx = 80; lvc.cx = 80;
LoadString(hInstance, LoadStringW(hInstance,
IDS_FOURTHCOLUMN, IDS_FOURTHCOLUMN,
szTemp, szTemp,
sizeof(szTemp) / sizeof(TCHAR)); sizeof(szTemp) / sizeof(WCHAR));
lvc.pszText = szTemp; lvc.pszText = szTemp;
(void)ListView_InsertColumn(Info->hListView, (void)ListView_InsertColumn(Info->hListView,
3, 3,
@ -414,10 +414,10 @@ CreateListView(PMAIN_WND_INFO Info)
/* logon as */ /* logon as */
lvc.iSubItem = LVLOGONAS; lvc.iSubItem = LVLOGONAS;
lvc.cx = 100; lvc.cx = 100;
LoadString(hInstance, LoadStringW(hInstance,
IDS_FITHCOLUMN, IDS_FITHCOLUMN,
szTemp, szTemp,
sizeof(szTemp) / sizeof(TCHAR)); sizeof(szTemp) / sizeof(WCHAR));
lvc.pszText = szTemp; lvc.pszText = szTemp;
(void)ListView_InsertColumn(Info->hListView, (void)ListView_InsertColumn(Info->hListView,
4, 4,

View file

@ -47,7 +47,7 @@ LengthOfStrResource(IN HINSTANCE hInst,
} }
INT INT
AllocAndLoadString(OUT LPTSTR *lpTarget, AllocAndLoadString(OUT LPWSTR *lpTarget,
IN HINSTANCE hInst, IN HINSTANCE hInst,
IN UINT uID) IN UINT uID)
{ {
@ -57,12 +57,12 @@ AllocAndLoadString(OUT LPTSTR *lpTarget,
uID); uID);
if (ln++ > 0) if (ln++ > 0)
{ {
(*lpTarget) = (LPTSTR)LocalAlloc(LMEM_FIXED, (*lpTarget) = (LPWSTR)LocalAlloc(LMEM_FIXED,
ln * sizeof(TCHAR)); ln * sizeof(WCHAR));
if ((*lpTarget) != NULL) if ((*lpTarget) != NULL)
{ {
INT Ret; INT Ret;
if (!(Ret = LoadString(hInst, uID, *lpTarget, ln))) if (!(Ret = LoadStringW(hInst, uID, *lpTarget, ln)))
{ {
LocalFree((HLOCAL)(*lpTarget)); LocalFree((HLOCAL)(*lpTarget));
} }
@ -75,11 +75,11 @@ AllocAndLoadString(OUT LPTSTR *lpTarget,
DWORD DWORD
LoadAndFormatString(IN HINSTANCE hInstance, LoadAndFormatString(IN HINSTANCE hInstance,
IN UINT uID, IN UINT uID,
OUT LPTSTR *lpTarget, OUT LPWSTR *lpTarget,
...) ...)
{ {
DWORD Ret = 0; DWORD Ret = 0;
LPTSTR lpFormat; LPWSTR lpFormat;
va_list lArgs; va_list lArgs;
if (AllocAndLoadString(&lpFormat, if (AllocAndLoadString(&lpFormat,
@ -89,13 +89,13 @@ LoadAndFormatString(IN HINSTANCE hInstance,
va_start(lArgs, lpTarget); va_start(lArgs, lpTarget);
/* let's use Format to format it because it has the ability to allocate /* let's use Format to format it because it has the ability to allocate
memory automatically */ memory automatically */
Ret = FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_STRING, Ret = FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_STRING,
lpFormat, lpFormat,
0, 0,
0, 0,
(LPTSTR)lpTarget, (LPWSTR)lpTarget,
0, 0,
&lArgs); &lArgs);
va_end(lArgs); va_end(lArgs);
LocalFree((HLOCAL)lpFormat); LocalFree((HLOCAL)lpFormat);
@ -112,7 +112,7 @@ StatusBarLoadAndFormatString(IN HWND hStatusBar,
...) ...)
{ {
BOOL Ret = FALSE; BOOL Ret = FALSE;
LPTSTR lpFormat, lpStr; LPWSTR lpFormat, lpStr;
va_list lArgs; va_list lArgs;
if (AllocAndLoadString(&lpFormat, if (AllocAndLoadString(&lpFormat,
@ -122,21 +122,21 @@ StatusBarLoadAndFormatString(IN HWND hStatusBar,
va_start(lArgs, uID); va_start(lArgs, uID);
/* let's use FormatMessage to format it because it has the ability to allocate /* let's use FormatMessage to format it because it has the ability to allocate
memory automatically */ memory automatically */
Ret = FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_STRING, Ret = FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_STRING,
lpFormat, lpFormat,
0, 0,
0, 0,
(VOID*)&lpStr, (VOID*)&lpStr,
0, 0,
&lArgs); &lArgs);
va_end(lArgs); va_end(lArgs);
if (lpStr != NULL) if (lpStr != NULL)
{ {
Ret = (BOOL)SendMessage(hStatusBar, Ret = (BOOL)SendMessageW(hStatusBar,
SB_SETTEXT, SB_SETTEXT,
(WPARAM)PartId, (WPARAM)PartId,
(LPARAM)lpStr); (LPARAM)lpStr);
LocalFree((HLOCAL)lpStr); LocalFree((HLOCAL)lpStr);
} }
@ -153,16 +153,16 @@ StatusBarLoadString(IN HWND hStatusBar,
IN UINT uID) IN UINT uID)
{ {
BOOL Ret = FALSE; BOOL Ret = FALSE;
LPTSTR lpStr; LPWSTR lpStr;
if (AllocAndLoadString(&lpStr, if (AllocAndLoadString(&lpStr,
hInstance, hInstance,
uID) > 0) uID) > 0)
{ {
Ret = (BOOL)SendMessage(hStatusBar, Ret = (BOOL)SendMessageW(hStatusBar,
SB_SETTEXT, SB_SETTEXT,
(WPARAM)PartId, (WPARAM)PartId,
(LPARAM)lpStr); (LPARAM)lpStr);
LocalFree((HLOCAL)lpStr); LocalFree((HLOCAL)lpStr);
} }
@ -171,17 +171,17 @@ StatusBarLoadString(IN HWND hStatusBar,
INT INT
GetTextFromEdit(OUT LPTSTR lpString, GetTextFromEdit(OUT LPWSTR lpString,
IN HWND hDlg, IN HWND hDlg,
IN UINT Res) IN UINT Res)
{ {
INT len = GetWindowTextLength(GetDlgItem(hDlg, Res)); INT len = GetWindowTextLengthW(GetDlgItem(hDlg, Res));
if(len > 0) if(len > 0)
{ {
GetDlgItemText(hDlg, GetDlgItemTextW(hDlg,
Res, Res,
lpString, lpString,
len + 1); len + 1);
} }
else else
lpString = NULL; lpString = NULL;
@ -191,26 +191,26 @@ GetTextFromEdit(OUT LPTSTR lpString,
VOID GetError(VOID) VOID GetError(VOID)
{ {
LPTSTR lpMsgBuf = NULL; LPWSTR lpMsgBuf = NULL;
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS, FORMAT_MESSAGE_IGNORE_INSERTS,
NULL, NULL,
GetLastError(), GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(VOID*)&lpMsgBuf, (VOID*)&lpMsgBuf,
0, 0,
NULL ); NULL );
MessageBox(NULL, lpMsgBuf, _T("Error!"), MB_OK | MB_ICONERROR); MessageBoxW(NULL, lpMsgBuf, L"Error!", MB_OK | MB_ICONERROR);
LocalFree(lpMsgBuf); LocalFree(lpMsgBuf);
} }
VOID DisplayString(PTCHAR Msg) VOID DisplayString(LPWSTR Msg)
{ {
MessageBox(NULL, Msg, _T("Note!"), MB_ICONEXCLAMATION|MB_OK); MessageBoxW(NULL, Msg, L"Note!", MB_ICONEXCLAMATION|MB_OK);
} }
@ -239,12 +239,12 @@ InitImageList(UINT StartResource,
ret = 0; ret = 0;
for (i = StartResource; i <= EndResource && ret != -1; i++) for (i = StartResource; i <= EndResource && ret != -1; i++)
{ {
hImage = LoadImage(hInstance, hImage = LoadImageW(hInstance,
MAKEINTRESOURCE(i), MAKEINTRESOURCEW(i),
type, type,
Width, Width,
Height, Height,
LR_LOADTRANSPARENT); LR_LOADTRANSPARENT);
if (hImage == NULL) if (hImage == NULL)
{ {
ImageList_Destroy(himl); ImageList_Destroy(himl);

View file

@ -12,14 +12,14 @@
HTREEITEM HTREEITEM
AddItemToTreeView(HWND hTreeView, AddItemToTreeView(HWND hTreeView,
HTREEITEM hParent, HTREEITEM hParent,
LPTSTR lpDisplayName, LPWSTR lpDisplayName,
LPTSTR lpServiceName, LPWSTR lpServiceName,
ULONG ServiceType, ULONG ServiceType,
BOOL bHasChildren) BOOL bHasChildren)
{ {
TV_ITEM tvi; TV_ITEM tvi;
TV_INSERTSTRUCT tvins; TV_INSERTSTRUCT tvins;
LPTSTR lpName; LPWSTR lpName;
DWORD dwSize; DWORD dwSize;
ZeroMemory(&tvi, sizeof(tvi)); ZeroMemory(&tvi, sizeof(tvi));
@ -27,7 +27,7 @@ AddItemToTreeView(HWND hTreeView,
tvi.mask = TVIF_TEXT | TVIF_PARAM | TVIF_SELECTEDIMAGE | TVIF_IMAGE | TVIF_CHILDREN; tvi.mask = TVIF_TEXT | TVIF_PARAM | TVIF_SELECTEDIMAGE | TVIF_IMAGE | TVIF_CHILDREN;
tvi.pszText = lpDisplayName; tvi.pszText = lpDisplayName;
tvi.cchTextMax = _tcslen(lpDisplayName); tvi.cchTextMax = wcslen(lpDisplayName);
tvi.cChildren = bHasChildren; tvi.cChildren = bHasChildren;
/* Select the image for this service */ /* Select the image for this service */
@ -53,14 +53,14 @@ AddItemToTreeView(HWND hTreeView,
if (lpServiceName) if (lpServiceName)
{ {
dwSize = _tcslen(lpServiceName) + 1; dwSize = wcslen(lpServiceName) + 1;
/* Attach the service name */ /* Attach the service name */
lpName = (LPTSTR)HeapAlloc(GetProcessHeap(), lpName = (LPWSTR)HeapAlloc(GetProcessHeap(),
0, 0,
dwSize * sizeof(TCHAR)); dwSize * sizeof(WCHAR));
if (lpName) if (lpName)
{ {
StringCchCopy(lpName, dwSize, lpServiceName); StringCchCopyW(lpName, dwSize, lpServiceName);
tvi.lParam = (LPARAM)lpName; tvi.lParam = (LPARAM)lpName;
} }
} }
@ -76,7 +76,7 @@ TreeView_GetItemParam(HWND hTreeView,
HTREEITEM hItem) HTREEITEM hItem)
{ {
LPARAM lParam = 0; LPARAM lParam = 0;
TVITEM tv = {0}; TVITEMW tv = {0};
tv.mask = TVIF_PARAM | TVIF_HANDLE; tv.mask = TVIF_PARAM | TVIF_HANDLE;
tv.hItem = hItem; tv.hItem = hItem;
@ -94,7 +94,7 @@ DestroyItem(HWND hTreeView,
HTREEITEM hItem) HTREEITEM hItem)
{ {
HTREEITEM hChildItem; HTREEITEM hChildItem;
LPTSTR lpServiceName; LPWSTR lpServiceName;
/* Does this item have any children */ /* Does this item have any children */
hChildItem = TreeView_GetChild(hTreeView, hItem); hChildItem = TreeView_GetChild(hTreeView, hItem);
@ -105,7 +105,7 @@ DestroyItem(HWND hTreeView,
} }
/* Get the string and free it */ /* Get the string and free it */
lpServiceName = (LPTSTR)TreeView_GetItemParam(hTreeView, hItem); lpServiceName = (LPWSTR)TreeView_GetItemParam(hTreeView, hItem);
if (lpServiceName) if (lpServiceName)
{ {
HeapFree(GetProcessHeap(), HeapFree(GetProcessHeap(),
@ -229,7 +229,7 @@ DependenciesPageProc(HWND hwndDlg,
if (!TreeView_GetChild(pDlgInfo->hDependsTreeView1, lpnmtv->itemNew.hItem)) if (!TreeView_GetChild(pDlgInfo->hDependsTreeView1, lpnmtv->itemNew.hItem))
{ {
/* It's not, add the children */ /* It's not, add the children */
TV1_AddDependantsToTree(pDlgInfo, lpnmtv->itemNew.hItem, (LPTSTR)lpnmtv->itemNew.lParam); TV1_AddDependantsToTree(pDlgInfo, lpnmtv->itemNew.hItem, (LPWSTR)lpnmtv->itemNew.lParam);
} }
} }
else if (lpnmtv->hdr.idFrom == IDC_DEPEND_TREE2) else if (lpnmtv->hdr.idFrom == IDC_DEPEND_TREE2)
@ -238,7 +238,7 @@ DependenciesPageProc(HWND hwndDlg,
if (!TreeView_GetChild(pDlgInfo->hDependsTreeView2, lpnmtv->itemNew.hItem)) if (!TreeView_GetChild(pDlgInfo->hDependsTreeView2, lpnmtv->itemNew.hItem))
{ {
/* It's not, add the children */ /* It's not, add the children */
TV2_AddDependantsToTree(pDlgInfo, lpnmtv->itemNew.hItem, (LPTSTR)lpnmtv->itemNew.lParam); TV2_AddDependantsToTree(pDlgInfo, lpnmtv->itemNew.hItem, (LPWSTR)lpnmtv->itemNew.lParam);
} }
} }
} }

View file

@ -59,7 +59,7 @@ static VOID
SetServiceStatusText(PSERVICEPROPSHEET dlgInfo, SetServiceStatusText(PSERVICEPROPSHEET dlgInfo,
HWND hwndDlg) HWND hwndDlg)
{ {
LPTSTR lpStatus; LPWSTR lpStatus;
UINT id; UINT id;
if (dlgInfo->pService->ServiceStatusProcess.dwCurrentState == SERVICE_RUNNING) if (dlgInfo->pService->ServiceStatusProcess.dwCurrentState == SERVICE_RUNNING)
@ -75,11 +75,11 @@ SetServiceStatusText(PSERVICEPROPSHEET dlgInfo,
hInstance, hInstance,
id)) id))
{ {
SendDlgItemMessage(hwndDlg, SendDlgItemMessageW(hwndDlg,
IDC_SERV_STATUS, IDC_SERV_STATUS,
WM_SETTEXT, WM_SETTEXT,
0, 0,
(LPARAM)lpStatus); (LPARAM)lpStatus);
LocalFree(lpStatus); LocalFree(lpStatus);
} }
} }
@ -89,12 +89,12 @@ SetServiceStatusText(PSERVICEPROPSHEET dlgInfo,
* values and sets it to value of the selected item * values and sets it to value of the selected item
*/ */
static VOID static VOID
SetStartupType(LPTSTR lpServiceName, SetStartupType(LPWSTR lpServiceName,
HWND hwndDlg) HWND hwndDlg)
{ {
HWND hList; HWND hList;
LPQUERY_SERVICE_CONFIG pServiceConfig; LPQUERY_SERVICE_CONFIG pServiceConfig;
LPTSTR lpBuf; LPWSTR lpBuf;
DWORD StartUp = 0; DWORD StartUp = 0;
UINT i; UINT i;
@ -106,10 +106,10 @@ SetStartupType(LPTSTR lpServiceName,
hInstance, hInstance,
i)) i))
{ {
SendMessage(hList, SendMessageW(hList,
CB_ADDSTRING, CB_ADDSTRING,
0, 0,
(LPARAM)lpBuf); (LPARAM)lpBuf);
LocalFree(lpBuf); LocalFree(lpBuf);
} }
} }
@ -125,10 +125,10 @@ SetStartupType(LPTSTR lpServiceName,
case SERVICE_DISABLED: StartUp = 2; break; case SERVICE_DISABLED: StartUp = 2; break;
} }
SendMessage(hList, SendMessageW(hList,
CB_SETCURSEL, CB_SETCURSEL,
StartUp, StartUp,
0); 0);
HeapFree(ProcessHeap, HeapFree(ProcessHeap,
0, 0,
@ -145,30 +145,30 @@ InitGeneralPage(PSERVICEPROPSHEET dlgInfo,
HWND hwndDlg) HWND hwndDlg)
{ {
LPQUERY_SERVICE_CONFIG pServiceConfig; LPQUERY_SERVICE_CONFIG pServiceConfig;
LPTSTR lpDescription; LPWSTR lpDescription;
/* set the service name */ /* set the service name */
SendDlgItemMessage(hwndDlg, SendDlgItemMessageW(hwndDlg,
IDC_SERV_NAME, IDC_SERV_NAME,
WM_SETTEXT, WM_SETTEXT,
0, 0,
(LPARAM)dlgInfo->pService->lpServiceName); (LPARAM)dlgInfo->pService->lpServiceName);
/* set the display name */ /* set the display name */
SendDlgItemMessage(hwndDlg, SendDlgItemMessageW(hwndDlg,
IDC_DISP_NAME, IDC_DISP_NAME,
WM_SETTEXT, WM_SETTEXT,
0, 0,
(LPARAM)dlgInfo->pService->lpDisplayName); (LPARAM)dlgInfo->pService->lpDisplayName);
/* set the description */ /* set the description */
if ((lpDescription = GetServiceDescription(dlgInfo->pService->lpServiceName))) if ((lpDescription = GetServiceDescription(dlgInfo->pService->lpServiceName)))
{ {
SendDlgItemMessage(hwndDlg, SendDlgItemMessageW(hwndDlg,
IDC_DESCRIPTION, IDC_DESCRIPTION,
WM_SETTEXT, WM_SETTEXT,
0, 0,
(LPARAM)lpDescription); (LPARAM)lpDescription);
HeapFree(ProcessHeap, HeapFree(ProcessHeap,
0, 0,
@ -178,11 +178,11 @@ InitGeneralPage(PSERVICEPROPSHEET dlgInfo,
pServiceConfig = GetServiceConfig(dlgInfo->pService->lpServiceName); pServiceConfig = GetServiceConfig(dlgInfo->pService->lpServiceName);
if (pServiceConfig) if (pServiceConfig)
{ {
SendDlgItemMessage(hwndDlg, SendDlgItemMessageW(hwndDlg,
IDC_EXEPATH, IDC_EXEPATH,
WM_SETTEXT, WM_SETTEXT,
0, 0,
(LPARAM)pServiceConfig->lpBinaryPathName); (LPARAM)pServiceConfig->lpBinaryPathName);
HeapFree(ProcessHeap, HeapFree(ProcessHeap,
0, 0,
pServiceConfig); pServiceConfig);
@ -258,7 +258,7 @@ OnStart(HWND hwndDlg,
if (GetDlgItemText(hwndDlg, IDC_START_PARAM, szStartParams, 256) > 0) if (GetDlgItemText(hwndDlg, IDC_START_PARAM, szStartParams, 256) > 0)
lpStartParams = szStartParams; lpStartParams = szStartParams;
if (DoStart(dlgInfo->Info, lpStartParams)) //if (DoStart(dlgInfo->Info, lpStartParams))
{ {
UpdateServiceStatus(dlgInfo->pService); UpdateServiceStatus(dlgInfo->pService);
ChangeListViewText(dlgInfo->Info, dlgInfo->pService, LVSTATUS); ChangeListViewText(dlgInfo->Info, dlgInfo->pService, LVSTATUS);
@ -312,37 +312,51 @@ GeneralPageProc(HWND hwndDlg,
break; break;
case IDC_START: case IDC_START:
OnStart(hwndDlg, dlgInfo); RunActionWithProgress(hwndDlg,
dlgInfo->pService->lpServiceName,
dlgInfo->pService->lpDisplayName,
ACTION_START);
UpdateServiceStatus(dlgInfo->pService);
ChangeListViewText(dlgInfo->Info, dlgInfo->pService, LVSTATUS);
SetButtonStates(dlgInfo, hwndDlg);
SetServiceStatusText(dlgInfo, hwndDlg);
break; break;
case IDC_STOP: case IDC_STOP:
if (DoStop(dlgInfo->Info)) RunActionWithProgress(hwndDlg,
{ dlgInfo->pService->lpServiceName,
UpdateServiceStatus(dlgInfo->pService); dlgInfo->pService->lpDisplayName,
ChangeListViewText(dlgInfo->Info, dlgInfo->pService, LVSTATUS); ACTION_STOP);
SetButtonStates(dlgInfo, hwndDlg);
SetServiceStatusText(dlgInfo, hwndDlg); UpdateServiceStatus(dlgInfo->pService);
} ChangeListViewText(dlgInfo->Info, dlgInfo->pService, LVSTATUS);
SetButtonStates(dlgInfo, hwndDlg);
SetServiceStatusText(dlgInfo, hwndDlg);
break; break;
case IDC_PAUSE: case IDC_PAUSE:
if (DoPause(dlgInfo->Info)) RunActionWithProgress(hwndDlg,
{ dlgInfo->pService->lpServiceName,
UpdateServiceStatus(dlgInfo->pService); dlgInfo->pService->lpDisplayName,
ChangeListViewText(dlgInfo->Info, dlgInfo->pService, LVSTATUS); ACTION_PAUSE);
SetButtonStates(dlgInfo, hwndDlg);
SetServiceStatusText(dlgInfo, hwndDlg); UpdateServiceStatus(dlgInfo->pService);
} ChangeListViewText(dlgInfo->Info, dlgInfo->pService, LVSTATUS);
SetButtonStates(dlgInfo, hwndDlg);
SetServiceStatusText(dlgInfo, hwndDlg);
break; break;
case IDC_RESUME: case IDC_RESUME:
if (DoResume(dlgInfo->Info)) RunActionWithProgress(hwndDlg,
{ dlgInfo->pService->lpServiceName,
UpdateServiceStatus(dlgInfo->pService); dlgInfo->pService->lpDisplayName,
ChangeListViewText(dlgInfo->Info, dlgInfo->pService, LVSTATUS); ACTION_RESUME);
SetButtonStates(dlgInfo, hwndDlg);
SetServiceStatusText(dlgInfo, hwndDlg); UpdateServiceStatus(dlgInfo->pService);
} ChangeListViewText(dlgInfo->Info, dlgInfo->pService, LVSTATUS);
SetButtonStates(dlgInfo, hwndDlg);
SetServiceStatusText(dlgInfo, hwndDlg);
break; break;
case IDC_EDIT: case IDC_EDIT:

View file

@ -26,27 +26,27 @@ GetSelectedService(PMAIN_WND_INFO Info)
} }
LPQUERY_SERVICE_CONFIG LPQUERY_SERVICE_CONFIG
GetServiceConfig(LPTSTR lpServiceName) GetServiceConfig(LPWSTR lpServiceName)
{ {
LPQUERY_SERVICE_CONFIG lpServiceConfig = NULL; LPQUERY_SERVICE_CONFIGW lpServiceConfig = NULL;
SC_HANDLE hSCManager; SC_HANDLE hSCManager;
SC_HANDLE hService; SC_HANDLE hService;
DWORD dwBytesNeeded; DWORD dwBytesNeeded;
hSCManager = OpenSCManager(NULL, hSCManager = OpenSCManagerW(NULL,
NULL, NULL,
SC_MANAGER_ALL_ACCESS); SC_MANAGER_ALL_ACCESS);
if (hSCManager) if (hSCManager)
{ {
hService = OpenService(hSCManager, hService = OpenServiceW(hSCManager,
lpServiceName, lpServiceName,
SERVICE_QUERY_STATUS | SERVICE_ENUMERATE_DEPENDENTS | SERVICE_QUERY_CONFIG); SERVICE_QUERY_STATUS | SERVICE_ENUMERATE_DEPENDENTS | SERVICE_QUERY_CONFIG);
if (hService) if (hService)
{ {
if (!QueryServiceConfig(hService, if (!QueryServiceConfigW(hService,
NULL, NULL,
0, 0,
&dwBytesNeeded)) &dwBytesNeeded))
{ {
if (GetLastError() == ERROR_INSUFFICIENT_BUFFER) if (GetLastError() == ERROR_INSUFFICIENT_BUFFER)
{ {
@ -55,7 +55,7 @@ GetServiceConfig(LPTSTR lpServiceName)
dwBytesNeeded); dwBytesNeeded);
if (lpServiceConfig) if (lpServiceConfig)
{ {
if (!QueryServiceConfig(hService, if (!QueryServiceConfigW(hService,
lpServiceConfig, lpServiceConfig,
dwBytesNeeded, dwBytesNeeded,
&dwBytesNeeded)) &dwBytesNeeded))
@ -80,38 +80,38 @@ GetServiceConfig(LPTSTR lpServiceName)
BOOL BOOL
SetServiceConfig(LPQUERY_SERVICE_CONFIG pServiceConfig, SetServiceConfig(LPQUERY_SERVICE_CONFIG pServiceConfig,
LPTSTR lpServiceName, LPWSTR lpServiceName,
LPTSTR lpPassword) LPWSTR lpPassword)
{ {
SC_HANDLE hSCManager; SC_HANDLE hSCManager;
SC_HANDLE hSc; SC_HANDLE hSc;
SC_LOCK scLock; SC_LOCK scLock;
BOOL bRet = FALSE; BOOL bRet = FALSE;
hSCManager = OpenSCManager(NULL, hSCManager = OpenSCManagerW(NULL,
NULL, NULL,
SC_MANAGER_LOCK); SC_MANAGER_LOCK);
if (hSCManager) if (hSCManager)
{ {
scLock = LockServiceDatabase(hSCManager); scLock = LockServiceDatabase(hSCManager);
if (scLock) if (scLock)
{ {
hSc = OpenService(hSCManager, hSc = OpenServiceW(hSCManager,
lpServiceName, lpServiceName,
SERVICE_CHANGE_CONFIG); SERVICE_CHANGE_CONFIG);
if (hSc) if (hSc)
{ {
if (ChangeServiceConfig(hSc, if (ChangeServiceConfigW(hSc,
pServiceConfig->dwServiceType, pServiceConfig->dwServiceType,
pServiceConfig->dwStartType, pServiceConfig->dwStartType,
pServiceConfig->dwErrorControl, pServiceConfig->dwErrorControl,
pServiceConfig->lpBinaryPathName, pServiceConfig->lpBinaryPathName,
pServiceConfig->lpLoadOrderGroup, pServiceConfig->lpLoadOrderGroup,
pServiceConfig->dwTagId ? &pServiceConfig->dwTagId : NULL, pServiceConfig->dwTagId ? &pServiceConfig->dwTagId : NULL,
pServiceConfig->lpDependencies, pServiceConfig->lpDependencies,
pServiceConfig->lpServiceStartName, pServiceConfig->lpServiceStartName,
lpPassword, lpPassword,
pServiceConfig->lpDisplayName)) pServiceConfig->lpDisplayName))
{ {
bRet = TRUE; bRet = TRUE;
} }
@ -131,35 +131,35 @@ SetServiceConfig(LPQUERY_SERVICE_CONFIG pServiceConfig,
return bRet; return bRet;
} }
LPTSTR LPWSTR
GetServiceDescription(LPTSTR lpServiceName) GetServiceDescription(LPWSTR lpServiceName)
{ {
SC_HANDLE hSCManager = NULL; SC_HANDLE hSCManager = NULL;
SC_HANDLE hSc = NULL; SC_HANDLE hSc = NULL;
SERVICE_DESCRIPTION *pServiceDescription = NULL; SERVICE_DESCRIPTIONW *pServiceDescription = NULL;
LPTSTR lpDescription = NULL; LPWSTR lpDescription = NULL;
DWORD BytesNeeded = 0; DWORD BytesNeeded = 0;
DWORD dwSize; DWORD dwSize;
hSCManager = OpenSCManager(NULL, hSCManager = OpenSCManagerW(NULL,
NULL, NULL,
SC_MANAGER_ENUMERATE_SERVICE); SC_MANAGER_ENUMERATE_SERVICE);
if (hSCManager == NULL) if (hSCManager == NULL)
{ {
GetError(); GetError();
return NULL; return NULL;
} }
hSc = OpenService(hSCManager, hSc = OpenServiceW(hSCManager,
lpServiceName, lpServiceName,
SERVICE_QUERY_CONFIG); SERVICE_QUERY_CONFIG);
if (hSc) if (hSc)
{ {
if (!QueryServiceConfig2(hSc, if (!QueryServiceConfig2W(hSc,
SERVICE_CONFIG_DESCRIPTION, SERVICE_CONFIG_DESCRIPTION,
NULL, NULL,
0, 0,
&BytesNeeded)) &BytesNeeded))
{ {
if (GetLastError() == ERROR_INSUFFICIENT_BUFFER) if (GetLastError() == ERROR_INSUFFICIENT_BUFFER)
{ {
@ -169,23 +169,23 @@ GetServiceDescription(LPTSTR lpServiceName)
if (pServiceDescription == NULL) if (pServiceDescription == NULL)
goto cleanup; goto cleanup;
if (QueryServiceConfig2(hSc, if (QueryServiceConfig2W(hSc,
SERVICE_CONFIG_DESCRIPTION, SERVICE_CONFIG_DESCRIPTION,
(LPBYTE)pServiceDescription, (LPBYTE)pServiceDescription,
BytesNeeded, BytesNeeded,
&BytesNeeded)) &BytesNeeded))
{ {
if (pServiceDescription->lpDescription) if (pServiceDescription->lpDescription)
{ {
dwSize = _tcslen(pServiceDescription->lpDescription) + 1; dwSize = wcslen(pServiceDescription->lpDescription) + 1;
lpDescription = HeapAlloc(ProcessHeap, lpDescription = HeapAlloc(ProcessHeap,
0, 0,
dwSize * sizeof(TCHAR)); dwSize * sizeof(WCHAR));
if (lpDescription) if (lpDescription)
{ {
StringCchCopy(lpDescription, StringCchCopyW(lpDescription,
dwSize, dwSize,
pServiceDescription->lpDescription); pServiceDescription->lpDescription);
} }
} }
} }
@ -207,8 +207,8 @@ cleanup:
} }
BOOL BOOL
SetServiceDescription(LPTSTR lpServiceName, SetServiceDescription(LPWSTR lpServiceName,
LPTSTR lpDescription) LPWSTR lpDescription)
{ {
SC_HANDLE hSCManager; SC_HANDLE hSCManager;
SC_HANDLE hSc; SC_HANDLE hSc;
@ -216,24 +216,24 @@ SetServiceDescription(LPTSTR lpServiceName,
SERVICE_DESCRIPTION ServiceDescription; SERVICE_DESCRIPTION ServiceDescription;
BOOL bRet = FALSE; BOOL bRet = FALSE;
hSCManager = OpenSCManager(NULL, hSCManager = OpenSCManagerW(NULL,
NULL, NULL,
SC_MANAGER_LOCK); SC_MANAGER_LOCK);
if (hSCManager) if (hSCManager)
{ {
scLock = LockServiceDatabase(hSCManager); scLock = LockServiceDatabase(hSCManager);
if (scLock) if (scLock)
{ {
hSc = OpenService(hSCManager, hSc = OpenServiceW(hSCManager,
lpServiceName, lpServiceName,
SERVICE_CHANGE_CONFIG); SERVICE_CHANGE_CONFIG);
if (hSc) if (hSc)
{ {
ServiceDescription.lpDescription = lpDescription; ServiceDescription.lpDescription = lpDescription;
if (ChangeServiceConfig2(hSc, if (ChangeServiceConfig2W(hSc,
SERVICE_CONFIG_DESCRIPTION, SERVICE_CONFIG_DESCRIPTION,
&ServiceDescription)) &ServiceDescription))
{ {
bRet = TRUE; bRet = TRUE;
} }

View file

@ -13,29 +13,30 @@
HINSTANCE hInstance; HINSTANCE hInstance;
HANDLE ProcessHeap; HANDLE ProcessHeap;
HWND g_hProgDlg;
int WINAPI int WINAPI
_tWinMain(HINSTANCE hThisInstance, wWinMain(HINSTANCE hThisInstance,
HINSTANCE hPrevInstance, HINSTANCE hPrevInstance,
LPTSTR lpCmdLine, LPWSTR lpCmdLine,
int nCmdShow) int nCmdShow)
{ {
LPTSTR lpAppName; LPWSTR lpAppName;
HWND hMainWnd; HWND hMainWnd;
MSG Msg; MSG Msg;
int Ret = 1; int Ret = 1;
INITCOMMONCONTROLSEX icex; INITCOMMONCONTROLSEX icex;
switch (GetUserDefaultUILanguage()) switch (GetUserDefaultUILanguage())
{ {
case MAKELANGID(LANG_HEBREW, SUBLANG_DEFAULT): case MAKELANGID(LANG_HEBREW, SUBLANG_DEFAULT):
SetProcessDefaultLayout(LAYOUT_RTL); SetProcessDefaultLayout(LAYOUT_RTL);
break; break;
default:
break;
}
default:
break;
}
hInstance = hThisInstance; hInstance = hThisInstance;
ProcessHeap = GetProcessHeap(); ProcessHeap = GetProcessHeap();
@ -57,13 +58,14 @@ _tWinMain(HINSTANCE hThisInstance,
if (hMainWnd != NULL) if (hMainWnd != NULL)
{ {
/* pump the message queue */ /* pump the message queue */
while( GetMessage( &Msg, NULL, 0, 0 ) ) while (GetMessageW( &Msg, NULL, 0, 0 ) )
{ {
//if ( !hProgDlg || !IsWindow(hProgDlg) || !IsDialogMessage(hProgDlg, &Msg) ) //if ( !hProgDlg || !IsWindow(hProgDlg) || !IsDialogMessage(hProgDlg, &Msg) )
//{ //if (!IsDialogMessage(g_hProgDlg, &Msg))
{
TranslateMessage(&Msg); TranslateMessage(&Msg);
DispatchMessage(&Msg); DispatchMessageW(&Msg);
//} }
} }
Ret = 0; Ret = 0;