当前位置:首页
开发技术指南» 文章正文
    引言:

    摘要: aspnet account 不能访问我的webservices(c:\inetpub\wwwroot\truewebservices\service1.asmx) 可能是aspnet帐号缺少对c:\inetpub\wwwroot\truewebservices目录的权限,请问怎么提升aspnet帐号的权限? 手动我会实现,请问怎么可以用代码来实现用户权限的提升呢? ......
    摘要: 用indy的tidtcpserver开发服务器程序时,当有多个客户端为往服务器发送数据时,我要根据不同数据内容作判断,转发到特定的客户端(即转发到一个已知ip的客户端)。该如何实现,多谢了!!!! ......


更改文件日期时间

如何更改文件的时间

NO.1   作者: wangdeshui

1.SystemTime:   system   time   is   expressed   in   Coordinated   Universal   Time   (UTC)  
  2.LocalTime:   指的是local   PC的时间日期,即vb   Date()   Time()所传回的日期时间  
  3.FileTime   :   文件储存的时间格式  
  前面两种日期的格式都是  
  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  
  这TYPE   SYSTEMTIME的格式够清楚了,而FileTime则是  
  Type   FileTime  
              dwLowDateTime   As   Long  
              dwHighDateTime   As   Long  
  End   Type  
  The   FILETIME   structure   is   a   64-bit   value   representing   the   number   of  
  100-nanosecond   intervals   since   January   1,   1601  
    这三个时间是可以做转换的,LocalTime对SystemTime最简单  
  SystemTime   =   LocalTime   +   时间差     (以台湾来说   时间差   =   -8小时)  
    我们可以用GetTimeZoneInformation()来取得时间差。  
  而SystemTime和FileTime间的转换则可用  
  FileTimeToSystemTime()   SystemTimeToFileTime()来转换。剩下的就是更动时间的部  
  份,那使用SetFileTime来完成  
  SetFileTime(  
          HANDLE     hFile,   //   identifies   the   file  
          CONST   FILETIME   *     lpftCreation,   //   time   the   file   was   created  
          CONST   FILETIME   *     lpftLastAccess,   //   time   the   file   was   last   accessed  
          CONST   FILETIME   *     lpftLastWrite   //   time   the   file   was   last   written  
        );  
    如果不想更动日期,相对应的叁数传Null进去   。  
    另可叁考读取文件建立时间及存取时间  
  以下程式在Form,需   textBox   *   1       Command   Button   *   1  
  Option   Explicit  
  Private   hFile   As   Long  
   
  Private   Sub   Command1_Click()  
  Dim   lpct   As   FileTime,   lplac   As   FileTime,   lplwr   As   FileTime  
  Dim   ofs   As   OFSTRUCT  
  Dim   tZone   As   TIME_ZONE_INFORMATION  
  Dim   ft   As   SYSTEMTIME  
  Dim   dtdate   As   Date  
  Dim   bias   As   Long  
   
  hFile   =   OpenFile("c:\prn2",   ofs,   OF_READWRITE)  
  Call   GetTimeZoneInformation(tZone)  
  bias   =   tZone.bias     时间差,   以「分」为单位  
  计算出Coordinated   Universal   Time   (UTC).  
  dtdate   =   CDate(Text1.Text)   +   TimeSerial(0,   bias,   0)  
   
  ft.wYear   =   Year(dtdate)  
  ft.wMonth   =   Month(dtdate)  
  ft.wDay   =   Day(dtdate)  
  ft.wHour   =   Hour(dtdate)  
  ft.wMinute   =   Minute(dtdate)  
  ft.wSecond   =   Second(dtdate)  
  ft.wDayOfWeek   =   WeekDay(dtdate)  
  ft.wMilliseconds   =   0  
  Call   SystemTimeToFileTime(ft,   lplwr)  
   
  更动hFile的时间,第2个叁数改Create   DateTime  
  第3个叁数改Last   Access   DateTime  
  第四个叁数改Last   Modify   DateTime  
  Call   SetFileTime(hFile,   ByVal   0,   ByVal   0,   lplwr)  
  Call   CloseHandle(hFile)  
   
  End   Sub  
  Private   Sub   Form_Load()  
  Text1.Text   =   "1998/06/03   5:50:10   AM"  
  End   Sub  
   
   
  Option   Explicit  
   
  Public   Const   OFS_MAXPATHNAME   =   128  
  Public   Const   OF_READ   =   &H0  
  Public   Const   OF_READWRITE   =   &H2  
   
  Type   OFSTRUCT  
            cBytes   As   Byte  
            fFixedDisk   As   Byte  
            nErrCode   As   Integer  
            Reserved1   As   Integer  
            Reserved2   As   Integer  
            szPathName(OFS_MAXPATHNAME)   As   Byte  
  End   Type  
   
  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  
   
  Type   FileTime  
              dwLowDateTime   As   Long  
              dwHighDateTime   As   Long  
  End   Type  
   
  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  
   
  Declare   Function   GetTimeZoneInformation   Lib   "kernel32"   _  
    (lpTimeZoneInformation   As   TIME_ZONE_INFORMATION)   As   Long  
  Declare   Function   OpenFile   Lib   "kernel32"   (ByVal   lpFileName   As   String,   _  
    lpReOpenBuff   As   OFSTRUCT,   ByVal   wStyle   As   Long)   As   Long  
  Declare   Function   CloseHandle   Lib   "kernel32"   (ByVal   hObject   As   Long)   As   Long  
  Declare   Function   SetFileTime   Lib   "kernel32"   (ByVal   hFile   As   Long,   lpCreationTime   As   Any,   lpLastAccessTime   As   Any,   lpLastWriteTime   As   Any)   As   Long  
  Declare   Function   SystemTimeToFileTime   Lib   "kernel32"   (lpSystemTime   As   SYSTEMTIME,   lpFileTime   As   FileTime)   As   Long  
   
  Declare   Sub   GetSystemTime   Lib   "kernel32"   (lpSystemTime   As   SYSTEMTIME)  
  Declare   Sub   GetLocalTime   Lib   "kernel32"   (lpSystemTime   As   SYSTEMTIME)  
 


 ·关于菜单的菜鸟问题    »显示摘要«
    摘要: 类似于"选中"功能怎么做? 就是我点击一下,菜单项的左边会有一个对号出现,然后别的菜单项的对号消失 ......
» 本期热门文章:

©2000-2007 All Rights Reserved. 最佳浏览:1024X768 MSIE