如何实现远程推送安装? ( 积分: 100 )

  • 主题发起人 主题发起人 ww990
  • 开始时间 开始时间
W

ww990

Unregistered / Unconfirmed
GUEST, unregistred user!
远程推送安装的原理是什么,如何实现?
 
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到远程主机成功");
}

 
接受答案了.
 
后退
顶部