******************************************
* ļymd.prg
* ܣַ
* ÷ʽcDate = ymd(date1)
*         cDate = ymd() ֱӵõ
******************************************
Parameters myDate
myDate = Iif(Empty(myDate), Date(), myDate)
Return Str(Year(myDate),4) + '' + Transform(Month(myDate), '@l 99') + '' + Transform(Day(myDate), '@l 99') + ''


*************************************
*  ǰںʱ䱸DBF        *
*  øʽBackup(,·)  *
*************************************
Function Backup
Parameters sFileName,sBakPath
If Parameters()=0
	Return
Endif
If Parameters()=1
	sBakPath=""
Endif
sFileName=Forceext(sFileName,".DBF")
If File(sFileName)
	Copy File (sFileName,".DBF")) To (sBakPath+sFileName+"_"+Chrtran(Chrtran(Chrtran(Ttoc(Datetime()),".",""),":","")," ","")+".DBF")
Endif



**ڵǰжֶָǷڣڷ棬򷵻ؼ٣÷:findfield(<ֶַ>)
Func findfield
Parameter ff_name
ff_name = Upper(Alltrim(ff_name))
ff_zds = Fcount()
For ff_i = 1 To ff_zds
	If Field(ff_i) == ff_name
		Return .T.
	Endif
Endfor
Return .F.



*!*	һܽصĺ
*!*	û뵽α֮ı任ɣһǼܺһǽܺܺ˼Ƕû루룩иӻλҲǽû20λαУܺ£

Func MAZH1
Para ZMZ
ZMZ=Val(ZMZ)
N1=Rand()*10^9
If N1<=999999999
	N1=N1+10^9
Endi
N1=Int(N1)
C1=Str(N1+ZMZ)+Str(N1)
C2=Subs(C1,5,20)+Subs(C1,1,4)
P1=''
P2=''
For II=1 To 10
	P1=P1+Subs(C2,2*II-1,1)
	P2=P2+Subs(C2,2*II,1)
Endfor
WMZ=P1+P2
Retu WMZ
*!*	---- Ϊ1234567αΪ64915302152868193982һλͬλαǾͬĲȷԺ͸ԣͨαǲܵġ

*!*	---- 뺯ǽݿдŵαתԭû룬£

Func MAZH2
Para WMZ
PP=''
For II=1 To 10
	PP=PP+Subs(WMZ,II,1)+Subs(WMZ,II+10,1)
Endfor
DD=Subs(PP,17,4)+Subs(PP,1,16)
M1=Subs(DD,1,10)
M2=Subs(DD,11,10)
ZMZ=Int(Val(M1)-Val(M2))
Retu ZMZ
*!*	---- ύϵͳȫǱ༭ģǷ޷õתеϢģԽܷǲױֵġ



ҲСдתдĺ
Procedure CAPP1
Parameters KK
Priv T1,T2,T3,T4,II,T,SS,U
T1 = 'ֽԪʰǪʰǪ  '
T3 = ' ,0,1,2,3,4,5,6,7,8,9,'
T4 = 'Ҽ½ƾ'
T2 = Alltrim(Str(KK,12,2))
SS = ''
II = 1
For T=Len(T2) To 1 Step -1
	U = Substr(T2,T,1)
	If U='.'
		Loop
	Endif
	SS = Subs(T4,At(U,T3),2)+Substr(T1,II,2)+' '+SS
	II = II+2
Endfor
Return SS





ܵú,RUNǿ,,ĵԶַָ:

FUNCTION XRUN
PARAMETERS MC 
DECLARE INTEGER ShellExecute IN SHELL32.DLL INTEGER , STRING , STRING , STRING , STRING , INTEGER 
RETURN SHELLEXECUTE(0,'open',MC,'','',1)

ʾ:
XRUN("P215.PDF")
XRUN("http://www.sld.com.cn";)

ʹô˺ǰ뱣֤õļڳĬĿ¼set defa toָļĿ¼. 

   ÷Ϊ 50 :  


жǷ
*chckdisk.prg
parameters tcDrive 
local lcDrive, lnWinErrMode, llCanRead 
declare integer SetErrorMode in Win32API integer nErrorMode 
lcDrive = iif(substr(tcDrive, 2, 1) = ':', left(tcDrive, 2), tcDrive) 
lnWinErrMode = SetErrorMode(1) 
llCanRead = diskspace(lcDrive) <> -1 
SetErrorMode(lnWinErrMode) 
return llCanRead

磺? chckdisk('A:')
أ
.T.   
.F.   





VFPṩ˶ԱֶμΪյĺ:SBLANK() EMPTY() ,ûṩԼ¼Ϊյĺ,ǿԱдһ:

* : IsBlankRec
*
* : ֵ | ַ - ѡ
*
* ֵͱʽҪĹ,
* ַͱʽҪı.
*
FUNCTION IsBlankRec
PARAMETER lAlias
PRIVATE llSeleBack, lnSeleBack, llResult, lcFieldName, IsBlankRec
llSeleBack = .F.
lnSeleBack = SELECT(0)
llResult = .T.
IF PARAMETERS() = 1
 llSeleBack = .T.
 SELECT (lAlias)
ENDIF
FOR IsBlankRec = 1 TO FCOUNT()
 lcFieldName = FIELD(IsBlankRec)
 IF ! empty( &lcFieldName )
  llResult = .F.
  EXIT
 ENDIF
ENDFOR
IF llSeleBack
 SELECT (lnSeleBack)
ENDIF
RETURN llResult 






FUNCTION gcrundoc
  **********************************************************************
  **  ܣĵ
  **  ֵ: tcdocument Ҫ򿪵ļ
  **  ֵ: 
  **********************************************************************
  **  úĬϵĹκĵ, ൱Դֻĵʱĳ.
  **  һⲿһıļ, һ Word  Excel ĵ, һͼļȵ.
  PARAMETERS tcdocument

  LOCAL lnresult

  DECLARE INTEGER ShellExecute ;
    IN SHELL32.DLL ;
    INTEGER nWinHandle, ;
    STRING cOperation, ;
    STRING cFileName, ;
    STRING cParameters, ;
    STRING cDirectory, ;
    INTEGER nShowWindow

  ** VFP ھ (þ ShellExecute ʹ)

  DECLARE INTEGER FindWindow ;
    IN WIN32API ;
    STRING cNull, ;
    STRING cWinName

  lnresult=shellexecute(findwindow( 0, _SCREEN.CAPTION), "Open", tcdocument, "", "", 1)

  ** ֵС 32 ʱʾϢ
  IF lnresult < 32
    DO CASE
    CASE lnresult=2
      WAIT WIND "Ĺļ URL."
    CASE lnresult=31
      WAIT WIND "޹ļ."
    CASE lnresult=29
      WAIT WIND "Ӧó."
    CASE lnresult=30
      WAIT WIND "ӦóѾ."
    ENDCASE
  ENDIF
  RETURN
  ** -----------------------------------------






[ת]DBFEXCELļ

****************************************
*            EXCELļ             *
*      Զ 1.0.1 2003.06.30         *
*      Զ 1.0   2003.06.28         *
**
****************************************
FUNCTION ToExcel
LPARAMETERS ExcelFile,OutField,PageSet,OtherSet
*ExcelFile-ɵEXCELļ (Ĳ)
*OutField-ֶ 1-ֶ 2- 3-(=-1ΪԶ) 4-ʽ (ʡ)
*PageSet-ҳ 1-õĿ 2-õֵ (ʡ,PageSetĿֵ뿴)
*OtherSet- (ʡ,OtherSetĿֵ뿴)

