求高手指点,怎样从局域网上拷贝文件夹?

tanhan 2003-12-10 03:25:13
当然要包括文件夹下的所以文件,并能有自动覆盖文件夹下面同名文件的功能?
...全文
62 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
tanhan 2003-12-11
  • 打赏
  • 举报
回复
我当然有用户名跟密码啊
tanhan 2003-12-11
  • 打赏
  • 举报
回复
你的那个c build函数在Vc下面不能运行,好像没 这个函数。
superS 2003-12-11
  • 打赏
  • 举报
回复
>>不管共享与否???

不共享,不可能考过来。
yifengling0 2003-12-11
  • 打赏
  • 举报
回复
不共享你拷什么??

这个可就难了,你先要建立ipc共享,有管理员用户名密码!~ ,,然后再。。。。

这个不会了!~

tanhan 2003-12-11
  • 打赏
  • 举报
回复
我要的是不管他共享与否,都能访问一个固定文件夹,并复制过来。
tanhan 2003-12-11
  • 打赏
  • 举报
回复
不行啊 有好一点的vc代码吗
yifengling0 2003-12-11
  • 打赏
  • 举报
回复
帮你找找吧,呵呵,小榕会阿:)
yifengling0 2003-12-10
  • 打赏
  • 举报
回复
回复人: COOL099(Alan Zjou) ( ) 信誉:105 2003-12-6 16:52:55 得分:19
下面是一个列出所有网络资源的的函数示例:
bool __fastcall TForm1::EnumerateFunc(HWND hwnd ,LPNETRESOURCE lpnr,TTreeNode * ParentNode)
{
DWORD dwResult, dwResultEnum;
HANDLE hEnum;
DWORD cbBuffer = 16384; /* 16K is reasonable size */
DWORD cEntries = 0xFFFFFFFF; /* enumerate all possible entries */
LPNETRESOURCE lpnrLocal; /* pointer to enumerated structures */
DWORD i;
dwResult = WNetOpenEnum(RESOURCE_GLOBALNET,
RESOURCETYPE_ANY,
0, /* enumerate all resources */
lpnr, /* NULL first time this function is called */
&hEnum); /* handle to resource */
if (dwResult ==67) //domain下没有可访问的主机
return true;
if (dwResult != NO_ERROR ) { //无
ShowError(dwResult);
return false;
}
TTreeNode * Child;
do {
lpnrLocal = (LPNETRESOURCE) GlobalAlloc(GPTR, cbBuffer);

dwResultEnum = WNetEnumResource(hEnum, /* resource handle */
¢ries, /* defined locally as 0xFFFFFFFF */
lpnrLocal, /* LPNETRESOURCE */
&cbBuffer); /* buffer size */

if (dwResultEnum == NO_ERROR) {
for(i = 0; i < cEntries; i++) {
Child=TreeView1->Items->AddChild(ParentNode,lpnrLocal[i].lpRemoteName);
if(RESOURCEUSAGE_CONTAINER ==
(lpnrLocal[i].dwUsage & RESOURCEUSAGE_CONTAINER))
if(!EnumerateFunc(this->Handle, &lpnrLocal[i],Child))
ShowMessage(”EnumerateFunc returned FALSE.”);
}
}

else if (dwResultEnum != ERROR_NO_MORE_ITEMS) {
ShowError(dwResultEnum);
break;
}
}
while(dwResultEnum != ERROR_NO_MORE_ITEMS);
GlobalFree((HGLOBAL) lpnrLocal);
dwResult = WNetCloseEnum(hEnum);
if(dwResult != NO_ERROR) {
ShowError(dwResult);
return FALSE;
}
return true;
}
需要说明在win98下,此方法列出的资源和网络邻居列出的是一样,和网络邻居一样,有时列出的数据并不准确,可能会有一些域或机器不能找到。
这是在CBuilder中写的,稍微改一改就可以在VC中用!~
tanhan 2003-12-10
  • 打赏
  • 举报
回复
最好写一个实例 ,本人初学,多谢。还有一点,怎么找到局域网上的那个文件夹?????
yifengling0 2003-12-10
  • 打赏
  • 举报
回复
Syntax

typedef struct _SHFILEOPSTRUCT {
HWND hwnd;
UINT wFunc;
LPCTSTR pFrom;
LPCTSTR pTo;
FILEOP_FLAGS fFlags;
BOOL fAnyOperationsAborted;
LPVOID hNameMappings;
LPCTSTR lpszProgressTitle;
} SHFILEOPSTRUCT, *LPSHFILEOPSTRUCT;
Members

