07-02-2018 11:04 AM
I've written a library and turned it into a DLL. In the lib, I use a custom mouse cursor during certain events, which loads a file.cur at run-time.
My question is, how can I embed this cursor file into the dll so that my host application can more easily get it (I'd rather not require the host to have this file to use the lib).
There are options to "Add Files to DLL" in the Target Settings. There's also the "Embed manifest file" option, but not sure what to do with either.
07-03-2018 03:01 AM
Both options are not what you look for. You need a Resource compliler like the rc.exe that comes with Microsoft Visual Studio. Not sure if it is also part of the Microsoft Windows SDK that used to be possible to install during installation of LabWindows CVI.
rc.exe is a command line tool, so you will want to investigate the parameter syntax it requires. You basically take the existing executable, and a script with the ending .rc that describes your resource files, which can be cursors, bitmaps, icons, version resource and such and tell the rc.exe tool to embed them as resources in your DLL.
Inside the DLL you then need to use Windows API functions like FindResource(), LoadResource() and friends.
07-03-2018 01:16 PM
Thanks for the help!
Yes, I have the SDK installed and found rc.exe. I found some great help here on making a script. I've made one as per their example and it does indeed compile my cursor file into a *.RES file.
You said:
@rolfktell the rc.exe tool to embed them as resources in your DLL.
I'm just missing this piece. I did some more digging and found this step:
Link the compiled resource (.res) file into the application's executable file with your linker.
I'm not sure how to do a custom linkage in CVI.
07-03-2018 03:05 PM
Well, that is a good question. It seems LabWindows CVI creates by default a .res file containing the version resource, but that is recreated during each build. So the linker is able to process a .res file and add it to the PE image file. However how to convince CVI to add another .res file seems to be a bit of a problem. Basically even the Microsoft C linker seems to only support adding one .res file.
Most likely it will be not really possible to do this in LabWindows CVI without special internal hooks into the linker.
Would leave the option to use Visual C as final linker step instead.