*ʹñ֮ǰ,лҪĹ;ֶֻ֧,ֱ֧ʽ
*ֶҲֱ֧עͺͨ
*ûʹEXCEL༭ͬļ,߽ҪɵEXCELļռ
*Ҳɳ,ʹñ֮ǰرEXCEL
 DO CASE 
 CASE PARAMETERS()=1
  STORE null TO OutField,PageSet,OtherSet 
 CASE PARAMETERS()=2
  STORE null TO PageSet,OtherSet
 CASE PARAMETERS()=3
  STORE null TO OtherSet
 ENDCASE 
 LOCAL i,OutFields,ExcelApp,ExcelAppRang

 FOR i=1 TO IIF(TYPE("OutField(1)")="U" OR ISNULL(OutField),0,ALEN(OutField,1))
  OutField(i,1)=UPPER(ALLTRIM(OutField(i,1)))
 NEXT 

 FOR i=1 TO IIF(TYPE("PageSet(1)")="U" OR ISNULL(PageSet),0,ALEN(PageSet,1))
  PageSet(i,1)=UPPER(ALLTRIM(PageSet(i,1)))
 NEXT 

 FOR i=1 TO IIF(TYPE("OtherSet(1)")="U" OR ISNULL(OtherSet),0,ALEN(OtherSet,1))
  OtherSet(i,1)=UPPER(ALLTRIM(OtherSet(i,1)))
 NEXT 

 OutFields=""
 FOR i=1 TO IIF(TYPE("OutField(1)")="U" OR ISNULL(OutField),0,ALEN(OutField,1))
  OutFields=OutFields+IIF(EMPTY(OutFields),"",",")+OutField(i,1)
 NEXT 
 IF ISNULL(OutField) OR OutField(1)="AUTO_SET" AND OutField(2)="-1" &&EXCELļ
  COPY TO (ExcelFile) XL5 
 ELSE
  COPY TO (ExcelFile) FIELDS &OutFields XL5 
 ENDIF 

 ExcelApp=CREATEOBJECT("Excel.application") &&EXCEL
 If Type("ExcelApp")#"O"
  WAIT CLEAR 
  MessageBox( "ExcelʧܣϵͳǷȷװ Excel "+CHR(13)+CHR(13)+;
   "Ѿδʽ Excel ļ:"+ExcelFile,48,"Excel")
  RETURN .f.
 ENDIF
 ExcelApp.Visible =.f.
 ExcelApp.Caption ="EXCEL" &&
 ExcelApp.Workbooks.Open(ExcelFile) &&ļ
 ExcelApp.Workbooks(1).ActiveSheet.Name="Test" &&
 ExcelAppRang=ExcelApp.Workbooks(1).Sheets(1).PageSetup &&ҳö
 FOR i=1 TO IIF(TYPE("PageSet(1)")="U" OR ISNULL(PageSet),0,ALEN(PageSet,1))
  DO CASE 
  CASE PageSet(i,1)=UPPER("PaperSize") &&ֽ
   ExcelAppRang.PaperSize=PageSet(i,2)
  CASE PageSet(i,1)=UPPER("Orientation") &&ӡ
   ExcelAppRang.Orientation=PageSet(i,2)
  CASE PageSet(i,1)=UPPER("TopMargin") &&ҳ
   ExcelAppRang.TopMargin=PageSet(i,2)
  CASE PageSet(i,1)=UPPER("BottomMargin") &&ҳ׿
   ExcelAppRang.BottomMargin=PageSet(i,2)
  CASE PageSet(i,1)=UPPER("LeftMargin") &&ҳ
   ExcelAppRang.LeftMargin=PageSet(i,2)
  CASE PageSet(i,1)=UPPER("RightMargin") &&ҳҿ
   ExcelAppRang.RightMargin=PageSet(i,2)
  CASE PageSet(i,1)=UPPER("HeaderMargin") &&ҳüλ
   ExcelAppRang.HeaderMargin=PageSet(i,2)
  CASE PageSet(i,1)=UPPER("FooterMargin") &&ҳλ
   ExcelAppRang.FooterMargin=PageSet(i,2)
  CASE PageSet(i,1)=UPPER("PrintTitleRows") &&б
   ExcelAppRang.PrintTitleRows=PageSet(i,2)
  CASE PageSet(i,1)=UPPER("PrintTitleColumns") &&б
   ExcelAppRang.PrintTitleColumns=PageSet(i,2)
  CASE PageSet(i,1)=UPPER("LeftHeader") &&ҳü
   ExcelAppRang.LeftHeader=PageSet(i,2)
  CASE PageSet(i,1)=UPPER("CenterHeader") &&ҳü
   ExcelAppRang.CenterHeader=PageSet(i,2)
  CASE PageSet(i,1)=UPPER("RightHeader") &&ҳü
   ExcelAppRang.RightHeader=PageSet(i,2)
  CASE PageSet(i,1)=UPPER("LeftFooter") &&ҳ
   ExcelAppRang.LeftFooter=PageSet(i,2)
  CASE PageSet(i,1)=UPPER("CenterFooter") &&ҳ
   ExcelAppRang.CenterFooter=PageSet(i,2)
  CASE PageSet(i,1)=UPPER("RightFooter") &&ҳ
   ExcelAppRang.RightFooter=PageSet(i,2)
  CASE PageSet(i,1)=UPPER("CenterHorizontally") &&ҳˮƽ
   ExcelAppRang.CenterHorizontally=PageSet(i,2)
  CASE PageSet(i,1)=UPPER("CenterVertically") &&ҳ洹ֱ
   ExcelAppRang.CenterVertically=PageSet(i,2)
  ENDCASE 
 NEXT 
 IF ISNULL(OutField) OR UPPER(OutField(1))="AUTO_SET" AND OutField(2)="-1"
  FOR i=1 TO FCOUNT()
   IF !ISNULL(OutField) AND ASCAN(OutField,UPPER(FIELD(i)))>0
    ExcelApp.Workbooks(1).Sheets(1).Application.Cells(1,i).value=OutField(ASCAN(OutField,UPPER(FIELD(i)))+1) &&
    *IF !ISNULL(OutField(ASCAN(OutField,UPPER(FIELD(i)))+2)) AND TYPE("OutField(ASCAN(OutField,UPPER(FIELD(i)))+2)")="N" AND OutField(ASCAN(OutField,UPPER(FIELD(i)))+2)#-1
    * ExcelApp.Workbooks(1).Sheets(1).Application.Columns(i).ColumnWidth =OutField(ASCAN(OutField,UPPER(FIELD(i)))+2)
    *ENDIF 
    IF !ISNULL(OutField(ASCAN(OutField,UPPER(FIELD(i)))+3)) AND !EMPTY(OutField(ASCAN(OutField,UPPER(FIELD(i)))+3)) &&ʽģ
     ExcelApp.Workbooks(1).Sheets(1).Application.Columns(i).NumberFormatLocal=OutField(ASCAN(OutField,UPPER(FIELD(i)))+3)
    ENDIF 
   ENDIF 
  NEXT 
 ELSE
  FOR i=1 TO ALEN(OutField,1)
   IF !ISNULL(OutField(i,2)) AND !EMPTY(OutField(i,2)) &&
    ExcelApp.Workbooks(1).Sheets(1).Application.Cells(1,i).value=OutField(i,2)
   ENDIF 

   *IF !ISNULL(OutField(i,3)) AND TYPE("OutField(i,3)")="N" AND OutField(i,3)#-1 &&п
   * ExcelApp.Workbooks(1).Sheets(1).Application.Columns(i).ColumnWidth =OutField(i,3)
   *ENDIF 

   IF !ISNULL(OutField(i,4)) AND !EMPTY(OutField(i,4)) &&ʽģ
    ExcelApp.Workbooks(1).Sheets(1).Application.Columns(i).NumberFormatLocal=OutField(i,4)
   ENDIF 
  NEXT 
 ENDIF 
 IF ISNULL(OutField) OR UPPER(OutField(1))="AUTO_SET" AND OutField(2)="-1" &&ѡзΧ
  ExcelAppRang=ExcelApp.Workbooks(1).Sheets(1).Application.Range(ExcelApp.Workbooks(1).Sheets(1).Application.Cells(1,1),;
   ExcelApp.Workbooks(1).Sheets(1).Application.Cells( 1,FCOUNT()))
 ELSE
  ExcelAppRang=ExcelApp.Workbooks(1).Sheets(1).Application.Range(ExcelApp.Workbooks(1).Sheets(1).Application.Cells(1,1),;
   ExcelApp.Workbooks(1).Sheets(1).Application.Cells( 1,ALEN(OutField,1)))
 ENDIF
 ExcelAppRang.HorizontalAlignment=3 &&ˮƽ
 ExcelAppRang.VerticalAlignment=2 &&ֱ
 ExcelAppRang.Font.Bold = .t.
 IF ISNULL(OutField) OR UPPER(OutField(1))="AUTO_SET" AND OutField(2)="-1" &&ѡΧ
  ExcelAppRang=ExcelApp.Workbooks(1).Sheets(1).Application.Range(ExcelApp.Workbooks(1).Sheets(1).Application.Cells(1,1),;
   ExcelApp.Workbooks(1).Sheets(1).Application.Cells(RECCOUNT()+1,FCOUNT()))
 ELSE
  ExcelAppRang=ExcelApp.Workbooks(1).Sheets(1).Application.Range(ExcelApp.Workbooks(1).Sheets(1).Application.Cells(1,1),;
   ExcelApp.Workbooks(1).Sheets(1).Application.Cells(RECCOUNT()+1,ALEN(OutField,1)))
 ENDIF
 IF !ISNULL(OtherSet) AND TYPE("OtherSet(1)")#"U" AND ASCAN(OtherSet,UPPER("FontSize"))#0 &&С
  ExcelAppRang.Font.Size=OtherSet(ASCAN(OtherSet,UPPER("FontSize"))+1)
 ELSE 
  ExcelAppRang.Font.Size=10
 ENDIF 
 IF !ISNULL(OtherSet) AND TYPE("OtherSet(1)")#"U" AND ASCAN(OtherSet,UPPER("FontName"))#0 &&
  ExcelAppRang.Font.Name=OtherSet(ASCAN(OtherSet,UPPER("FontName"))+1)
 ELSE 
  ExcelAppRang.Font.Name=""
 ENDIF 
 IF !ISNULL(OtherSet) AND TYPE("OtherSet(1)")#"U" AND ASCAN(OtherSet,UPPER("LineStyle"))#0 &&ߵ
  STORE OtherSet(ASCAN(OtherSet,UPPER("LineStyle"))+1) TO 
   ExcelAppRang.Borders(1).LineStyle,;
   ExcelAppRang.Borders(2).LineStyle,;
   ExcelAppRang.Borders(3).LineStyle,;
   ExcelAppRang.Borders(4).LineStyle
 ELSE
  STORE 1 TO 
   ExcelAppRang.Borders(1).LineStyle,;
   ExcelAppRang.Borders(2).LineStyle,;
   ExcelAppRang.Borders(3).LineStyle,;
   ExcelAppRang.Borders(4).LineStyle
 ENDIF 
 IF !ISNULL(OtherSet) AND TYPE("OtherSet(1)")#"U" AND ASCAN(OtherSet,UPPER("Weight"))#0 &&ߵĿ,LineStyle=1ʱЧ
  STORE OtherSet(ASCAN(OtherSet,UPPER("Weight"))+1) TO 
   ExcelAppRang.Borders(1).Weight,;
   ExcelAppRang.Borders(2).Weight,;
   ExcelAppRang.Borders(3).Weight,;
   ExcelAppRang.Borders(4).Weight
 ELSE
  STORE 2 TO 
   ExcelAppRang.Borders(1).Weight,;
   ExcelAppRang.Borders(2).Weight,;
   ExcelAppRang.Borders(3).Weight,;
   ExcelAppRang.Borders(4).Weight
 ENDIF 

 IF ISNULL(OutField) OR UPPER(OutField(1))="AUTO_SET" AND OutField(2)="-1" &&п
  FOR i=1 TO FCOUNT()
   IF !ISNULL(OutField) AND ASCAN(OutField,UPPER(FIELD(i)))>0 and OutField(ASCAN(OutField,UPPER(FIELD(i)))+2)#-1
    ExcelApp.Workbooks(1).Sheets(1).Application.Columns(i).ColumnWidth =OutField(ASCAN(OutField,UPPER(FIELD(i)))+2)
   ELSE
    ExcelApp.Workbooks(1).Sheets(1).Application.Columns(i).AutoFit
   ENDIF 
  NEXT 
 ELSE
  FOR i=1 TO ALEN(OutField,1)
   IF OutField( i, 3)=-1
    ExcelApp.Workbooks(1).Sheets(1).Application.Columns(i).AutoFit
   ELSE 
    ExcelApp.Workbooks(1).Sheets(1).Application.Columns(i).ColumnWidth=OutField( i, 3)
   ENDIF 
  NEXT 
 ENDIF 
 ExcelApp.Workbooks(1).Save() &&
 ExcelApp.Quit &&ر
 RELEASE ExcelApp,ExcelAppRang
