简体   繁体   中英

Create folders on a remote Windows PC using C++?

如何使用C ++在远程Windows PC上创建文件夹?

Directly, you can't -- there would have to be a service on the remote machine which exposes that functionality for you.

If you're talking about a server message block scenario (ie "Windows Filesharing"), you can just call CreateDirectory with a network path, ie "\\\\\\\\computername\\\\share\\\\newFolder" , but this requires the remote machine already be setup with an existing network share (I don't believe you can create said share remotely without A. admin rights on the target box, and B. some lessening of security settings to allow creation of shares remotely).

EDIT : (In response to the tag edit adding the MFC tag)
As far as how CreateDirectory is exposed in MFC, I'm not sure if there's an MFC wrapper around that function at all -- though there really doesn't need to be a wrapper because the function itself is self contained -- there'd be no benefit of putting it in a class.

The typical way is to start by calling NetShareAdd to create a share to a path on the remote machine. To support creating things there, you'll normally want to specify at least ACCESS_CREATE for the share.

Once you've done that, you'll have a local path to the remote disk, and you can create a directory in it, just like you would with a local disk.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM