注册 登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

mylotustips的博客

IBM Lotus协作产品家族经验分享

 
 
 

日志

 
 
关于我

欢迎大家使用SR向IBM800提交问题http://www.ibm.com/support/servicerequest 可以随时查看问题状态,上传文件

网易考拉推荐

如何通过LotusScript取得客户端IP地址  

2012-06-18 18:24:23|  分类: LotusScript |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |

客户希望根据用户IP地址来判断并打开最适宜的Domino 服务器上的副本,如何通过LotusScript实现?。

 

原文出处:

Title: Capture IP address in Notes

URL: http://tinyurl.com/cxrcxwr

 

The \'type\' and \'function\' declarations should put placed in the (Declarations) area and the rest of the code can be inserted anywhere into your own. The final value of \'Address\' is a string representing the current IP address.

Regards,
Mark Brown
MBCC Limited
mark@mbcc.co.uk


Public Type HOSTENT
hName As Long
hAliases As Long
hAddrType As Integer
hLen As Integer
hAddrList As Long
End Type

Declare Public Function gethostname Lib "WSOCK32.
DLL" (Byval szHost As String, Byval dwHostLen As Long) As Long
Declare Public Function gethostbyname Lib "WSOCK32.
DLL" (Byval szHost As String) As Long
Declare Public Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (hpvDest As Any, Byval hpvSource As Long, Byval cbCopy As Long)

Sub Initialize
Dim HostName As String * 256
Dim HostPointer As Long
Dim HostStruct As HOSTENT
Dim HostAddressPointer As Long
Dim HostAddress As Long
Dim AddressNum As String
Dim Address As String

gethostname HostName, 256
HostName = Trim(HostName)
HostPointer = gethostbyname(HostName)

CopyMemory HostStruct, HostPointer, Len(HostStruct)
CopyMemory HostAddressPointer, HostStruct.hAddrList, 4
CopyMemory HostAddress, HostAddressPointer, 4

AddressNum = Trim(Hex(HostAddress))
AddressNum = String(8-Len(AddressNum), Asc("0")) & AddressNum

Address = Cstr(Cint("&H" & Mid(AddressNum, 7))) & "." & Cstr(Cint("&H" & Mid(AddressNum, 5, 2))) & "." & Cstr(Cint("&H" & Mid(AddressNum, 3, 2))) & "." & Cstr(Cint("&H" & Left(AddressNum, 2)))
End Sub

 

您还可以参考以下网页:

 

Title: Converting Host Name To IP Address

URL: http://www.breakingpar.com/bkp/home.nsf/0/87256B280015193F87256CA300788B6E

  评论这张
 
阅读(884)| 评论(0)
推荐 转载

历史上的今天

在LOFTER的更多文章

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2017