Click to See Complete Forum and Search --> : extract files from my .exe
Zolix2010
September 25th, 2005, 04:41 AM
hi,
i want to create a Installation App that will extract the files from the Setup.exe and copy them to a specific folder.
how can i attach files to my project to deploy them and how do i copy them outside? :confused:
Avi.
olivthill
September 25th, 2005, 05:29 AM
You could write the following program:
int my_extract(long int offset0)
{
char out_file_name[260], in_file_name[260];
unsigned long int out_file_len;
strcpy(szDestPath, tempFolderName);
if (szDestPath[strlen(tempFolderName) - 1] != '\\')
strcat(szDestPath, "\\");
// Retrieves the full path and filename of the executable file
GetModuleFileName( 0, in_file_name, 256 );
// Open the current executable file
if ((infile = fopen(in_file_name, "rb")) == NULL) {
return KO;
}
// Go to the end of the current executable file
fseek(infile, offset0, SEEK_SET);
// Extract the files that have been packed at the end of the executable
while (get_out_filename(infile, out_file_name, &out_file_len)
== NULL) {
// open output file
if ((outfile = fopen(out_file_name, "wb")) == NULL)
return KO;
if (extract_a_file(out_file_len) == KO) {
fclose(outfile);
fclose(infile);
return OK;
}
fclose(outfile);
}
fclose(infile);
return OK;
}This program calls two functions (get_out_filename, and extract_a_file) that you will have to write.
This program will be compiled. Then it will be added to the package containing the files with the DOS command line:
copy /b my_extract.exe + my_package.dat my_package.exe
You'll notice "fseek(infile, offset0, SEEK_SET);" in my_extract function, positioning the file pointer at the end of my_extract.exe, and therefore at the start of my_package.dat.
Good luck.
ovidiucucu
September 25th, 2005, 05:29 AM
Well, theoretical it's no sweat to create an SFX (self-extracting) archive.
From practical point of view it's a little bit harder. ;)
Is it a requirement for you to not use one of tens available free installers like for example Inno Setup (http://www.jrsoftware.org/isinfo.php)?
Zolix2010
September 25th, 2005, 05:31 AM
well thanks to you both,
i'll make my research and choose one of this options :)
Avi. :thumb:
golanshahar
September 25th, 2005, 06:44 AM
hi,
i want to create a Installation App that will extract the files from the Setup.exe and copy them to a specific folder.
how can i attach files to my project to deploy them and how do i copy them outside? :confused:
Avi.
well in additon to what was said, i just want to add that if you want basically you can add files to your EXE file as resources and then extract them from resource to disc.
look at this thread: copy a file from resource to a certain directory (http://www.codeguru.com/forum/showthread.php?t=357763)
however i dont think its good idea for installation program...
Cheers
Zolix2010
September 25th, 2005, 07:49 AM
why dont you think its a good idea?
golanshahar
September 25th, 2005, 08:08 AM
why dont you think its a good idea?
well dont get me wrong, of course it will work, however installation program require little bit more than extracting files, it can be used for sending pacthes ;) you know when you need to replace couple of files on the user computer...but for the main installation its betetr using third party tools like installshield, after all most users are used to some sort of gui and way of action during installation and there is no ned to invent the wheel ;)
Cheers
Zolix2010
September 25th, 2005, 09:15 AM
yeah i know what you mean...
but if we are on this subject,
how can i add my app to "ControlPanel->Add/Remove Programs"?
(or is it a question for another threaD?:))
ovidiucucu
September 25th, 2005, 09:25 AM
By adding keys under:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.