PC SOFT

FORUMS PROFESSIONNELS
WINDEVWEBDEV et WINDEV Mobile

Accueil → WINDEV 2024 → [WD19] - Storing files inside the exe
[WD19] - Storing files inside the exe
Débuté par JP, 02 sep. 2014 17:09 - 7 réponses
Posté le 02 septembre 2014 - 17:09
Hi All,

Is there a way to store a file, such as a PDF file, inside the exe file? I see that I can add a PDF to, for example, the Documents branch of the Project Explorer. How can I copy that PDF file back out of the exe to a folder on the hard disk?

TIA
Posté le 02 septembre 2014 - 18:52
Hi

storing it is easy... Just add it in the library when you are creating the exe...

After that, it should be accessible by its name...

So I guess doing myBuf is buffer=MyFileName then fsavebuffer(xxx) should allow you to extract it on the disk

But I have never used that last part, so you will have to test

Best regards
Posté le 02 septembre 2014 - 19:31
Hi Fabrice,

This doesnt seem to work. I have:

bufMyBuf is Buffer= fLoadBuffer( "Internal.pdf" )

fSaveBuffer( "c:\ emp\External.pdf" , bufMyBuf )

But the created external file is empty because fLoadBuffer() is looking for the Internal.pdf file in the folder of the EXE, not internally. So the question is how to reference the file added to the exe ?

Thanks
Posté le 02 septembre 2014 - 19:35
Fabrice,

So here is an interesting thing; In the help there is a function called fExtractResource() whose purpose is to extract a resource from the application to a disk file. Sounds good. But when I type this function in the program the editor rejects it as an unknown function ... ?

<a class="ExternalLink" rel="nofollow" target="_blank" href="http://doc.windev.com/?1000019509&name=fextractresource_function">http://doc.windev.com/&hellip;</a>
Posté le 02 septembre 2014 - 20:18
Hi JP,

In fact this is not possible. You can indeed have files added as Fabrice explained, but you can't extract them. What Fabrice explained will only work for supported files, like images.

The function you are referring to will only work in Mobile applications (I know the icon at the top of the help page says contrary, but if you look to the details, you will see it's not there yet). You to, can make a suggestion to have this nice feature brought into WD.

PCSoft suggested an official turn-around-the-problem in an LST. The trick was to create a DB file and then store all the desired files in the DB file. Finally, you include the DB file into the library. When you will ask for the file with the H* commands, WinDev will automatically use the file included in the library. Then you can extract the data which is inside the file. This is a nice trick, but will require more job on your side and to be more careful with the files you are packaging. But nothing that can't be done.

Best regards,
Alexandre Leclerc
Posté le 02 septembre 2014 - 20:28
Thanks Alexandre. The idea of using an included file is how I did this in VFP so I understand the process.

Thanks for the reply.
Posté le 03 septembre 2014 - 08:53
Hi Alexandre, I cant even make this work with image files. Are you sure this works? If so, have you any example code?
Posté le 03 septembre 2014 - 14:45
Hi JP,

What I personally do is that I add the image in the project files (these will display also in the project tree in the "Other" folder). Then when you want to use the file, in the source code, just call it by name: IMG_One = "myfile.png".

The files in the "Other" folder are automatically declared to the project and added in the library.

For the "How to include files in the EXE", take a look at this blog post (in French) from the Free Technical Support (it was not in a LST, but from this blog post that I got this piece of information - bad memory): <a class="ExternalLink" rel="nofollow" target="_blank" href="http://blogs.pcsoft.fr/post.awp?title=comment-extraire-fichier-executable-windev,2,316">http://blogs.pcsoft.fr/post.awp&hellip;</a>

Best regards,
Alexandre Leclerc