void CClientDlg::InstallService(TCHAR *lpHost)
{
SC_HANDLE schSCManager;
SC_HANDLE schService;
TCHAR lpCurrentPath[MAX_PATH];
TCHAR lpImagePath[MAX_PATH];
TCHAR *lpHostName;
DWORD dwErrorCode;
SERVICE_STATUS InstallServiceStatus;
if(lpHost==NULL)
{
GetSystemDirectory(lpImagePath,MAX_PATH);
strcat(lpImagePath,_T("//SERVICE.exe"
);
lpHostName=NULL;
}
else
{
sprintf(lpImagePath,_T("////%s//Admin$//system32//SERVICE.exe"
,lpHost);
lpHostName=(TCHAR *)malloc(256);
sprintf(lpHostName,_T("////%s"
,lpHost);
}
printf("Transmitting File ... "
;
// hSearch=FindFirstFile(lpImagePath,&FileData);
//if(hSearch==INVALID_HANDLE_VALUE)
GetCurrentDirectory(MAX_PATH,lpCurrentPath);
strcat(lpCurrentPath,_T("//SERVICE.exe"
);
if(CopyFile(lpCurrentPath,lpImagePath,TRUE)==0)
{
dwErrorCode=GetLastError();
if(dwErrorCode==5)
{
printf("Failure ... Access is Denied !/n"
;
}
else
{
printf("Failure !/n"
;
}
return;
}
else
{
MessageBox("复制SERVER到远程主机成功"
;
}