News:

Download Pelles C here: http://www.pellesc.se

Main Menu

Recent posts

#21
General discussions / Re: Legacy header files
Last post by John Z - May 02, 2026, 04:48:07 PM
Well I'm far from an expert but I have used a dll in a program.
basically the use follows this:
1)LoadLibrary: Loads the DLL into memory.
2)repeat GetProcAddress: Get a pointers to the exported functions.
3)use the functions:
4)FreeLibrary: Unloads the DLL when done.

A quick web example where the dll contains 1 function:
__declspec(dllexport) int Add(int a, int b) {return a + b};

// LoadDLL.c
#include <windows.h>
#include <stdio.h>

typedef int (*AddFunc)(int, int);

int main() {
    HMODULE hDll = LoadLibrary(TEXT("ExampleDLL.dll"));
    if (hDll == NULL) {
        printf("Failed to load DLL. Error: %d\n", GetLastError());
        return 1;
    }

    AddFunc add = (AddFunc)GetProcAddress(hDll, "Add");
    if (add == NULL) {
        printf("Failed to get function. Error: %d\n", GetLastError());
        FreeLibrary(hDll);
        return 1;
    }

    int result = add(2, 3);
    printf("2 + 3 = %d\n", result);

    FreeLibrary(hDll);
    return 0;
}

some code excerpts from one of my actual programs
// Load the dll

  swprintf(p_DllFile,260,L"%ls%ls",p_appdir, L"libxlsxio_write64.dll" );
  hXlsxLib = LoadLibrary(p_DllFile);
  if (hXlsxLib == NULL)
    { MessageBoxA(NULL,"Can't export because the DLL is missing.","XLSX Export",MB_OK|MB_ICONERROR);
      return;
}

// get the functions

/* set up DLL procs */
(FARPROC) add_cell_datetime  = GetProcAddress(hXlsxLib,"xlsxiowrite_add_cell_datetime") ;
(FARPROC) add_cell_float     = GetProcAddress(hXlsxLib,"xlsxiowrite_add_cell_float") ;
(FARPROC) add_cell_int       = GetProcAddress(hXlsxLib,"xlsxiowrite_add_cell_int") ;
(FARPROC) add_cell_string    = GetProcAddress(hXlsxLib,"xlsxiowrite_add_cell_string")  ;
(FARPROC) add_column         = GetProcAddress(hXlsxLib,"xlsxiowrite_add_column") ;
(FARPROC) write_close        = GetProcAddress(hXlsxLib,"xlsxiowrite_close") ;
(FARPROC) get_version        = GetProcAddress(hXlsxLib,"xlsxiowrite_get_version") ;
(FARPROC) get_version_string = GetProcAddress(hXlsxLib,"xlsxiowrite_get_version_string") ;
(FARPROC) next_row           = GetProcAddress(hXlsxLib,"xlsxiowrite_next_row") ;
(FARPROC) write_open         = GetProcAddress(hXlsxLib,"xlsxiowrite_open") ;
(FARPROC) set_detection_rows = GetProcAddress(hXlsxLib,"xlsxiowrite_set_detection_rows") ;
(FARPROC) set_row_height     = GetProcAddress(hXlsxLib,"xlsxiowrite_set_row_height") ;

 // use the exported function
 .....
 
// finally clean up
  // release DLL
  FreeLibrary(hXlsxLib) ;

Hopefully helpful, at least a start -

John Z
#22
General discussions / Re: Legacy header files
Last post by ander_cc - May 02, 2026, 03:48:47 PM
Quote from: John Z on May 02, 2026, 10:35:03 AMHi ander_cc,

There are two windows system dll's that might help -

C:\windows\system32\winsqlite3.dll
and
C:\windows\SysWOW64\winsqlite3.dll

John Z
I see, thank you very much! I find the dll. But how to use it?
#23
General discussions / Re: Legacy header files
Last post by TimoVJL - May 02, 2026, 11:42:25 AM
winsqlite3.dll is available since Windows 10 ?
#24
Add-ins / Re: AddIn Create/Open 32-bit p...
Last post by John Z - May 02, 2026, 10:36:43 AM
Thanks Timo!


John Z
#25
General discussions / Re: Legacy header files
Last post by John Z - May 02, 2026, 10:35:03 AM
Hi ander_cc,

There are two windows system dll's that might help -

C:\windows\system32\winsqlite3.dll
and
C:\windows\SysWOW64\winsqlite3.dll

John Z
#26
General discussions / Legacy header files
Last post by ander_cc - May 02, 2026, 06:03:06 AM
There are two header files in folder "Include/win/winsqlite/": winsqlite3.h and winsqlite3ext.h.
But no related .lib files are included in folder "Lib".
Is this a deprecated feature?
#27
Tips & tricks / Re: LiteZip tests
Last post by Vortex - April 29, 2026, 01:31:51 PM
Here is a zip sample :

// Source code by ChatGPT

#include <windows.h>
#include <stdio.h>
#include "LiteZip.h"

void AddFolder(HZIP hz, const char *basePath, const char *relPath)
{
    char search[MAX_PATH];
    WIN32_FIND_DATAA fd;
    HANDLE hFind;

    sprintf(search, "%s\\%s\\*", basePath, relPath);

    hFind = FindFirstFileA(search, &fd);
    if (hFind == INVALID_HANDLE_VALUE)
        return;

    do
    {
        if (strcmp(fd.cFileName, ".") == 0 ||
            strcmp(fd.cFileName, "..") == 0)
            continue;

        char fullPath[MAX_PATH];
        char zipPath[MAX_PATH];

        sprintf(fullPath, "%s\\%s\\%s", basePath, relPath, fd.cFileName);

        if (relPath[0])
            sprintf(zipPath, "%s\\%s", relPath, fd.cFileName);
        else
            sprintf(zipPath, "%s", fd.cFileName);

        if (fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
        {
            AddFolder(hz, basePath, zipPath);
        }
        else
        {
            printf("Adding: %s\n", zipPath);
            ZipAddFileA(hz, zipPath, fullPath);
        }

    } while (FindNextFileA(hFind, &fd));

    FindClose(hFind);
}

int main(void)
{
    HZIP hz;

    if (ZipCreateFileA(&hz, "archive.zip", 0) != 0)
    {
        printf("Cannot create ZIP\n");
        return 1;
    }

    AddFolder(hz, "C:\\testfolder", "");

    ZipClose(hz);
    printf("Done.\n");
    return 0;
}
#28
General discussions / v 14.10 debugger
Last post by TimoVJL - April 29, 2026, 11:11:39 AM
Have anyone problems with debugger with their code ?
#29
Add-ins / Re: AddIn Create/Open 32-bit p...
Last post by TimoVJL - April 29, 2026, 09:39:26 AM
Fix for UTF-8 BOM
#30
Tips & tricks / Re: LiteZip tests
Last post by Vortex - April 28, 2026, 09:42:07 PM
Hi Timo,

Thanks for the static libraries. With the help of ChatGPT, here is an unzip sample :

// Dependencies required to build the project
// LiteUnzip.h and LiteUnzip.lib from LiteUnzip_WS2.zip
// https://forum.pellesc.de/index.php?msg=42339
// Sample code by ChatGPT

#include <windows.h>
#include <stdio.h>
#include "LiteUnzip.h"

int main(void)
{
    HUNZIP hz;
    ZIPENTRY ze;
    DWORD numitems, i;

    // Open ZIP
    if (UnzipOpenFileA(&hz, "test.zip", 0) != 0)
    {
        printf("Cannot open ZIP file\n");
        return 1;
    }

    // Get number of items
    ze.Index = (DWORD)-1;
    if (UnzipGetItemA(hz, &ze) != 0)
    {
        printf("Cannot get ZIP info\n");
        UnzipClose(hz);
        return 1;
    }

    numitems = ze.Index;
    printf("Files in archive: %lu\n", numitems);

    // Extract loop
    for (i = 0; i < numitems; i++)
    {
        ze.Index = i;

        if (UnzipGetItemA(hz, &ze) != 0)
        {
            printf("Error reading item %lu\n", i);
            continue;
        }

        printf("Extracting: %s\n", ze.Name);

        if (UnzipItemToFileA(hz, ze.Name, &ze) != 0)
        {
            printf("Failed to extract %s\n", ze.Name);
        }
    }

    UnzipClose(hz);
    return 0;
}