hwnd
Window handle to the dialog box to display information about the status of the file operation.
wFunc
Value that indicates which operation to perform. This member can be one of the following values:
FO_COPY
Copy the files specified in the pFrom member to the location specified in the pTo member.
FO_DELETE
Delete the files specified in pFrom.
FO_MOVE
Move the files specified in pFrom to the location specified in pTo.
FO_RENAME
Rename the file specified in pFrom. You cannot use this flag to rename multiple files with a single function call. Use FO_MOVE instead.
pFrom
Address of a buffer to specify one or more source file names. These names must be fully qualified paths. Standard Microsoft® MS-DOS® wild cards, such as "*", are permitted in the file-name position. Although this member is declared as a null-terminated string, it is used as a buffer to hold multiple file names. Each file name must be terminated by a single NULL character. An additional NULL character must be appended to the end of the final name to indicate the end of pFrom.
pTo
Address of a buffer to contain the name of the destination file or directory. This parameter must be set to NULL if it is not used. Like pFrom, the pTo member is also a double-null terminated string and is handled in much the same way. However, pTo must meet the following specifications:
Wildcard characters are not supported.
Copy and Move operations can specify destination directories that do not exist and the system will attempt to create them. The system normally displays a dialog box to ask the user if they want to create the new directory. To suppress this dialog box and have the directories created silently, set the FOF_NOCONFIRMMKDIR flag in fFlags.
For Copy and Move operations, the buffer can contain multiple destination file names if the fFlags member specifies FOF_MULTIDESTFILES.
Pack multiple names into the string in the same way as for pFrom.
Use only fully-qualified paths. Using relative paths will have unpredictable results.
fFlags
Flags that control the file operation. This member can take a combination of the following flags:
FOF_ALLOWUNDO
Preserve Undo information, if possible. If pFrom does not contain fully qualified path and file names, this flag is ignored.
FOF_CONFIRMMOUSE
Not currently used.
FOF_FILESONLY
Perform the operation on files only if a wildcard file name (*.*) is specified.
FOF_MULTIDESTFILES
The pTo member specifies multiple destination files (one for each source file) rather than one directory where all source files are to be deposited.
FOF_NOCONFIRMATION
Respond with "Yes to All" for any dialog box that is displayed.
FOF_NOCONFIRMMKDIR
Do not confirm the creation of a new directory if the operation requires one to be created.
FOF_NO_CONNECTED_ELEMENTS
Version 5.0. Do not move connected files as a group. Only move the specified files.
FOF_NOCOPYSECURITYATTRIBS
Version 4.71. Do not copy the security attributes of the file.
FOF_NOERRORUI
Do not display a user interface if an error occurs.
FOF_NORECURSION
Only operate in the local directory. Don't operate recursively into subdirectories.
FOF_NORECURSEREPARSE
Treat reparse points as objects, not containers. You must set _WIN32_WINNT to 5.01 or later to use this flag. See Shell and Common Controls Versions for further discussion of versioning.
FOF_RENAMEONCOLLISION
Give the file being operated on a new name in a move, copy, or rename operation if a file with the target name already exists.
FOF_SILENT
Do not display a progress dialog box.
FOF_SIMPLEPROGRESS
Display a progress dialog box but do not show the file names.
FOF_WANTMAPPINGHANDLE
If FOF_RENAMEONCOLLISION is specified and any files were renamed, assign a name mapping object containing their old and new names to the hNameMappings member.
FOF_WANTNUKEWARNING
Version 5.0. Send a warning if a file is being destroyed during a delete operation rather than recycled. This flag partially overrides FOF_NOCONFIRMATION.
fAnyOperationsAborted
Value that receives TRUE if the user aborted any file operations before they were completed, or FALSE otherwise.
hNameMappings
A handle to a name mapping object containing the old and new names of the renamed files. This member is used only if the fFlags member includes the FOF_WANTMAPPINGHANDLE flag. See Remarks for more details.
lpszProgressTitle
Address of a string to use as the title of a progress dialog box. This member is used only if fFlags includes the FOF_SIMPLEPROGRESS flag.
Remarks

If the pFrom or pTo members are unqualified names, the current directories are taken from the global current drive and directory settings as managed by the GetCurrentDirectory and SetCurrentDirectory functions.

If pFrom is set to a file name, deleting the file with FO_DELETE will not move it to the Recycle Bin, even if the FOF_ALLOWUNDO flag is set. You must use a full path.

There are two versions of this structure, an ANSI version (SHFILEOPSTRUCTA) and a Unicode version (SHFILEOPSTRUCTW). The Unicode version is identical to the ANSI version, except that wide character strings (LPCWSTR) are used in place of ANSI character strings (LPCSTR). On Microsoft Windows® 98 and earlier, only the ANSI version is supported. On Microsoft Windows NT® 4.0 and later, both the ANSI and Unicode versions of this structure are supported. SHFILEOPSTRUCTW and SHFILEOPTSTRUCTA should never be used directly; the appropriate structure is redefined as SHFILEOPSTRUCT by the precompiler depending on whether the application is compiled for ANSI or Unicode. SHNAMEMAPPING has similar ANSI and Unicode versions. For ANSI applications, hNameMappings points to an int followed by an array of ANSI SHNAMEMAPPING structures. For Unicode applications, hNameMappings points to an int followed by an array of Unicode SHNAMEMAPPING structures. However, on Windows NT 4.0 and later, SHFileOperation always returns a handle to a Unicode set of SHNAMEMAPPING structures. If you want applications to be functional with all versions of Windows, the application must employ conditional code to deal with name mappings. For example:

x = SHFileOperation(&shop);
...
if (fWin9x) {
HandleAnsiNameMappings(shop.hNameMappings);
}

else {
HandleUnicodeNameMappings(shop.hNameMappings);
}


Treat hNameMappings as a pointer to a structure whose members are an UINT value followed by a pointer to an array of SHNAMEMAPPING structures, for example:

struct HANDLETOMAPPINGS {
UINT uNumberOfMappings; // number of mappings in array
LPSHNAMEMAPPING lpSHNameMapping; // pointer to array of mappings
};

The UINT value is set to the number of SHNAMEMAPPING structures in the array. Each SHNAMEMAPPING structure contains the old and new path for one of the renamed files.

Note The handle must be freed with SHFreeNameMappings.
For a complete application that uses the SHFILEOPSTRUCT structure and explains how to set up the SHNAMEMAPPING structure, see the Knowledge Base Article Q151799 at http://support.microsoft.com/support/kb/articles/Q151/7/99.asp.

Structure Information

Header shellapi.h
Minimum operating systems Windows NT 4.0, Windows 95

16,551

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Creator Browser
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