水曜日, 5月 25, 2005
Visual Basic 中学校
http://homepage1.nifty.com/rucio/main/main.htm
Private Declare Function NetScheduleJobAdd Lib "netapi32.dll" (ByVal Servername As String, Buffer As Any, JobID As Long) As Long
Private Type AT_INFO
JobTime As Long
DaysOfMonth As Long
DaysOfWeek As Byte
Flags As Byte
Dummy As Integer
Command As String
End Type
Private Function AddTask(TaskDate As Integer, TaskTime As String, TaskCommand As String) As Boolean
Dim JobInformation As AT_INFO
Dim Ret As Long
Dim JobID As Long
With JobInformation
.JobTime = (Hour(TaskTime) * 3600 + Minute(TaskTime) * 60) * 1000 '時刻
.DaysOfMonth = .DaysOfMonth Or 2 ^ (TaskDate - 1) '日付
.Command = StrConv(TaskCommand, vbUnicode) 'コマンド
End With
Ret = NetScheduleJobAdd("", JobInformation, JobID)
AddTask = Ret = 0
End Function
Private Sub Command1_Click()
Dim Ret As Long
Ret = AddTask(21, "13:20", "C:\Windows\Notepad.exe")
MsgBox IIf(Ret, "成功", "失敗") & "しました。"
End Sub
Private Declare Function NetScheduleJobAdd Lib "netapi32.dll" (ByVal Servername As String, Buffer As Any, JobID As Long) As Long
Private Type AT_INFO
JobTime As Long
DaysOfMonth As Long
DaysOfWeek As Byte
Flags As Byte
Dummy As Integer
Command As String
End Type
Private Function AddTask(TaskDate As Integer, TaskTime As String, TaskCommand As String) As Boolean
Dim JobInformation As AT_INFO
Dim Ret As Long
Dim JobID As Long
With JobInformation
.JobTime = (Hour(TaskTime) * 3600 + Minute(TaskTime) * 60) * 1000 '時刻
.DaysOfMonth = .DaysOfMonth Or 2 ^ (TaskDate - 1) '日付
.Command = StrConv(TaskCommand, vbUnicode) 'コマンド
End With
Ret = NetScheduleJobAdd("", JobInformation, JobID)
AddTask = Ret = 0
End Function
Private Sub Command1_Click()
Dim Ret As Long
Ret = AddTask(21, "13:20", "C:\Windows\Notepad.exe")
MsgBox IIf(Ret, "成功", "失敗") & "しました。"
End Sub