使用PB调用API自动更新(非FTP模式)(三、连接函数F_CONNECT_COPYSERVER)

作者:网络 来源:佚名 更新时间:2008-02-09 13:38:55 点击:

三、连接函数f_connect_copyserver
返回路径
global type f_connect_copyserver from function_object
end type

forward prototypes
global function string f_connect_copyserver ()
end prototypes

global function string f_connect_copyserver ();
string gs_copyserver1
string gs_copyserver2
string gs_copyserver3
string gs_copyloginuser1
string gs_copyloginuser2
string gs_copyloginuser3
string gs_copyloginpass1
string gs_copyloginpass2
string gs_copyloginpass3

gs_copyserver1    = profilestring("autodown.ini","downpath","copyserver1","")
gs_copyserver2    = profilestring("autodown.ini","downpath","copyserver2","")
gs_copyserver3    = profilestring("autodown.ini","downpath","copyserver3","")
gs_copyloginuser1 = profilestring("autodown.ini","downpath","copyloginuser1","")
gs_copyloginuser2 = profilestring("autodown.ini","downpath","copyloginuser2","")
gs_copyloginuser3 = profilestring("autodown.ini","downpath","copyloginuser3","")
gs_copyloginpass1 = profilestring("autodown.ini","downpath","copyloginpass1","")
gs_copyloginpass2 = profilestring("autodown.ini","downpath","copyloginpass2","")
gs_copyloginpass3 = profilestring("autodown.ini","downpath","copyloginpass3","")

s_netresource ss_net

ss_net.dwscope = 0
ss_net.dwtype  = 0//
ss_net.dwdisplaytype = 0
ss_net.dwusage = 0
ss_net.lplocalname  = ''//
ss_net.lpremotename = gs_copyserver1//
ss_net.lpcomment    = ''
ss_net.lpprovider   = ''//

long ll_ret
string ls_path
ls_path = ''
ll_ret = wnetgetconnectiona('',gs_copyserver1,255)
if ll_ret <> 0 then
 ll_ret = wnetgetconnectiona('',gs_copyserver2,255)
 if ll_ret <> 0 then
  ll_ret = wnetgetconnectiona('',gs_copyserver3,255)
  if ll_ret = 0 then
   return gs_copyserver3
  end if
 else
  return gs_copyserver2
 end if
else
 return gs_copyserver1
end if
//gl_handle,
ll_ret = wnetaddconnection2a(ss_net,gs_copyloginpass1,gs_copyloginuser1,1)
if ll_ret <> 0 then
 ss_net.dwscope = 0
 ss_net.dwtype  = 0//
 ss_net.dwdisplaytype = 0
 ss_net.dwusage = 0
 ss_net.lplocalname  = ''//
 ss_net.lpremotename = gs_copyserver2//
 ss_net.lpcomment    = ''
 ss_net.lpprovider   = ''//
 ll_ret = wnetaddconnection2a(ss_net,gs_copyloginpass2,gs_copyloginuser2,1)
 if ll_ret <> 0 then
  ss_net.dwscope = 0
  ss_net.dwtype  = 0//
  ss_net.dwdisplaytype = 0
  ss_net.dwusage = 0
  ss_net.lplocalname  = ''//
  ss_net.lpremotename = gs_copyserver3//
  ss_net.lpcomment    = ''
  ss_net.lpprovider   = ''//
  ll_ret = wnetaddconnection2a(ss_net,gs_copyloginpass3,gs_copyloginuser3,1)
  if ll_ret <> 0 then
   //messagebox('错误!','连接服务器错误!',stopsign!)
   return ls_path
  end if
  ls_path = gs_copyserver3
 else
  ls_path = gs_copyserver2
 end if
else
 ls_path = gs_copyserver1
end if
if isnull(ls_path) then ls_path = ''
//messagebox('',ls_path)
return ls_path

end function