June 26, 2024, 06:30:07 AM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


Resource only dll

Started by LarryMc, August 31, 2008, 07:17:06 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

LarryMc

August 31, 2008, 07:17:06 AM Last Edit: August 31, 2008, 08:20:27 AM by Larry McCaughn
Currently working on creating a static lib that loads bitmaps from resources.

I assume I have to furnish the .lib, .inc, and .res to any potential users?
I assume that applications created  with the static lib requires nothing more than the .exe be distributed?

Paul mentioned that he was using "resource only dlls" in his contract work.

I've looked on msdn at "resource only dlls" which didn't tell me much.

I assume the process is this for EBasic:
Create a project.
Add all the bitmap resources to it.
Compile as dll.

In static lib project
hlib = LoadLibraryA("mydll.dll")
hInstance = _GetModuleHandle(hlib)
hBitmap2 = LoadImageA(hInstance, "#201", IMAGE_BITMAP, w,h, 0)

I assume I have to furnish the .lib, .inc, and .dll to any potential users?
I assume that applications created  with the static lib requires nothing more than the .exe be distributed?

How close did I get?

REV: And if I use sapero's dll2lib I could keep from having to distribute the mydll.dll and .lib at all?

Larry
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

Ionic Wind Support Team

You could do it this way:

hlib = LoadLibraryA("mydll.dll")
hInstance = _GetModuleHandle("mydll.dll")
hBitmap2 = LoadImageA(hInstance, "#201", IMAGE_BITMAP, w,h, 0)

I do it a bit differently though.  In my resource DLL I have an exported function that mimics the built in command LOADIMAGE except it loads the images from that DLL's resource.  So I only need to create an import library and include it with my project, less messy that way.

When a DLL is loaded the DLLMain function sets the global variable _hInstance to the dll's instance handle, so in my modified loadimage function I just need an extern:

extern _hinstance as UINT

You can do it your way though, just don't forget to unload the library with _FreeLibrary when you done with it.

Paul.
Ionic Wind Support Team

LarryMc

August 31, 2008, 08:18:02 AM #2 Last Edit: August 31, 2008, 08:21:52 AM by Larry McCaughn
Quote from: Paul Turley on August 31, 2008, 07:38:00 AM
I do it a bit differently though.  In my resource DLL I have an exported function that mimics the built in command LOADIMAGE except it loads the images from that DLL's resource.  So I only need to create an import library and include it with my project, less messy that way.

You know I'm dense so let's see if I understand your way.

Create a project.
Add all the bitmap resources to it.
Add a load resource mimic function to it.
Compile as dll.
create a import lib of mydll

In my static lib project
have a $use "mydll.lib"
Call load resource mimic as necessary
complie as static lib

Furnish the users of my static lib the following:
mylib.lib
mylib.inc
mydll.lib
mylib.dll

Furnish users of programs made with my static lib the following:
userprog.exe
mylib.dll

Is that correct?

REV: And if I use sapero's dll2lib I could keep from having to distribute the mydll.dll and .lib at all?

Larry
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

Ionic Wind Support Team

No.  dll2lib doesn't handle resources as far as I know, just the code sections.

Your static lib project can't $use "mydll.lib", it will be ignored since the linker isn't being invoked for a static library.  I think I have covered this before here.

The mydll.lib has to be included in the end users compile.  Such as from an include file that they must include to use your library, or they must add it to their project as an external file.

Paul.

Ionic Wind Support Team

LarryMc

August 31, 2008, 08:55:00 AM #4 Last Edit: August 31, 2008, 09:44:24 AM by Larry McCaughn
I know, I can see your BP rising, but

Create a project.
Add all the bitmap resources to it.
Add a load resource mimic function to it.
Compile as dll.
create a import lib of mydll

In my static lib project
Call load resource mimic as necessary
complie as static lib

Furnish the users(those who will compile my lib into their exe) of my static lib the following:
mylib.lib
mylib.inc - which includes a $use "mydll.lib"
mydll.lib
mylib.dll

Furnish end users (no compiling) of programs made with my static lib the following:
userprog.exe
mylib.dll

Is that correct?

Larry
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

Ionic Wind Support Team

Sounds about right.

Now to go back to spending labor day weekend with my kids...

later,
Paul.
Ionic Wind Support Team

LarryMc

Thanks again, Paul

We're getting a little crowded for the weekend.
we live in west Texas but are from the coast down by the Louisiana border.
So we have a bunch of our family up here because of the hurricane.

Larry
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library