Download Pelles C here: http://www.smorgasbordet.com/pellesc/
Quote from: John Z on December 11, 2025, 03:34:34 PMNew resizer with the ability to resize the font along with the controls if desired.
Library sources, and library_demo sources attached.
Version will show as 1.1001
John Z
Quote from: MrBcx on December 10, 2025, 04:21:11 PMI have attached my four Bcx Basic Task Scheduler source codes, so that peopleBCX seems to be powerful
can examine the codes without needing to sign up on the Bcx forum.
The BCX Translator is needed, if you want to examine the resulting C/C++ codes.
I successfully tested each using Pelles C, MSVC, Mingw64, and Clang.

ComCpp2C2.exe EnumTasks2.cpp > EnumTasks2.cit just convert from cpppTaskCollection->Release();to C pTaskCollection->lpVtbl->Release(pTaskCollection);/********************************************************************
This sample enumerates through all running tasks on the local computer and
displays their name and state.
********************************************************************/
#define WIN32_LEAN_AND_MEAN
#define _WIN32_DCOM
#include <windows.h>
#include <stdio.h>
//#include <comdef.h>
// Include the task header file.
#include <taskschd.h>
#pragma comment(lib, "taskschd.lib")
//#pragma comment(lib, "comsupp.lib")
#pragma comment(lib, "ole32.lib")
#pragma comment(lib, "oleaut32.lib")
int __cdecl wmain()
{
// ------------------------------------------------------
// Initialize COM.
HRESULT hr = CoInitializeEx(NULL, COINIT_MULTITHREADED);
if( FAILED(hr) )
{
printf("\nCoInitializeEx failed: %x", hr );
return 1;
}
// Set general COM security levels.
hr = CoInitializeSecurity(
NULL,
-1,
NULL,
NULL,
RPC_C_AUTHN_LEVEL_PKT_PRIVACY,
RPC_C_IMP_LEVEL_IMPERSONATE,
NULL,
0,
NULL);
if( FAILED(hr) )
{
printf("\nCoInitializeSecurity failed: %x", hr );
CoUninitialize();
return 1;
}
// ------------------------------------------------------
// Create an instance of the Task Service.
ITaskService *pService = NULL;
hr = CoCreateInstance( &CLSID_TaskScheduler,
NULL,
CLSCTX_INPROC_SERVER,
&IID_ITaskService,
(void**)&pService );
if (FAILED(hr))
{
printf("Failed to CoCreate an instance of the TaskService class: %x", hr);
CoUninitialize();
return 1;
}
// Connect to the task service.
VARIANT v1;
VariantInit(&v1);
hr = pService->lpVtbl->Connect(pService, v1, v1, v1, v1);
if( FAILED(hr) )
{
printf("ITaskService::Connect failed: %x", hr );
pService->lpVtbl->Release(pService);
CoUninitialize();
return 1;
}
// Get the running tasks.
IRunningTaskCollection* pRunningTasks = NULL;
hr = pService->lpVtbl->GetRunningTasks(pService,TASK_ENUM_HIDDEN, &pRunningTasks);
pService->lpVtbl->Release(pService);
if( FAILED(hr) )
{
printf("Cannot get Root Folder pointer: %x", hr );
CoUninitialize();
return 1;
}
LONG numTasks = 0;
hr = pRunningTasks->lpVtbl->get_Count(pRunningTasks,&numTasks);
if( numTasks == 0 )
{
printf("\nNo Tasks are currently running" );
pRunningTasks->lpVtbl->Release(pRunningTasks);
CoUninitialize();
return 1;
}
printf("\nNumber of running tasks : %d", numTasks );
TASK_STATE taskState;
v1.vt = VT_I4;
for(LONG i=1; i <= numTasks; i++)
{
v1.lVal = i;
IRunningTask* pRunningTask = NULL;
hr = pRunningTasks->lpVtbl->get_Item(pRunningTasks, v1, &pRunningTask );
if( SUCCEEDED(hr) )
{
BSTR taskName = NULL;
hr = pRunningTask->lpVtbl->get_Name(pRunningTask,&taskName);
if( SUCCEEDED(hr) )
{
printf("\nTask Name: %ls", taskName);
SysFreeString(taskName);
hr = pRunningTask->lpVtbl->get_State(pRunningTask,&taskState);
if (SUCCEEDED (hr) )
printf("\n\tState: %d", taskState);
else
printf("\n\tCannot get the registered task state: %x", hr);
}
else
{
printf("\nCannot get the registered task name: %x", hr);
}
pRunningTask->lpVtbl->Release(pRunningTask);
}
else
{
printf("\nCannot get the registered task item at index=%d: %x", i+1, hr);
}
}
pRunningTasks->lpVtbl->Release(pRunningTasks);
CoUninitialize();
return 0;
}
// Connect to the task service.
//hr = pService->Connect(_variant_t(), _variant_t(), _variant_t(), _variant_t());
hr = pService->lpVtbl->Connect(pService, v1, v2, v3, v4);
those variants are optional, but C compiler don't allow NULL for them.Page created in 0.055 seconds with 15 queries.