these examples use the wrapper functions posted in this thread:
http://www.powerbasic.com/support/pb...ad.php?t=24506
note
if you have any comments, please use this thread:
http://www.powerbasic.com/support/pb...ad.php?t=21275
------------------
[this message has been edited by josé roca (edited march 04, 2005).]
http://www.powerbasic.com/support/pb...ad.php?t=24506
note
if you have any comments, please use this thread:
http://www.powerbasic.com/support/pb...ad.php?t=21275
Code:
' ******************************************************************************************** ' this example enumerates all the tasks in the scheduled tasks folder of the local computer. ' ******************************************************************************************** #compile exe #dim all #include "win32api.inc" #include "iunknown.inc" #include "tb_mstsk.inc" %clsctx_inproc_server = &h1 ' ******************************************************************************************** ' main ' ******************************************************************************************** function pbmain local hr as long local clsid_ctaskscheduler as guid local iid_itaskscheduler as guid local pits as dword local pienum as dword local tasks_to_retrieve as dword local dwfetchedtasks as dword local rgpwsznames as dword ptr local buffer as string local bstrlen as long local i as long ' create a task scheduler object clsid_ctaskscheduler = guid$("{148bd52a-a2ab-11ce-b11f-00aa00530503}") iid_itaskscheduler = guid$("{148bd527-a2ab-11ce-b11f-00aa00530503}") hr = cocreateinstance(clsid_ctaskscheduler, byval %null, %clsctx_inproc_server, iid_itaskscheduler, pits) if istrue hr or isfalse pits then exit function ' call itaskscheduler_enum to get an enumeration object hr = itaskscheduler_enum(pits, pienum) ' release the task scheduler interface iunknown_release pits ' terminate if itaskscheduler_enum has failed if istrue hr or isfalse pienum then exit function ' call ienumworkitems_next to retrieve tasks. note that ' this example tries to retrieve five tasks for each call tasks_to_retrieve = 5 do ' retrieve the tasks hr = ienumworkitems_next(pienum, tasks_to_retrieve, rgpwsznames, dwfetchedtasks) if isfalse dwfetchedtasks then exit do if istrue rgpwsznames then for i = 0 to dwfetchedtasks - 1 ' extract the name (unicode) and show it bstrlen = lstrlenw(byval @rgpwsznames[i]) if istrue bstrlen then buffer = peek$(@rgpwsznames[i], bstrlen * 2) msgbox acode$(buffer) end if ' free the task name cotaskmemfree @rgpwsznames[i] next end if loop ' release the array if istrue rgpwsznames then cotaskmemfree rgpwsznames ' release the collection if istrue pienum then iunknown_release pienum end function ' ********************************************************************************************
------------------
[this message has been edited by josé roca (edited march 04, 2005).]
Comment