installer

This is a discussion on installer within the Windows Programming forums, part of the Platform Specific Boards category; I'm making installer (VC++ 6.0), I use LoadResource() to get files from install.exe, something like this Code: HINSTANCE hInst = ...

  1. #1
    Registered User
    Join Date
    Jun 2005
    Posts
    24

    installer

    I'm making installer (VC++ 6.0),

    I use LoadResource() to get files from install.exe, something like this

    Code:
          HINSTANCE hInst = AfxGetInstanceHandle();
    
          HRSRC hmdbFile = ::FindResource(hInst, ResName, ResType);
          HGLOBAL hRes = ::LoadResource(hInst, hmdbFile);
          DWORD dwResSize = ::SizeofResource(hInst, hmdbFile);
    
          UINT FAR* lpnRes = (UINT FAR*)::LockResource(hRes);
      
          CString szFileName = FileName;			
    	
          CFile f( szFileName, CFile::modeCreate | CFile::modeWrite );
      
          f.WriteHuge(lpnRes, dwResSize);
          f.Flush();
          ...
    but the install file is to big because files are not compressed.


    I tried CUnzip (from http://www.codeguru.com/cpp/cpp/cpp_...icle.php/c819/) to unzip files, but this library dose not support folders... it means I still have to write my programs folder structure in code and make resources to all files.

    Is there available any better unzip (or another format: rar, ace ... ) library?
    Or another solution to make install.exe (I dont want to use InstallShield or any another app), my solution is:
    1) add resource (file.zip) to my project
    2) built and execute install.exe
    3) loading resource (file.zip) and write it temporarily to disk (install destination folder)
    4) unzip files from file.zip (with folder structure)
    5) delete file.zip

  2. #2
    Registered User
    Join Date
    Mar 2005
    Location
    Mountaintop, Pa
    Posts
    1,059
    Possibly Zlib?

  3. #3
    Registered User
    Join Date
    Jun 2005
    Posts
    24
    Quote Originally Posted by BobS0327
    Possibly Zlib?
    Yes I tried this lib... but unfortunately this is too much for me.
    Can someone show me how to use zlib in MFC.

    For example I have :

    Code:
    class AppX : public CWinApp
    {
    	public:
    	
    	BOOL InitInstance()
    	{
    		
    	        ... ALL WINDOW STUFF
    
    		mainWinL->ActivateFrame();
    
                    CString zipfile = "temp.zip";
                  
                    /// this function creates temp.zip file from resource
    		CreateFileFromResource("IDR_BINFILE2", "BINFILE", zipfile);
    		
                    CString uncomp_dest = "./Folder/Where/To/Uncompress/Files/";
    
    
                    ... HOW LOOKS THE CODE ??? UNCOMPRESS zipfile TO uncomp_dest
    
    		return TRUE ;
    	}
    
    
    };
    
    AppX InstallFile;

  4. #4
    Registered User
    Join Date
    Jun 2005
    Posts
    24
    Finally ...
    I found ZipArchive from http://www.codeproject.com/cpp/zip.asp
    and this works

    Code:
     
    /// szDest is CString with dest. folder from "Folder Browse Dialog"
    
    CString ZipTempFileName = szDest+"/temppack";
    CString UnpackFolder = szDest;
    
    CreateFileFromResource("IDR_BINFILE2", "BINFILE", ZipTempFileName);
    			
    CZipArchive zip;
    
    zip.Open(ZipTempFileName, CZipArchive::openReadOnly); 
    			
    for (WORD i = 0; i < zip.GetNoEntries(); i++)
    	{ zip.ExtractFile(i, UnpackFolder); }
    
    zip.Close();
    
    CFile::Remove(ZipTempFileName);

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. typical operations of an installer
    By stanlvw in forum Windows Programming
    Replies: 4
    Last Post: 05-30-2008, 08:07 AM
  2. Linux software installer recommendations
    By BobS0327 in forum Tech Board
    Replies: 13
    Last Post: 09-24-2006, 01:19 AM
  3. Visual Studio Installer Privilege Issue
    By mercury529 in forum Windows Programming
    Replies: 4
    Last Post: 01-30-2006, 12:48 PM
  4. Installer Program
    By Junior89 in forum C++ Programming
    Replies: 4
    Last Post: 01-17-2005, 12:49 AM
  5. Windows Installer Problem on XP
    By Sh0t in forum Tech Board
    Replies: 4
    Last Post: 10-14-2002, 02:11 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21