RETURN .t.








**************************************
*ƣȡӲк
*ܣȡӲк
*ʹãdrvinfo("C:",3)
*أָӲк
*ߣϾŸĽ
*************************************
FUNC drvinfo
PARAMETERS c_drv, n_opt
If Empty(c_drv)
   Return .F.
Endif
If Empty(n_opt)
   Return ""
Endif
DECL INTEGER GetVolumeInformation IN Win32API AS _GetVolumeInformation_ STRING @, STRING @, INTEGER, INTEGER @, INTEGER @, INTEGER @, STRING @, INTEGER
DECL INTEGER GetDriveType IN Win32API AS _GetDriveType_ STRING @

lcrootpathname = Allt(c_drv)+"\"
ndrivetype = _getdrivetype_(@lcrootpathname)
DO CASE
     CASE ndrivetype=1
          cdrivetype = "δҵ"
     CASE ndrivetype=2
          cdrivetype = "ƶ"
     CASE ndrivetype=3
          cdrivetype = "̶"
     CASE ndrivetype=4
          cdrivetype = ""
     CASE ndrivetype=5
          cdrivetype = ""
     CASE ndrivetype=6
          cdrivetype = ""
     OTHE
          cdrivetype = "޷ȷ" 
ENDC
STOR SPACE(256) TO lcvolumenamebuffer, lcfilesystemnamebuffer
STOR 256 TO lnvolumenamesize, lnfilesystemnamesize
STOR 0 TO lnvolumeserialnumber, lnmaximumcomponentlength, lnfilesystemflags
lnerror = _getvolumeinformation_(@lcrootpathname,@lcvolumenamebuffer,lnvolumenamesize,@lnvolumeserialnumber,@lnmaximumcomponentlength,@lnfilesystemflags,@lcfilesystemnamebuffer,lnfilesystemnamesize)
Do Case
   Case n_opt=1
        return Upper(lcrootpathname)   && 
   Case n_opt=2
        Return LEFT(lcvolumenamebuffer, AT(CHR(0), lcvolumenamebuffer)-1)   &&
   Case n_opt=3
        Return allt(str(ABS(lnvolumeserialnumber)))   &&к
   Case n_opt=4
        Return cDrivetype   &&
EndCase














 yyyymm  ǷЧ199912200408
*********************** yymm  ***************************
FUNCTION CHK_YYMM
PARAMETER tcYYMM   &&tcYYMM 6λַ,199906
LOCAL lcYY, lcMM
IF LEN(ALLT(tcYYMM))<6
 lcYY = LEFT(ALLT(tcYYMM),2)
 tcYYMM = IIF(VAL(lcYY)>70,"19"+ALLT(tcYYMM),"20"+ALLT(tcYYMM))
ENDIF
lcYY = LEFT(tcYYMM,4)
lcMM = RIGHT(tcYYMM,2)
IF VAL(lcYY)<1970 OR VAL(lcYY)>2070 OR VAL(lcMM)<1 OR VAL(lcMM)>12
 = MESSAGEBOX("ڷǷ",0+16+0,"Error")
 tcYYMM = cStartYM
ENDIF
RETURN tcYYMM




