VFP程试如何用TERMINAL登入?
用SHAREMAPDRIVE()函数会将服务器共享资料夹镜像至客户端,这样用起来不安全!有没有只登入服务器但不镜像磁盘的函数或命令? Terminal 服务器 安全
[解决办法]
本帖最后由 apple_8180 于 2013-07-15 14:37:26 编辑
If NET_LOGIN('\\IP地址\共享名','用户名','密码')=0
Messagebox("连接登录成功!")
Else
Messagebox("连接登录失败!")
Endif
Function NET_LOGIN()
Lparameters lcUncPath, lcUserName, lcPassWord
Declare Integer WNetAddConnection2 In Win32Api String @ lpNetResource,String lpPassword,String lpUsername,Integer dwFlags
Declare Integer GlobalAlloc In kernel32 Integer, Integer
Declare RtlMoveMemory In kernel32 As Str2Heap Integer, String @, Integer
Declare Integer GlobalFree In kernel32 Integer
Private lcBuff , lnValue, lnretu
Store 0 To m.lnValue, m.lnretu
m.lcBuff = Replicate(Chr(0),16) + Setvalue("") + Setvalue(m.lcUncPath) + Replicate(Chr(0),16)
m.lnretu = WNetAddConnection2(@m.lcBuff, @lcPassWord, @lcUserName, 1)
If m.lnretu <> 0
**这里如果取错误代码...
Endif
Clear Dlls WNetAddConnection2, GlobalAlloc, Str2Heap, GlobalFree
Return m.lnretu
Endfunc
Function Setvalue
Parameters lcString
Local b0, b1, b2, b3
m.lcString = m.lcString + Chr(0)
m.lnretu = Len(m.lcString)
m.lnValue = GlobalAlloc (0, m.lnretu)
If m.lnValue <> 0
= Str2Heap (m.lnValue, @m.lcString, m.lnretu)
Endif
b3 = Int(m.lnValue/16777216)
b2 = Int((m.lnValue - b3*16777216)/65536)
b1 = Int((m.lnValue - b3*16777216 - b2*65536)/256)
b0 = Mod(m.lnValue, 256)
Return Chr(b0)+Chr(b1)+Chr(b2)+Chr(b3)
Endfunc
Declare Integer WNetCancelConnection2 In WIN32API String,Integer
=WNetCancelConnection2("\\IP地址\共享名",1)