Has anyone successfully used this in VB?
I can use NetScheduleJobAdd to add a task to the task scheduler through VB, but I cannot find a way to list all the tasks.
This is what I am trying to call.
The call returns successfully, but I don't know how to get all the values out of udtAtInfo.
It seams that it should return an array of these, but I am lost.
VB Code:
  1. 'In form
  2.     lngWin32apiResultCode = NetScheduleJobEnum("", udtAtInfo, MAX_PREFERRED_LENGTH, lOutEntriesRead, lOutTotal, 0)
  3.  
  4. 'In module
  5. Declare Function NetScheduleJobAdd Lib "netapi32.dll" (ByVal Servername As String, Buffer As Any, JobId As Long) As Long
  6. Declare Function NetScheduleJobEnum Lib "netapi32.dll" (ByVal Servername As String, Buffer As Any, PreferredMaximumLength As Long, EntriesRead As Long, TotalEntries As Long, ResumeHandle As Long) As Long
  7.  
  8. ' Schedule structure
  9. Type AT_INFO
  10.     JobId As Long
  11.     JobTime     As Long
  12.     DaysOfMonth As Long
  13.     DaysOfWeek  As Byte
  14.     Flags       As Byte
  15.     dummy       As Integer
  16.     Command     As String
  17. End Type
  18.  
  19. ' Schedule constants
  20. Public Const JOB_RUN_PERIODICALLY = &H1
  21. Public Const JOB_NONINTERACTIVE = &H10
  22. Public Const NERR_Success = 0
  23. Public Const MAX_PREFERRED_LENGTH As Long = -1