* -------------------------------------
* ȡػ
* -------------------------------------
Function GetLocalHostName32
    #Define WSADATA_SIZE  398
    #Define WS_VERSION    514
    #Define SOCKET_ERROR  -1
    Declare integer WSAStartup in ws2_32 integer wVerRq, string @lpWSAData
    Local lcWSADATA
    lcWSADATA = Repli(CHR(0), WSADATA_SIZE)
    If WSAStartup (WS_VERSION, @lcWSADATA) = 0
        Declare integer gethostname in ws2_32 string @cName, integer nNamelen
        Local lcBuffer, lnResult, lcReturn
        lcBuffer = SPACE(250)
        lnResult = gethostname (@lcBuffer, LEN(lcBuffer))
        lcReturn = IIF(lnResult=0, SUBSTR(lcBuffer, 1,AT(CHR(0),lcBuffer)-1), [] )
        Declare integer WSACleanup in ws2_32
        = WSACleanup()
        Return lcReturn
    Else
        Return []
    Endif
Endfunc

* -------------------------------------
*  IP ȡ Mac ַ
* -------------------------------------
Function GetHostMac32 ( tcHostname )
    tcHostname = iif(Type([tcHostname])=[C],tcHostname,[])
    #Define WSADATA_SIZE  398
    #Define WS_VERSION    514
    Declare integer WSAStartup in ws2_32 integer wVerRq, string @lpWSAData

    * ʼ SOCKET
    Local lcMacStr, lcWSADATA
    lcMacStr = [00-00-00-00-00-00]
    lcWSADATA = Repli(CHR(0), WSADATA_SIZE)
    If WSAStartup (WS_VERSION, @lcWSADATA) = 0
        * ARPѯԶMACַ
        Declare integer inet_addr in ws2_32 string cp
        Declare integer SendARP in Iphlpapi integer nHost, integer unsigned, string @, integer @
        Local lnRemoteAddr, lcMacAddress, iRet, iMac
        lnRemoteAddr = inet_addr( tcHostname )
        lcMacAddress = Space(6)
        iRet = SendARP(lnRemoteAddr, 0, @lcMacAddress, 6)
        If iRet = 0
            lcMacStr = []
            For iMac = 1 to 6
                lcMacStr = lcMacStr + [-] + Right(Transform(asc(subs(lcMacAddress,iMac,1)),[@0]),2)
            Endfor
            lcMacStr = subs(lcMacStr,2)
        Endif
        Declare integer WSACleanup in ws2_32
        = WSACleanup()
    Endif
    Return lcMacStr
Endfunc

* -------------------------------------
* ƻȡ IP ַ
* -------------------------------------
Function GetHostIP32 ( tcHostname )
    #Define WSADATA_SIZE  398
    #Define WS_VERSION    514
    #Define HOSTENT_SIZE  16
    Declare integer WSAStartup in ws2_32 integer wVerRq, string @lpWSAData
    Local lcWSADATA, lcReturn
    lcReturn = []
    lcWSADATA = Repli(CHR(0), WSADATA_SIZE)
    If WSAStartup (WS_VERSION, @lcWSADATA) = 0
        Local lnHOSTENTptr, lcHOSTENT, lnAddrlistPtr
        Declare integer gethostbyname in ws2_32 string hostname
        lnHOSTENTptr = gethostbyname(tcHostname)
        If lnHOSTENTptr <> 0
            lcHOSTENT = GetMemBuf (lnHOSTENTptr, HOSTENT_SIZE)
            Local lcReturn, lnAddrlistPtr, lnDataAddress
            lnAddrlistPtr = buf2dword( SUBSTR(lcHOSTENT, 13,4) )
            lnDataAddress = buf2dword( GetMemBuf (lnAddrlistPtr, 4) )
            If lnDataAddress <> 0
                lcACSAddress = GetMemBuf(lnDataAddress, 4)
                Local iIP
                For iIP = 1 TO 4
                    lcReturn = lcReturn + [.] + ltrim(STR(asc(Subs(lcACSAddress, iIP,1))))
                Endfor
                lcReturn = Subs(lcReturn,2)
            Endif
        Endif
        Declare integer WSACleanup in ws2_32
        = WSACleanup()
    Endif
    Return lcReturn
Endfunc

* -------------------------------------
*  IP ַȡ
* -------------------------------------
Function GetHostName32 ( tcHostIP )
    #Define WSADATA_SIZE  398
    #Define WS_VERSION    514
    #Define HOSTENT_SIZE   16
    Local lcWSADATAln, lcReturn
    lcReturn = []
    lcWSADATA = Repli(CHR(0), WSADATA_SIZE)
    Declare integer WSAStartup in ws2_32 integer wVerRq, string @lpWSAData
    If WSAStartup (WS_VERSION, @lcWSADATA) = 0
        #Define AF_UNSPEC      0  && unspecified
        #Define AF_UNIX        1  && local to host (pipes, portals)
        #Define AF_inET        2  && internetwork: UDP, TCP, etc.
        #Define AF_IMPLinK     3  && arpanet imp addresses
        #Define AF_PUP         4  && pup protocols: e.g. BSP
        #Define AF_CHAOS       5  && mit CHAOS protocols
        #Define AF_IPX         6  && IPX and SPX
        #Define AF_NS          6  && XEROX NS protocols
        #Define AF_ISO         7  && ISO protocols
        #Define AF_OSI         7  && OSI is ISO
        #Define AF_ECMA        8  && european computer manufacturers
        #Define AF_DATAKIT     9  && datakit protocols
        #Define AF_CCITT      10  && CCITT protocols, X.25 etc
        #Define AF_SNA        11  && IBM SNA
        #Define AF_DECnet     12  && DECnet
        #Define AF_DLI        13  && Direct data link interface
        #Define AF_LAT        14  && LAT
        #Define AF_HYLinK     15  && NSC Hyperchannel
        #Define AF_APPLETALK  16  && AppleTalk
        #Define AF_NETBIOS    17  && NetBios-style addresses
        #Define AF_VOICEVIEW  18  && VoiceView
        #Define AF_FIREFOX    19  && FireFox
        #Define AF_UNKNOWN1   20  && Somebody is using this!
        #Define AF_BAN        21  && Banyan
        #Define AF_MAX        22
        Local lnIP, lnHOSTENTptr, lcHOSTENT
        Declare integer gethostbyaddr in ws2_32 integer @addr, integer len, integer type
        Declare integer inet_addr in ws2_32 string cp
        lnIP = inet_addr( tcHostIP )
        lnHOSTENTptr = gethostbyaddr(@lnIP, 4, AF_inET)
        If lnHOSTENTptr # 0
            #Define HOSTENT_SIZE  16
            lcHOSTENT = GetMemBuf (lnHOSTENTptr, HOSTENT_SIZE)
            lcReturn = GetMemBuf( buf2dword(SUBSTR(lcHOSTENT, 1,4)), 250)
            lcReturn = SUBSTR(lcReturn, 1, AT(CHR(0),lcReturn)-1)
        Endif
        Declare integer WSACleanup in ws2_32
        = WSACleanup()
    Endif
    Return lcReturn
Endfunc

* -------------------------------------
* öھӼ
* -------------------------------------
Function NetEnumResource ( tcTableName, lplIsGetIP )
    * ൱ !/n COMMAND.COM /C net view>c:\Temp\NetComp.txt
    tcTableName = IIF(TYPE([tcTableName])=[C], tcTableName, [NetEnumCompTable])
    lplIsGetIP = IIF(TYPE([lplIsGetIP])=[L], lplIsGetIP, .F. )
    Create CURSOR (tcTableName) ( LocalName C(254), RemoteName C(254), CompComment C(254), CompProvider C(254), CompIPaddr C(15) )
    #Define RESOURCE_CONNECTED        0x1          && öӵԴ
    #Define RESOURCE_GLOBALNET        0x2          && öԴ
    #Define RESOURCE_REMEMBERED       0x3          && ֻö
    #Define RESOURCE_RECENT           0x4
    #Define RESOURCE_CONTEXT          0x5
    #Define RESOURCEUSAGE_ALL         0x0          && öԴ
    #Define RESOURCEUSAGE_CONNECTABLE 0x1          && ֻöЩܹӵԴ
    #Define RESOURCEUSAGE_CONTAinER   0x2          && ֻöٰԴԴ
    #Define RESOURCEUSAGE_ATTACHED    0x10
    #Define RESOURCETYPE_ANY          0x0          && ö͵Դ
    #Define RESOURCETYPE_DISK         0x1          && öٴԴ
    #Define RESOURCETYPE_PRinT        0x2          && öٴӡԴ
    #Define RESOURCETYPE_UNKNOWN      0xFFFF       && ֪
    #Define RESOURCEDISPLAYTYPE_DOMAin   1
    #Define RESOURCEDISPLAYTYPE_SERVER   2
    #Define RESOURCEDISPLAYTYPE_GROUP    5
    #Define RESOURCEDISPLAYTYPE_NETWORK  6
    #Define RESOURCEDISPLAYTYPE_ROOT     7
    #Define NETRESOURCE_SIZE            32
    Declare integer WNetOpenEnum in mpr.dll ;
        integer dwScope , ;
        integer dwType , ;
        integer dwUsage , ;
        string  @lpNetResource , ;
        integer @lphEnum
    Declare integer WNetEnumResource in mpr.dll ;
        integer hEnum , ;
        integer @lpcCount , ;
        string  @lpBuffer , ;
        integer @lpBufferSize
    Declare integer WNetCloseEnum in mpr.dll  ;
        integer hEnum
    Local lhEnum
    lhEnum = 0
    If WNetOpenEnum( RESOURCE_CONTEXT, RESOURCETYPE_ANY, 0, 0, @lhEnum ) = 0
        Local lnCount, lnBufferSize, lcBuffer, iԴ
        lnCount = -1
        lnBufferSize = 16384
        lcBuffer = Repli( CHR(0), lnBufferSize )
        If WNetEnumResource( lhEnum, @lnCount, @lcBuffer, @lnBufferSize ) = 0
            Local LCENTRY, lnScope, lnType, lnDisplayType, lnUsage, lcLocalName, lcRemoteName, lcComment, lcProvider
            For iԴ = 1 TO lnCount
                LCENTRY = Subs( lcBuffer, (iԴ-1)*32+1, 32)
                lnScope       = buf2dword(SUBSTR(LCENTRY, 01, 4))
                lnType        = buf2dword(SUBSTR(LCENTRY, 05, 4))
                lnDisplayType = buf2dword(SUBSTR(LCENTRY, 09, 4))
                lnUsage       = buf2dword(SUBSTR(LCENTRY, 13, 4))
                lcLocalName   = mem2str(buf2dword(SUBSTR(LCENTRY, 17, 4)))
                lcRemoteName  = mem2str(buf2dword(SUBSTR(LCENTRY, 21, 4)))
                lcComment     = mem2str(buf2dword(SUBSTR(LCENTRY, 25, 4)))
                lcProvider    = mem2str(buf2dword(SUBSTR(LCENTRY, 29, 4)))
                *Wait Window ([/]+lcRemoteName+[/]) at 1,1 TimeOut 1
                If !empt(lcRemoteName)
                    Insert Into (tcTableName) values ( lcLocalName, Strt(allt(lcRemoteName), [\\], []), ;
                        lcComment, lcProvider, iif(lplIsGetIP, GetHostIP32( Strt(allt(lcRemoteName), [\\], []) ), []) )
                Endif
            Endfor
        Endif
        = WNetCloseEnum( lhEnum )
    Endif
Endfunc

Function mem2str ( lpnMemBlock )
    #Define BUFFER_SIZE  254
    If lpnMemBlock = 0
        Return []
    Endif
    Local lnPtr, lcResult, lcBuffer, LNPOS
    lnPtr = lpnMemBlock
    lcResult = []
    Do WHILE .T.
        lcBuffer = GetMemCpy( lnPtr, BUFFER_SIZE )
        LNPOS = AT(CHR(0), lcBuffer)
        If LNPOS > 0
            lcResult = lcResult + SUBSTR(lcBuffer, 1, LNPOS-1)
            Return  lcResult
        Else
            lcResult = lcResult + lcBuffer
            lnPtr = lnPtr + BUFFER_SIZE
        Endif
    Enddo
Endfunc

Function GetMemBuf ( lnAddr, lnBufsize )
    Declare RtlMoveMemory in kernel32 As Heap2Str string @Dest, integer Src, integer nLength
    Local lcBuffer
    lcBuffer = Repli(CHR(0), lnBufsize)
    = Heap2Str (@lcBuffer, lnAddr, lnBufsize)
    Return  lcBuffer
Endfunc

Function GetMemCpy ( lnAddr, lnBufsize )
    Declare lstrcpyn in kernel32 As Heap2Str string @Dest, integer Src, integer nLength
    Local lcBuffer
    lcBuffer = Repli(CHR(0), lnBufsize)
    = Heap2Str (@lcBuffer, lnAddr, lnBufsize)
    Return  lcBuffer
Endfunc

Function buf2dword (lcBuffer)
    Return asc(SUBSTR(lcBuffer, 1,1)) + ;
        asc(SUBSTR(lcBuffer, 2,1)) * 256 +;
        asc(SUBSTR(lcBuffer, 3,1)) * 65536 +;
        asc(SUBSTR(lcBuffer, 4,1)) * 16777216
Endfunc












ȡϵͳ汾
* -------------------------------------
Function GetOSVer ( )
    Declare integer GetVersionEx in kernel32 string @lpVersioninformation
    OsVersioninfo = int2Str(148) + replicate(CHR(0), 144)
    = GetVersionEx(@OsVersioninfo)
    Return Str2int(SUBSTR(OsVersioninfo, 17, 4))
Endfunc

Function int2Str
    Lparameters lnLongVal
    Private i, retustr
    retustr = []
    For i = 24 TO 0 Step -8
        retustr = CHR(int(lnLongVal/(2^i))) + retustr
        lnLongVal = mod(lnLongVal, (2^i))
    Next
    Return retustr
Endfunc

Function Str2int
    Lparameters tcLongStr
    Private i, RetuVal
    RetuVal = 0
    For i = 0 TO 24 Step 8
        RetuVal = RetuVal + (asc(tcLongStr) * (2^i))
        tcLongStr = RIGHT(tcLongStr, LEN(tcLongStr) - 1)
    Next
    Return RetuVal
Endfunc

* -------------------------------------
* òϵͳİװĿ¼
* -------------------------------------
Function GetWindowsDir ()
    Declare integer GetWindowsDirectory in kernel32 string @lpBuffer, integer nSize
    Local lpBuffer, nSizeRet
    #Define MAX_PATH 260
    lpBuffer = SPACE( MAX_PATH )
    nSizeRet = GetWindowsDirectory (@lpBuffer, LEN(lpBuffer))
    If nSizeRet <> 0
        lpBuffer = SUBSTR (lpBuffer, 1, nSizeRet)
    Endif
    Return allt(lpBuffer)
Endfunc

* -------------------------------------
* òϵͳϵͳĿ¼
* -------------------------------------
Function GetSystemDir ( )
    Declare integer GetSystemDirectory in kernel32 string @lpBuffer, integer nSize
    Local lpBuffer, nSizeRet
    #Define MAX_PATH 260
    lpBuffer = SPACE( MAX_PATH )
    nSizeRet = GetSystemDirectory (@lpBuffer, LEN(lpBuffer))
    If nSizeRet <> 0
        lpBuffer = SUBSTR (lpBuffer, 1, nSizeRet)
    Endif
    Return allt(lpBuffer)
Endfunc

* -------------------------------------
*  Windows ¼ûʱĿ¼
* -------------------------------------
Function GetUserTempDir ( )
    Declare Integer GetTempPath in kernel32 Integer nBufferLength, String @lpBuffer
    Local lpBuffer, nSizeRet
    #Define MAX_PATH 260
    lpBuffer = SPACE( MAX_PATH )
    nSizeRet = GetTempPath( LEN(lpBuffer), @lpBuffer )
    If nSizeRet <> 0
        lpBuffer = PADR(lpBuffer, nSizeRet)
    Endif
    Return allt(lpBuffer)
Endfunc

* -------------------------------------
* ȡҵĵ·
* -------------------------------------
Function GetMyDocuments ( )
    Local IsOK, lcRetu, lcOldonError, loWshShell
    IsOK = .T.
    lcRetu = []
    lcOldonError = ON([Error])
    On Error IsOK = .F.
    loWshShell = CREATEOBJECT("WScript.Shell")
    lcRetu = loWshShell.SpecialFolders("MyDocuments")
    On Error &lcOldonError.
    Return lcRetu
Endfunc

* -------------------------------------
* ȡϵͳ·
* : ? [ҵĵ: ->], GetWinSystemDir( 0x0005 )
* -------------------------------------
Function GetWinSystemDir ( tnFolderID, tlCreateNew )
    #Define SHGFP_TYPE_CURRENT        0x0000 && ǰ·
    #Define SHGFP_TYPE_DEFAULT        0x0001 && ĬĿ¼
    #Define CSIDL_PERSONAL             0x0005 && \My Documents
    #Define CSIDL_APPDATA              0x001A && \<user name>\Application Data
    #Define CSIDL_PROGRAM_FILES_COMMON 0x002B && \Program Files\Common
    #Define CSIDL_LOCAL_APPDATA        0x001C && \<user name>\Local Settings\Applicaiton Data (non roaming)
    #Define CSIDL_COMMON_APPDATA       0x0023 && \<All Users>\Application Data
    #Define CSIDL_WINDOWS              0x0024 && \Windows
    #Define CSIDL_SYSTEM               0x0025 && \<Windows>\System
    #Define CSIDL_PROGRAM_FILES        0x0026 && \Program Files
    #Define CSIDL_FLAG_CREATE          0x8000 && 򴴽ļ

    If Vartype(tnFolderID)#"N"
        Return []
    Endif
    Local lcFolder, lnFolder
    lnFolder = tnFolderID
    If Vartype(tlCreateNew)=[L] AND tlCreateNew
        lnFolder = lnFolder + CSIDL_FLAG_CREATE
    Endif
    lcFolder = SPACE(260)
    Declare Integer SHGetFolderPath In SHFolder ;
        Integer hwndOwner, ;
        Integer nFolder, ;
        Integer hToken, ;
        Integer dwFlags, ;
        String  @pszPath
    If SHGetFolderPath(0, lnFolder, 0, SHGFP_TYPE_CURRENT, @lcFolder) # 0
        Return []
    Else
        Return Allt(Chrtran(lcFolder ,CHR(0),[]))
    Endif
Endfunc

* -------------------------------------
* ȡϵͳ·
* : ? [ҵĵ: ->], GetWinSysFolder(5)
* -------------------------------------
Function GetWinSysFolder( tnFolderID )
    #Define ZSM_PROGRAMS                 2 &&Program Groups Folder
    #Define ZSM_PERSONAL                 5 &&Personal Documents Folder
    #Define ZSM_FAVORITES                6 &&Favorites Folder
    #Define ZSM_STARTUP                  7 &&Startup Group Folder
    #Define ZSM_RECENT                   8 &&Recently Used Documents Folder
    #Define ZSM_SENDTO                   9 &&Send To Folder
    #Define ZSM_STARTMENU               11 &&Start Menu Folder
    #Define ZSM_DESKTOPDIRECTORY        16 &&Desktop Folder
    #Define ZSM_NETHOOD                 19 &&Network Neighborhood Folder
    #Define ZSM_TEMPLATES               21 &&Document Templates Folder
    #Define ZSM_COMMON_STARTMENU        22 &&Common Start Menu Folder
    #Define ZSM_COMMON_PROGRAMS         23 &&Common Program Groups Folder
    #Define ZSM_COMMON_STARTUP          24 &&Common Startup Group Folder
    #Define ZSM_COMMON_DESKTOPDIRECTORY 25 &&Common Desktop Folder
    #Define ZSM_APPDATA                 26 &&Application Data Folder
    #Define ZSM_PRINTHOOD               27 &&Printers Folder
    #Define ZSM_COMMON_FAVORITES        31 &&Common Favorites Folder
    #Define ZSM_INTERNET_CACHE          32 &&Temp. Internet Files Folder
    #Define ZSM_COOKIES                 33 &&Cookies Folder
    #Define ZSM_HISTORY                 34 &&History Folder

    If Vartype(tnFolderID)#"N"
        Return []
    Endif
    Local lcFolder
    Declare SHGetSpecialFolderPath IN Shell32 ;
        Integer hwndOwner, ;
        String @cSpecialFolderPath, ;
        Integer nWhichFolder
    lcFolder = Space(260)
    = SHGetSpecialFolderPath( 0, @lcFolder, tnFolderID )
    lcFolder = Allt(Chrtran(lcFolder ,CHR(0),[]))
    Return lcFolder
Endfunc

* -------------------------------------
* ĳļ -> DOSļ
* -------------------------------------
Function GetShortName ( tcPathName )
    tcPathName = iif(Type([tcPathName])=[C], tcPathName, [])
    Declare integer GetShortPathName in kernel32.dll String lpszLongPath, String @lpszShortPath, integer cchBuffer
    Private lpBuffer, nSizeRet
    #Define MAX_PATH 260
    lpBuffer = SPACE( MAX_PATH )
    nSizeRet = GetShortPathName( tcPathName, @lpBuffer, LEN(lpBuffer) )
    If nSizeRet <> 0
        lpBuffer = PADR(lpBuffer, nSizeRet)
    Endif
    Return allt(lpBuffer)
Endfunc

* -------------------------------------
* DOSļ -> ĳļ
* -------------------------------------
Function GetLongName( tcPathName )
    tcPathName = iif(Type([tcPathName])=[C], tcPathName, [])
    Declare integer GetLongPathName in vb5stkit.dll String lpszShortPath, String @lpszLongPath, integer cchBuffer
    Private lpBuffer, nSizeRet
    #Define MAX_PATH 260
    nSizeRet = 0
    lpBuffer = SPACE( MAX_PATH )
    nSizeRet = GetLongPathName( tcPathName, @lpBuffer, LEN(lpBuffer) )
    If nSizeRet <> 0
        lpBuffer = PADR(lpBuffer, nSizeRet)
    Endif
    Return allt(lpBuffer)
Endfunc

* -------------------------------------
* ļĬϴ򿪷ʽ()
* -------------------------------------
Function GetOpenFileExec ( tcPathFileName )
    tcPathFileName = IIF(TYPE([tcPathFileName])=[C], tcPathFileName, [])
    Local lpBuffer, lnRetuEr
    #Define MAX_PATH 260
    lpBuffer = SPACE( MAX_PATH )
    If !empt(tcPathFileName) AND FILE(tcPathFileName)
        Declare Integer FindExecutable IN shell32 String lpFile, String lpDirectory, String @lpResult
        lnRetuEr = FindExecutable( tcPathFileName, [], @lpBuffer )
        If lnRetuEr > 32
            lnRetuEr = Left(lpBuffer, AT(CHR(0), lpBuffer)-1)
        Endif
    Endif
    Return allt(lpBuffer)
Endfunc

* -------------------------------------
* ̬ע(dllocx)ؼ
* -------------------------------------
Function DllRegister ( lpLibFileName, isReg )
    isReg = IIF(TYPE([isReg])=[U], .T., isReg)
    lpProcName = IIF(isReg, "DllRegisterServer", "DllUnregisterServer" )
    Declare integer LoadLibrary in kernel32 string lpLibFileName
    Declare integer FreeLibrary in kernel32 integer hLibModule
    Declare integer GetProcAddress in kernel32 integer hModule, string lpProcName
    Declare integer CallWindowProc in user32 integer lpPrevWndFunc, integer hwnd, integer Msg, integer wParam, integer lParam

    Local hLibModule, lnAddress
    hLibModule = LoadLibrary( lpLibFileName )
    If hLibModule # 0
        lnAddress = GetProcAddress( hLibModule, lpProcName )
        If lnAddress # 0
            If CallWindowProc( lnAddress, 0,0,0,0) = 0
                = FreeLibrary( hLibModule )
                Return .T.
            Endif
        Endif
        = FreeLibrary( hLibModule )
    Endif
    Return .F.
Endfunc

* -------------------------------------
* ȡ  ·ļ
* -------------------------------------
Function GetMyFileName ()
    Declare integer GetModuleFileName in kernel32 integer  hModule, string @ lpFilename, integer nSize
    Local lcFileName, lnLen
    lcFileName = SPACE(250)
    lnLen = GetModuleFileName (0, @lcFileName, LEN(lcFileName))
    Return Left(lcFileName, lnLen)
Endfunc

* -------------------------------------
* ȡ ļʱ
* -------------------------------------
Function GetFileLastWriteTime ( tcFileName )
    #Define BYTE_2               256
    #Define OF_READ                0
    #Define OF_SHARE_DENY_NONE    64
    #Define HFILE_ERROR           -1
    #Define dwordPlus     4294967296
    Declare integer GetFileTime in kernel32 integer hFile, string @lpCreationTime, string @lpLastAccessTime, string @lpLastWriteTime
    Declare integer FileTimeToLocalFileTime in kernel32 string lpFileTime, string @lpLocalFileTime
    Declare integer FileTimeToSystemTime in kernel32 string FILETIME, string @SYSTEMTIME
    Declare integer OpenFile in kernel32 string lpFileName, string @lpReOpenBuff, integer wStyle
    Declare integer CloseHandle in kernel32 integer hObject

    Local lpCreationTime, lpLastAccessTime, lpLastWriteTime, lcFileName, hFile, FileTimeBuffer
    lpCreationTime = SPACE( 8 )
    lpLastAccessTime = SPACE( 8 )
    lpLastWriteTime = SPACE( 8 )
    lpReOpenBuff = Repli (CHR(0), 250)
    hFile = OpenFile (tcFileName, @lpReOpenBuff, OF_SHARE_DENY_NONE)
    = GetFileTime( hFile, @lpCreationTime, @lpLastAccessTime, @lpLastWriteTime )
    = CloseHandle (hFile)

    Local SystemTimeBuffer, FileTimeBuffer
    FileTimeBuffer = SPACE(8)
    = FileTimeToLocalFileTime( lpLastWriteTime, @FileTimeBuffer )
    SystemTimeBuffer = SPACE(16)
    fResult = FileTimeToSystemTime(FileTimeBuffer, @SystemTimeBuffer)

    If fResult = 0
        lptLastWriteTime = CToT( [1901.01.01 00:00:01] )
    Else
        lnYea = asc(SUBSTR(SystemTimeBuffer,  1, 1)) + (asc(SUBSTR(SystemTimeBuffer,  2, 1))* BYTE_2)
        lnMon = asc(SUBSTR(SystemTimeBuffer,  3, 1)) + (asc(SUBSTR(SystemTimeBuffer,  4, 1))* BYTE_2)
        lnDay = asc(SUBSTR(SystemTimeBuffer,  7, 1)) + (asc(SUBSTR(SystemTimeBuffer,  8, 1))* BYTE_2)
        lnHou = asc(SUBSTR(SystemTimeBuffer,  9, 1)) + (asc(SUBSTR(SystemTimeBuffer, 10, 1))* BYTE_2)
        lnMin = asc(SUBSTR(SystemTimeBuffer, 11, 1)) + (asc(SUBSTR(SystemTimeBuffer, 12, 1))* BYTE_2)
        lnSec = asc(SUBSTR(SystemTimeBuffer, 13, 1)) + (asc(SUBSTR(SystemTimeBuffer, 14, 1))* BYTE_2)
        lptLastWriteTime = CToT( ;
            padl(allt(str(INT(lnYea))),4,[0]) + [.] + ;
            padl(allt(str(INT(lnMon))),2,[0]) + [.] + ;
            padl(allt(str(INT(lnDay))),2,[0]) + [ ] + ;
            padl(allt(str(INT(lnHou))),2,[0]) + [:] + ;
            padl(allt(str(INT(lnMin))),2,[0]) + [:] + ;
            padl(allt(str(INT(lnSec))),2,[0]) )
    Endif
    Return lptLastWriteTime
Endfunc

* -------------------------------------












 
* ------------------------------------------------
* : ýļļб
* : 
* : 20031019
* ------------------------------------------------
* ʾ:
* ------------------------------------------------
* 1ýļ(ֻһ)
= PlayMicList( [Z:\OKSong\ʤ\ǵԼ.mpg], .F. )
Return

* 2ļб(ѭ)
Local lcSysPath
lcSysPath = addb(JustPath(SYS(16,1)))
= PlayMicList( FileToStr( addb(lcSysPath)+[PlayMicList.txt] ), .T. )

Return

* ------------------------------------------------
* :
* ------------------------------------------------
Function PlayMicList( tcPlayListStr, tlISRePlayMic )
 * ------------------------------------------------
 * : ,ýļļб
 * : tcPlayListStr - ļбַ,ļûسзָ
 *       tISRePlayMic  - Ƿѭб,ĬΪ.T.
 * ------------------------------------------------
 If Type([tcPlayListStr])=[C]
  If !empt(tcPlayListStr)
   If VarType(_Screen.MicTime) = [O]
    _Screen.RemoveObject([MicTime])
   Endif
   _Screen.AddObject([MicTime], [MicTime])
   With _Screen.MicTime
    If Para()=2 and VarType(tlISRePlayMic) = [L]
     .ISRePlayMic = tlISRePlayMic
    Endif
    Local lcCR, lcList, lnFile, liFile, lcFile
    lcCR = Chr(13) + Chr(10)
    lcList = lcCR + tcPlayListStr + lcCR
    lnFile = Occu( lcCR, lcList ) - 1
    For liFile = 1 to lnFile
     lnBeg = at( lcCR, lcList, liFile ) + 2
     lnEnd = at( lcCR, lcList, liFile + 1 )
     lcFile = subs( lcList, lnBeg, lnEnd-lnBeg )
     If File(lcFile)
      If MicCanBeOpen(lcFile) > 0
       .nMicCount = .nMicCount + 1
       Dime .aMicList(.nMicCount)
       .aMicList(.nMicCount) = lcFile
      Endif
     Endif
    Endfor
    = SendMciString( [Close MICTEMP] )
    = SendMciString( [Close MICVFPPLAY] )
    .Enabled = .T.
   Endwith
  Endif
 Endif
Endfunc

Function MicCanBeOpen( tcFileName )
 tcFileName = iif(Type([tcFileName])=[C], tcFileName, [])
 Local lnMicLength
 lnMicLength = 0
 If SendMciString( [Open ] + GetShortFile(tcFileName) + [ Alias MICTEMP] )#[MicError]
  lnMicLength = Val( SendMciString([Status MICTEMP Length]) ) && ȡý峤
  = SendMciString( [Close MICTEMP] )
 Endif
 Return lnMicLength
Endfunc

Function OpenAndPlayMicFile( tcPlayFile )
 tcPlayFile = Iif(Type([tcPlayFile])=[C],tcPlayFile,[])
 If !Empt(tcPlayFile) And File(tcPlayFile)
  Local lcShotFile, lnVideoHwnd
  lcShotFile = GetShortFile(tcPlayFile)
  = SendMciString( [Close MICVFPPLAY] )
  = SendMciString( [Open ] + lcShotFile + [ Alias MICVFPPLAY] )
  lnMicLength = Val(SendMciString( [Status MICVFPPLAY Length] ) )
  = SendMciString( [Play MICVFPPLAY From 0] )
 Endif
Endfunc

