在DELPHI中映射网络驱动器
有没有什么API提供映射?
我在MSDN中一堆API中哭哭追寻,却找不到她的芳影。痛苦!
倒是发现一个接口,IWshNetwork ,可是我不会用。
她的有关文档是
Microsoft® Windows® Script Host
MapNetworkDrive Method WSH Reference
Version 1
See Also Applies To
--------------------------------------------------------------------------------
Description
Maps the share point specified by strRemoteName to the local resource name strLocalName.
Syntax
object.MapNetworkDrive strLocalName, strRemoteName, [bUpdateProfile], [strUser], [strPassword]
Parameters
Part Description
object WshNetwork object.
strLocalName Local resource name.
strRemoteName Remote share to map.
bUpdateProfile Optional. If bUpdateProfile is supplied and its value is TRUE, the mapping is stored in the user profile. The default is FALSE.
strUser, strPassword Optional. If you are mapping the share point using the credentials of someone other than current user, you can specify strUser and strPassword.
Example
The following example shows how to map the "Z" drive to a network share:
Set WshNetwork = WScript.CreateObject("WScript.Network")
WshNetwork.MapNetworkDrive "Z:", "\\Server\Share"
这大概是VB的玩意吧,谁把她翻译成DELPHI?
问题点数:28、回复次数:2Top
1 楼hzwjs(无聊)回复于 2001-06-22 14:30:00 得分 28
procedure TForm1.Button1Click(Sender: TObject);
var
NRW: TNetResource;
begin
with NRW do
begin
dwType := RESOURCETYPE_ANY;
lpLocalName := 'X:'; // map to this driver letter
lpRemoteName := '\\MyServer\MyDirectory';
// Must be filled in. If an empty string is used,
// it will use the lpRemoteName.
lpProvider := '';
end;
WNetAddConnection2(NRW, 'MyPassword', 'MyUserName',
CONNECT_UPDATE_PROFILE);
end;
Top
2 楼zxb2001(zxb)回复于 2001-06-24 20:42:00 得分 0
gzTop




