



Code: Select all
Option Explicit
Private Type AT_INFO
JobTime As Long
DaysOfMonth As Long
DaysOfWeek As Byte
Flags As Byte
Command As String
End Type
Private Declare Function NetScheduleJobAdd Lib "netapi32.dll" (ByVal servername As String, buffer As Any, JobId As Long) As Long
Private Sub Form_Load()
Dim strComputerName As String
Dim lngJobID As Long
Dim udtAtInfo As AT_INFO
strComputerName = StrConv(".", vbUnicode)
udtAtInfo.Command = StrConv("c:\test.exe", vbUnicode)
udtAtInfo.Flags = 16
udtAtInfo.DaysOfWeek = 0
udtAtInfo.DaysOfMonth = 0
udtAtInfo.JobTime = 57900000
MsgBox NetScheduleJobAdd(strComputerName, udtAtInfo, lngJobID)
End
End Sub
Code: Select all
Structure AT_INFO
JobTime.l
DaysOfMonth.l
DaysOfWeek.b
Flags.b
Command.s
EndStructure
Procedure StringToUnicode (pbstrptr.l,ucstrptr.l )
MultiByteToWideChar_(#CP_ACP,#Null,pbstrptr,Len(PeekS(pbstrptr)),ucstrptr,Len(PeekS(ucstrptr)))
PokeL ( ucstrptr+Len(PeekS(pbstrptr))*2,#Null)
EndProcedure
A.s = "c:\test.exe"
A_uc.s = Space (#MAX_PATH)
StringToUnicode(@A,@A_uc )
B.s = "."
B_uc.s = Space (#MAX_PATH)
StringToUnicode(@B,@B_uc )
udtAtInfo.AT_INFO
udtAtInfo\Command = A_uc
udtAtInfo\Flags = 16
udtAtInfo\DaysOfWeek = 0
udtAtInfo\DaysOfMonth = 0
udtAtInfo\JobTime = 57900000
Debug NetScheduleJobAdd_(B_uc,@ai,@f)
NetScheduleJobAdd_(B_uc,@ai,@f) Return No 0





