| 发表于:2007-03-09 17:27:17 楼主 |
大家好! 现在要取得局域网某一台 windows server 2003系统机器的系统时间,在 vb6.0 下用 netremotetod() api 函数可以取到吗? 目前我这边没有这个测试条件,在xp系统下是可以的,看看各位谁有这个测试条件,谢谢了! 代码如下: ------------------------------------- option explicit private declare function netremotetod lib "netapi32.dll " (tserver as any, pbuffer as long) as long private type systemtime wyear as integer wmonth as integer wdayofweek as integer wday as integer whour as integer wminute as integer wsecond as integer wmilliseconds as integer end type private type time_zone_information bias as long standardname(32) as integer standarddate as systemtime standardbias as long daylightname(32) as integer daylightdate as systemtime daylightbias as long end type private declare function netapibufferfree lib "netapi32.dll " (byval lpbuffer as long) as long private type time_of_day_info tod_elapsedt as long tod_msecs as long tod_hours as long tod_mins as long tod_secs as long tod_hunds as long tod_timezone as long tod_tinterval as long tod_day as long tod_month as long tod_year as long tod_weekday as long end type private declare sub copymemory lib "kernel32 " alias "rtlmovememory " ( _ destination as any, source as any, byval length as long) public function getremotetod(byval strserver as string) as date dim result as date dim lret as long dim tod as time_of_day_info dim lpbuff as long dim tserver() as byte tserver = strserver & vbnullchar lret = netremotetod(tserver(0), lpbuff) if lret = 0 then copymemory tod, byval lpbuff, len(tod) netapibufferfree lpbuff result = dateserial(tod.tod_year, tod.tod_month, tod.tod_day) + _ timeserial(tod.tod_hours, tod.tod_mins - tod.tod_timezone, tod.tod_secs) getremotetod = result else err.raise number:=vbobjecterror + 1001, _ description:= "cannot get remote tod " end if end function private sub form_load() dim d as date d = getremotetod( "192.168.186.110 ") msgbox d end sub ------------------------------ |
|
|
|
|