用delphi实现映射网络盘符,怎么做? 在netware开了a、b、c三个用户,我在win上也建立了三个相应的用户并设置相应的密码来连接netware,并把netware里相应的文件夹映射成win上的文件夹,现在我想在一个win用户里用批处理就能连接a、b、c三个用户,怎么做? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 添加网路硬盘映射?API:WNetAddConnection2 localname:本地磁盘号 如:Y: Z: remotename: 共享路径 如 :\\server\shareusername : 用户名password: 密码function connectserver(localname: string; remotename: string; username: string; password: string): boolean;var NetSource: TNetResource; Errinfo: longint;begin with NetSource do begin dwType := RESOURCETYPE_ANY; //RESOURCETYPE_DISK lpLocalName := pchar(localname); // 将远程资源映射到此驱动器 lpRemoteName := pchar(remotename); // 远程网络资 源 lpProvider := ''; // 必须赋值,如为空则使用lpRemoteName 的值。 end; ErrInfo := WnetAddConnection2(NetSource, pchar(password), pchar(username), 0); result := (ErrInfo = NO_ERROR);end; procedure TfrmMain.btnMapClick(Sender : TObject);var NetSource : TNetResource;begin with NetSource do begin dwType := RESOURCETYPE_DISK; lpLocalName :=Pchar(edtLocal.text); // 将远程资源映射到此驱动器 lpRemoteName :=pchar(edtResource.text); // 远程网络资源 lpProvider := ''; // 必须赋值,如为空则使用lpRemoteName的值 end; if WnetAddConnection2(NetSource, pchar(edtPass.text), pchar(edtUser.text), CONNECT_UPDATE_PROFILE)=NO_ERROR //用户名为Guest,口令为Password,下次登录时重新连接,此时在Windows资源管理器中可看到网络驱动器: then //映射成功 showmessage(edtResource.text+'成功映射成'+edtLocal.text) else showmessage('映射失败!');end; Delphi怎么才能实现关闭服务类的进程呢? 请教一个简单的函数声明,请看内容,在线,马上结分 activeForm怎样连接ACCESS数据库? 如何将QRDBText控件显示的金额数字后加'.00'? 如何访问oracle数据库中的数据表数据? 我的女朋友从建设银行跳槽到招商银行,为祝她前程似锦,我要现在马上散分! ask:如何对自动编码的字段添加数据 100分!谁有完整的邮件收发程序,给我一份 [email protected] 打不开执行文件(EXE) 请问如何读出计算机中的时间,日期并显示出来? 请问这样的界面怎么实现的?(金蝶KIS) 控件使用问题,请大侠赐教!谢谢了!!!
API:WNetAddConnection2
remotename: 共享路径 如 :\\server\share
username : 用户名
password: 密码
function connectserver(localname: string; remotename: string; username: string; password: string): boolean;
var
NetSource: TNetResource; Errinfo: longint;
begin
with NetSource do begin
dwType := RESOURCETYPE_ANY; //RESOURCETYPE_DISK
lpLocalName := pchar(localname);
// 将远程资源映射到此驱动器
lpRemoteName := pchar(remotename);
// 远程网络资 源
lpProvider := '';
// 必须赋值,如为空则使用lpRemoteName 的值。
end;
ErrInfo := WnetAddConnection2(NetSource, pchar(password), pchar(username), 0);
result := (ErrInfo = NO_ERROR);
end;
var
NetSource : TNetResource;
begin
with NetSource do
begin
dwType := RESOURCETYPE_DISK;
lpLocalName :=Pchar(edtLocal.text);
// 将远程资源映射到此驱动器
lpRemoteName :=pchar(edtResource.text);
// 远程网络资源
lpProvider := '';
// 必须赋值,如为空则使用lpRemoteName的值
end;
if WnetAddConnection2(NetSource, pchar(edtPass.text), pchar(edtUser.text), CONNECT_UPDATE_PROFILE)=NO_ERROR
//用户名为Guest,口令为Password,下次登录时重新连接,此时在Windows资源管理器中可看到网络驱动器:
then
//映射成功
showmessage(edtResource.text+'成功映射成'+edtLocal.text)
else
showmessage('映射失败!');
end;