News:

Download Pelles C here: http://www.smorgasbordet.com/pellesc/

Main Menu

Recent posts

#1
Work in progress / Re: Task Schedule 2.0 examples
Last post by Vortex - December 11, 2025, 09:12:30 PM
Hi Timo,

Exactly, BCX is very powerful. The BCX translator has a very rich library of functions.
#2
User contributions / Re: Simple resizer Library
Last post by MrBcx - December 11, 2025, 04:04:54 PM
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

Thanks John - showing good progress.
#3
User contributions / Re: Simple resizer Library
Last post by John Z - December 11, 2025, 03:34:34 PM
New 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
#4
Work in progress / Re: Task Schedule 2.0 examples
Last post by TimoVJL - December 11, 2025, 10:11:30 AM
Quote from: MrBcx on December 10, 2025, 04:21:11 PMI have attached my four Bcx Basic Task Scheduler source codes, so that people
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.


BCX seems to be powerful  :)
#5
Work in progress / Re: Task Schedule 2.0 examples
Last post by TimoVJL - December 11, 2025, 04:47:55 AM
https://learn.microsoft.com/en-us/windows/win32/taskschd/displaying-task-names-and-state--c---

usage example:
ComCpp2C2.exe EnumTasks2.cpp > EnumTasks2.cit just convert from cpp
pTaskCollection->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;
}
#6
General discussion / Re: Pellesc site down?
Last post by John Z - December 11, 2025, 12:04:05 AM
registration expired and has not (yet?) been renewed.

When the site is not available the request is rerouted to that page by whatever server was being used at Network Solutions.

John Z
#7
Work in progress / Re: Task Schedule 2.0 examples
Last post by Vortex - December 10, 2025, 08:37:42 PM
Hi Timo,

Thanks for your ComCpp2C2 tool. Kindly, could you please provide an example explaining how to use the tool?
#8
Work in progress / Re: Task Schedule 2.0 examples
Last post by MrBcx - December 10, 2025, 04:21:11 PM
I have attached my four Bcx Basic Task Scheduler source codes, so that people
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.

#9
Work in progress / Re: Task Schedule 2.0 examples
Last post by TimoVJL - December 10, 2025, 04:14:32 AM
My idea was to learn convert MS C++ code to Pelles C code.

Nice to have also MrBcx in this topic too.

I didn't use ComCpp2C2 for conversion.

One example:
https://learn.microsoft.com/en-us/windows/win32/api/taskschd/nf-taskschd-itaskservice-connect
    //  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.
Just an one empty VARIANT could be used too ?

If you don't have msvcrt.libs, just remove USE_MSVCRT define from projects
#10
General discussion / Re: Pellesc site down?
Last post by alderman2 - December 09, 2025, 10:27:37 PM
Does anyone know why Pelle's website is not up?
Why is there an image with links on the page that lead to strange things?