News:

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

Main Menu

Recent posts

#11
General discussions / smorgasbordet.com/pellesc/ has...
Last post by Cbeginner - November 23, 2025, 05:49:24 PM
Hopefully the domain get's renewed soon but could a moderator post V13 to the downloads section?

I was about to install on a new PC but I guess not right now  :'(
#12
Work in progress / Re: ChatGPT examples
Last post by Quin - November 23, 2025, 12:25:46 PM
Very nice, Vortex!
#13
Work in progress / Re: ChatGPT examples
Last post by Vortex - November 23, 2025, 10:53:24 AM
Retrieving boot time with COM \ ( Component Oject Modeling ) :

/*
    boot_time_wmi_local.c
    Display Windows boot time and uptime (local time)
    Works with Pelles C, uses WMI (Win32_OperatingSystem.LastBootUpTime)
*/

#define _CRT_SECURE_NO_WARNINGS
#include <windows.h>
#include <stdio.h>
#include <wbemidl.h>
#include <wchar.h>

#pragma comment(lib, "wbemuuid.lib")

// Convert WMI "yyyymmddHHMMSS.mmmmmmsUUU" to SYSTEMTIME (local)
BOOL ParseWmiTime(LPCWSTR wmiTime, SYSTEMTIME *st)
{
    if (!wmiTime || wcslen(wmiTime) < 14)
        return FALSE;

    swscanf(wmiTime, L"%4hu%2hu%2hu%2hu%2hu%2hu",
            &st->wYear, &st->wMonth, &st->wDay,
            &st->wHour, &st->wMinute, &st->wSecond);
    st->wMilliseconds = 0;
    return TRUE;
}

int main(void)
{
    HRESULT hr;
    IWbemLocator *pLoc = NULL;
    IWbemServices *pSvc = NULL;
    IEnumWbemClassObject *pEnum = NULL;
    IWbemClassObject *pObj = NULL;
    ULONG ret;
    VARIANT vt;
    SYSTEMTIME stBoot;
    FILETIME ftBoot, ftNow;
    ULONGLONG boot64, now64, diff64, diffSec;
    ULONGLONG days, hrs, mins, secs;

    // Initialize COM
    hr = CoInitializeEx(0, COINIT_MULTITHREADED);
    if (FAILED(hr)) {
        printf("CoInitializeEx failed: 0x%lx\n", hr);
        return 1;
    }

    // Initialize COM security
    hr = CoInitializeSecurity(NULL, -1, NULL, NULL,
                              RPC_C_AUTHN_LEVEL_DEFAULT,
                              RPC_C_IMP_LEVEL_IMPERSONATE,
                              NULL, EOAC_NONE, NULL);
    if (FAILED(hr)) {
        printf("CoInitializeSecurity failed: 0x%lx\n", hr);
        CoUninitialize();
        return 1;
    }

    // Create WMI locator
    hr = CoCreateInstance(&CLSID_WbemLocator, 0, CLSCTX_INPROC_SERVER,
                          &IID_IWbemLocator, (LPVOID *)&pLoc);
    if (FAILED(hr)) {
        printf("CoCreateInstance failed: 0x%lx\n", hr);
        CoUninitialize();
        return 1;
    }

    // Connect to ROOT\CIMV2
    hr = pLoc->lpVtbl->ConnectServer(pLoc,
                                    L"ROOT\\CIMV2",
                                    NULL, NULL, 0, 0, 0, 0,
                                    &pSvc);
    if (FAILED(hr)) {
        printf("ConnectServer failed: 0x%lx\n", hr);
        pLoc->lpVtbl->Release(pLoc);
        CoUninitialize();
        return 1;
    }

    // Set proxy security levels (cast to IUnknown for Pelles C)
    hr = CoSetProxyBlanket((IUnknown *)pSvc,
                          RPC_C_AUTHN_WINNT,
                          RPC_C_AUTHZ_NONE,
                          NULL,
                          RPC_C_AUTHN_LEVEL_CALL,
                          RPC_C_IMP_LEVEL_IMPERSONATE,
                          NULL,
                          EOAC_NONE);
    if (FAILED(hr)) {
        printf("CoSetProxyBlanket failed: 0x%lx\n", hr);
        pSvc->lpVtbl->Release(pSvc);
        pLoc->lpVtbl->Release(pLoc);
        CoUninitialize();
        return 1;
    }

    // Query LastBootUpTime
    hr = pSvc->lpVtbl->ExecQuery(pSvc, L"WQL",
                                L"SELECT LastBootUpTime FROM Win32_OperatingSystem",
                                WBEM_FLAG_FORWARD_ONLY | WBEM_FLAG_RETURN_IMMEDIATELY,
                                NULL, &pEnum);
    if (FAILED(hr)) {
        printf("ExecQuery failed: 0x%lx\n", hr);
        pSvc->lpVtbl->Release(pSvc);
        pLoc->lpVtbl->Release(pLoc);
        CoUninitialize();
        return 1;
    }

    // Read result
    hr = pEnum->lpVtbl->Next(pEnum, WBEM_INFINITE, 1, &pObj, &ret);
    if (SUCCEEDED(hr) && ret) {
        VariantInit(&vt);
        hr = pObj->lpVtbl->Get(pObj, L"LastBootUpTime", 0, &vt, 0, 0);
        if (SUCCEEDED(hr) && vt.vt == VT_BSTR) {
            if (ParseWmiTime(vt.bstrVal, &stBoot)) {
                SystemTimeToFileTime(&stBoot, &ftBoot);

                printf("Boot time (local): %04u-%02u-%02u %02u:%02u:%02u\n",
                      stBoot.wYear, stBoot.wMonth, stBoot.wDay,
                      stBoot.wHour, stBoot.wMinute, stBoot.wSecond);

                // Compute uptime
                GetSystemTimeAsFileTime(&ftNow);
                boot64 = ((ULONGLONG)ftBoot.dwHighDateTime << 32) | ftBoot.dwLowDateTime;
                now64  = ((ULONGLONG)ftNow.dwHighDateTime << 32) | ftNow.dwLowDateTime;

                if (now64 > boot64) {
                    diff64 = now64 - boot64;
                    diffSec = diff64 / 10000000ULL;
                    days = diffSec / 86400;
                    hrs  = (diffSec % 86400) / 3600;
                    mins = (diffSec % 3600) / 60;
                    secs = diffSec % 60;

                    printf("Uptime: %llu days, %llu hours, %llu minutes, %llu seconds\n",
                          days, hrs, mins, secs);
                }
            } else {
                printf("Could not parse WMI time.\n");
            }
        } else {
            printf("Failed to read LastBootUpTime property.\n");
        }
        VariantClear(&vt);
        pObj->lpVtbl->Release(pObj);
    }

    // Cleanup
    pEnum->lpVtbl->Release(pEnum);
    pSvc->lpVtbl->Release(pSvc);
    pLoc->lpVtbl->Release(pLoc);
    CoUninitialize();
    return 0;
}
#14
Work in progress / Re: New resizer discussion
Last post by Vortex - November 23, 2025, 10:50:39 AM
Hi John,

