 |
卢志渊的意见:
void WriteDataFile(CString strFileName)
{
char filename[MAX_PATH] = "\\\\10.213.44.1\\C$\\Data\\";
strcat(filename,strFileName);
ExeCommand("net use \\\\10.213.44.1 /user:admin sysuser");
CFile file(filename,CFile::modeCreate|CFile::modeWrite|CFile::typeBinary );
file.Write(yourdata,sizeof(yourdata);
file.Close();
ExeCommand("net use /delete \\\\10.213.44.1");
}
BOOL ExeCommand(CString strCmdLine)
{
PROCESS_INFORMATION stProcInfo;
ZeroMemory(&stProcInfo,sizeof(PROCESS_INFORMATION));
STARTUPINFO startup;
ZeroMemory(&startup, sizeof(startup));
startup.cb = sizeof(startup);
startup.dwFlags = STARTF_USESHOWWINDOW;
startup.wShowWindow = SW_HIDE;
if (::CreateProcess(NULL,
(LPTSTR)(LPCTSTR)strCmdLine,
NULL,
NULL,
FALSE,
0,
NULL,
NULL,
&startup,
&stProcInfo)
)
{
if (stProcInfo.hProcess)
{
::CloseHandle(stProcInfo.hThread);
}
WaitForSingleObject(stProcInfo.hProcess,INFINITE);
::CloseHandle(stProcInfo.hProcess);
return TRUE;
}
return FALSE;
}
此问题由卢志渊等回答。
附加关键字:编程, 源程序, programming, source code, C/C++, MFC, C++ Builder, Borland C++, Turbo C, C, BCB, 网络与通信, network, communicate, com, com1, com2。
|