Extending Win32.LIB adding 2 Kernel Functions

Hi all.

It’s been a while since I’ve needed to work with LIB files - I feel somewhat like a newbie with this.

I need to add two Win32 functions to a LIB file for a project. These functions are found in KERNEL32.DLL and are not currently listed in the Win32.LIB file that Clarion 11 ships with.

I couldn’t find a way to add the functions directly with the Libmaker UI. I did consider hardcoding them into Libmaker when saving the list to a LIB file. Maybe there’s an easier way?

Thys

Make another lib with required functions and add it to your project.

3 Likes

Hi Mike.

I considered that, but because Win32.LIB is a selection of APIs that SoftVelocity added to it, and they’re not only from KERNEL32.LIB - there functions from at least 5x Windows DLLs - it will be a tedious task to get it the same as in the provided LIB.

Thys

No, you should create the lib (say mywin32.lib) with only 2 functions, your app will use both win32.lib (implicitly) and mywin32.lib (explicitly included in the project). You can add to a project as much libs as you want, each lib with its own function list.

3 Likes

With the help of @PaulAttryde I can now load, call and unload any API using proc name or ordinal only api’s, without needing a lib file.

This is handy as I need 16bit api’s and unicode apis, all from one app which might need to run on w2k/xp upto win11.

I’ll put together a demo app file to show how it all fits together, but its quite simple when you see it working…

Edit
C6.3 app, dct and .a file
Shows how to call 16bit dll on the fly and unicode api’s for processing with callback procedure that captures the new power notification api’s. If you run this on a laptop with battery, you’ll see the battery % go down along with the display dimmed and laptop lid open and close, amongst other power events

The Console and Session GUID’s overlap functionality.

If you have a background app/service which is triggering GUID_IDLE_BACKGROUND_TASK, then the background app/service isnt optimised/lightweight enough so the code needs refactoring.

apiunicode.zip (23.7 KB)

Thys,
You have 2 options

  1. what Mike said - make a new .lib with a different name, add it to the project/solution, and it’ll get added into the .exe file just like normal. There’s no limit that I know of to the number of .lib files you can add.

  2. What RchdR says - you can load any DLL and call a procedure without needing a .lib file. Depending on how you do it you can also get away without needing a procedure prototype in the map as well.

If you’ve only ever done #1 then it’s probably easier to just stick with that.
But if you want to try #2 here’s my web article from '99
https://attryde.com/clarion/cwdll.htm

HTH,
Paul

With a teaser like that, care to elucidate?

I thought you already know how to do that?
The short answer is to use the _CallPtr function in the .a file you have from Jim Kane’s original article.
It may have been “Calling By Address STARTing By Address”, but since I never had a cmag subscription I never got to read it.

This Lib Maker allows Tagging the 2 you want then making a Lib with just those.

It also has the feature to Subtract Win32.lib so you are left with just functions not defined by Clarion. I would still limit your LIB to only functions you need.

1 Like

Its that one, just checking in case of some other way to do things. Thanks!