Please don't worry, everything is OK. Keep up the good work.
#15
Work in progress / Re: New resizer discussion
Last post by John Z - November 22, 2025, 10:13:55 PM
Every project, all 8, I have on SourceForge are open source, granted one or two might be a version or two behind due to computer replacements and getting the git or SVN access working again.

Every project on Pelles Forum has had the source included except Linecounter+.  The code is such a tangle, works well, but spaghetti-fied it would not go over well  :( Maybe I'll fix it for the next activity.

So I fully, and always support open source, but you open source something when it is finally finished IMO.

Anyway no worries, we are all in synch in reality I think.
The new sizer library code is posted can be used as a library or just include the sources directly.

Pelles Help file indicates he could be interested -
"The full source code for resizer.lib (and resizer64.lib) is included, so if you have a better idea how to handle this - just implement it (but it would be nice if you inform me, so I may include the changes in some future version).
"

So maybe he can use some ideas from this effort.

John Z
#16
Chit-Chat / Re: WinDirStat
Last post by John Z - November 22, 2025, 09:56:35 PM
Not open source though either like SwiftSearch is btw.

https://sourceforge.net/projects/swiftsearch/

John Z
#17
Chit-Chat / Re: WinDirStat
Last post by Vortex - November 22, 2025, 08:58:09 PM
Thanks. As I guessed, no any issues with that application.
#18
Work in progress / Re: New resizer discussion
Last post by Vortex - November 22, 2025, 07:44:23 PM
It's maybe a matter of personal tast but like Timo, I support open source projects.
#19
Work in progress / Re: New resizer discussion
Last post by TimoVJL - November 22, 2025, 07:28:10 PM
I was just a hobby programmer, but now retired and invalid.
But i bought a new HP laptop Windows 11, as it was so cheap, only 236 €

At another site
QuoteI bought an very cheap HP laptop with Intel® Core™ i3-N305 processor, so i can test code with it too.
#20
Chit-Chat / Re: WinDirStat
Last post by John Z - November 22, 2025, 05:23:34 PM
Quote from: Vortex on November 21, 2025, 08:03:44 AMKindly, could you share your inspection results with us?

I download the .zip installation.  Unzipped into a directory. A single .exe
Started with no system network - didn't see any attempt to communicate.
Disabled the HTTPS servers feature. Enabled the system network and started it up again.
Nothing was seen in the firewall logs or in the resource monitor.

I let it index the main drive, it created a 33 mb db in the program directory.
The everything.db was not readable with sqlite - said it was not a db. HEXEDITOR
showed ESDb as the initial DB file bytes.

Searching was fast once the index was already created, which was fast too.

Everything seems to remain in the installation directory.  There is a user
editable .ini file.  The program interface for options seem to have most of the setting.

I disabled run in background - personal choice

Didn't see anything in appdata. Didn't try the HTTPS server feature.

So looks ok to me.

John Z