0

I need to have my unmanaged VC++ program able to copy a file from the computer the application is on to one of 100 other computers.

I have administrator access on each computer, so that won't be a problem.

It seems I need to use WMI to do this, but I am having a hard time getting it to work properly by looking at examples in: http://msdn.microsoft.com/en-us/library/windows/desktop/aa394558(v=vs.85).aspx

I am curious of the CopyFile family of functions should work:

http://msdn.microsoft.com/en-us/library/windows/desktop/aa363851(v=vs.85).aspx

This is a console application that doesn't use MFC and isn't using ATL.

Is there a good example of how to do what I am trying to do that will work on WinXP and Windows 7?

4

2 回答 2

1

唯一设计用于操作文件的 WMI 类是CIM_DataFile该类,它们包含一组方法(CopyCopyEx)来复制文件,但只能在目标机器上工作,这意味着您不能使用 WMI 将文件从一台机器复制到另一台机器(至少您使用网络驱动器或共享)。

于 2013-05-14T01:24:23.100 回答
1

最简单的方法可能是先用 建立网络连接,然后用或WNetAddConnection2之类的东西复制文件。完成后,使用删除网络连接会很有礼貌。CopyFileCopyFileExWNetCancelConnection2

于 2013-05-14T05:38:18.203 回答