Function SendMciString( tcMCIcmd )
 Declare integer mciSendString     in WINMM String, String, integer,integer
 Declare integer mciGetErrorString in WINMM integer, String, integer
 Local lcRetStr, lcErrStr, lnRetVal
 lcRetStr = Space( 80)
 lnRetVal = mciSendString( tcMCIcmd, @lcRetStr, Len(lcRetStr), 0 )
 If lnRetVal = 0
  Return Trim(Strtran(lcRetStr,chr(0),[]))
 Else
  Return [MicError]
 Endif
Endfunc

Function GetShortFile( tcPathFileName )
 tcPathFileName = iif(Type([tcPathFileName])=[C],tcPathFileName,[])
 Local lcRetuShotFile, lnRetuShotFile
 Declare integer GetShortPathName in kernel32 String, String, integer
 lcRetuShotFile = Space(255)
 lnRetuShotFile = GetShortPathName(tcPathFileName, @lcRetuShotFile, Len(tcPathFileName))
 lcRetuShotFile = IIF(empt(lcRetuShotFile), tcPathFileName, Left(lcRetuShotFile, lnRetuShotFile) )
 Return lcRetuShotFile
Endfunc

Define CLASS MicTime AS Timer
 Interval = 1000
 Name = [MicTime]
 Enabled = .F.
 nMicCount = 0
 nMicvalue = 0
 ISPlayInit = .T.
 ISRePlayMic = .T.
 Dime aMicList(1)
 aMicList(1) = []
 Procedure Timer
  With This
   lnMicLength = Val(SendMciString( [Status MICVFPPLAY Length] ) )    && ȡýܳ
   lnMicPosition = Val(SendMciString( [Status MICVFPPLAY Position]) ) && ȡǰĲλ
   If lnMicPosition >= lnMicLength
    = SendMciString( [Close MICVFPPLAY] )
    If .nMicCount = 0
     .Enabled = .F.
    Else
     If .ISPlayInit
         .nMicvalue = 1
      .ISPlayInit = .F.
      = OpenAndPlayMicFile( .aMicList(.nMicvalue) )
     Else
      If .nMicCount <= .nMicvalue
       If .ISRePlayMic
        .nMicvalue = 1
        = OpenAndPlayMicFile( .aMicList(.nMicvalue) )
       Else
        .Enabled = .F.
       Endif
      Else
       .nMicvalue = .nMicvalue + 1
       = OpenAndPlayMicFile( .aMicList(.nMicvalue) )
      Endif
     Endif
    Endif
   Endif
  Endwith
 Endproc
Enddefine
 







 ƪ7עסVFPӦóʹô
עWindowsϵͳбϵͳӲϢӦóϢûϢһݿ⣬ΪӦóṩ˱õѳWindowsϵͳУСRegEdit.exeļӴ򿪵ע༭пԿעɣ ĿĵһΪע˫ʱĸ֮ΪӼڵҲǸӼļֵÿһӼӦĬֵòͬļֵʾļֵĬֵļֵΪһմ

VFPӦóждעWIN32APIWindows 32λӦóӿڣΪʹVFPһWIN32APIDECLAREÿһúעᣨʽΪDECLARE [cFunctionType] FunctionName IN LibraryName [AS AliasName] ;

[cParamType1 [@] ParamName1,cParamType2 [@] ParamName2, ...]

иΪcFunctionTypeΪķֵͣSHORTINTEGERLONGSINGLEDOUBLESTRING֮һûзֵʡcFunctionTypeFunctionNameָWIN32APIעСдVFP.DLL⣨LibraryNameú úVFPĺͬASӾȡһϷVFPLibraryNameָⲿWindows .DLLƣȡWIN32APIVFPKERNEL32.DLL, GDI32.DLL, USER32.DLL, MPR.DLLADVAPI32.DLLFunctionNamecParamTypeָͣΪINTEGERLONGSINGLEDOUBLESTRING֮һVFPݲķʽֵ֣ݺͰãݣǰֻѱҲΪֵںڲ޸ĸñֵǰѱóĵַںڲ޸ĸñֵҪںڲ޸ĸñֵڱз÷ֵVFPڱǰӡ@ʾôݲӡ@ʾֵݲڱʾиǰôݻǰֵݣDECLAREͺһ֪
ʾÿһΣͽעHKEY_CURRENT_USER\SOFTWARE\LYTAPPӼTimesForUseµֵ1ֱ12Ϊֹ
* һINTEGERֵӦ

#DEFINE HKEY_CLASSES_ROOT bitset(0,31) &&-2147483648
#DEFINE HKEY_CURRENT_USER bitset(0,31)+1 &&-2147483647
#DEFINE HKEY_LOCAL_MACHINE bitset(0,31)+2 &&-2147483646
#DEFINE HKEY_USER bitset(0,31)+3 &&-2147483645
#DEFINE HKEY_CURRENT_CONFIG bitset(0,31)+5 &&-2147483643
#DEFINE HKEY_DYN_DATA bitset(0,31)+6 &&-2147483642

* ֵͣ1-ַ3-ƣ4-

#DEFINE REG_SZ 1
#DEFINE REG_BINARY 3
#DEFINE REG_DWORD 4

* API0ʱɹ

DECLARE Integer RegOpenKey IN Win32API ;
Integer nHKey, String @cSubKey, Integer @nResult

DECLARE Integer RegCreateKey IN Win32API ;
Integer nHKey, String @cSubKey, Integer @nResult

DECLARE Integer RegSetvalueEx IN Win32API ;
Integer hKey, String lpszvalueName, Integer dwReserved,;
Integer fdwType, String lpbData, Integer cbData

DECLARE Integer RegQueryvalueEx IN Win32API ;
Integer nHKey, String lpszvalueName, Integer dwReserved,;
Integer @lpdwType,string @lpbData, Integer @lpcbData

* DECLARE Integer RegDeleteKey IN Win32API ;
* Integer nHKey, String @cSubKey

* DECLARE Integer RegDeletevalue IN Win32API ;
* Integer nHKey, String cSubKey

* DECLARE Integer RegCloseKey IN Win32API ;
* Integer nHKey

csubkey='Software\lytapp'
nresult=0 
if regopenkey(HKEY_CURRENT_USER,@csubkey,@nresult)#0 
RegCreateKey(HKEY_CURRENT_USER,csubkey,@nresult)
endif

* nresultдָӼHKEY_CURRENT_USER\Software\lytappĳֵ

lpdwtype=0
lpbdata=space(256)
lpcbdata=len(lpbdata)
if RegQueryvalueEx(nresult,'TimesForUse',0,@lpdwtype,@lpbdata,@lpcbdata)=0
do case 
case lpdwtype=REG_SZ
lpbdata=left(lpbdata,lpcbdata-1)
if val(lpbdata)<12
lpbdata=alltrim(str(val(lpbdata)+1))
messagebox('δע֮ǰֻʹ12Σ'+CHR(13)+' ǵ'+ ;
lpbdata+'ʹñ')
lpbdata=lpbdata+chr(0)
cbdata=len(lpbdata)
RegSetvalueEx(nresult,'TimesForUse',0,REG_SZ,lpbdata,cbdata)
else
messagebox(" ѹϣ"+CHR(13)+" ϵעˡ")
endif
case lpdwtype=REG_BINARY
messagebox('üֵΪݡ')
case lpdwtype=REG_DWORD
messagebox('üֵΪݣ NN=0'+CHR(13)+'for i=1 to 4'+CHR(13)+ ;
'NN=NN+VAL(SUBSTR(lpbdata,i,1)*16^(2*i-2)'+CHR(13)+ ;
'endfor ȡֵ')
otherwise
messagebox('δ֪ݣ')
endcase
else
lpbdata='1'
messagebox('δע֮ǰֻʹ12Σ'+CHR(13)+' ǵ'+lpbdata+'ʹñ')
lpbdata=lpbdata+chr(0)
RegSetvalueEx(nresult,'TimesForUse',0,REG_SZ,lpbdata,2)
endif

* 棺ûϤעʱòҪ޸еݣ򣬿ϵͳıûע޸ģ޸ǰýעݡ
 










