Click here to Skip to main content
15,894,362 members
Articles / Desktop Programming / MFC

Creating a Self Extracting Executable

Rate me:
Please Sign up or sign in to vote.
4.98/5 (22 votes)
20 Aug 2002CPOL3 min read 309.4K   5.7K   108  
A class that allows you to create self extracting executables for use in distribution or setup programs
/*************************************************************************************
*
*	File:		SEFileInfo.cpp
*	Version:	1.12
*
*	Author:		James Spibey
*	Date:		22/08/2002
*	E-mail:		james@spibey.com
*
*	Implementation of the CSEFileInfo class
*
*	You are free to use, distribute or modify this code
*	as long as this header is not removed or modified.
*
*
*************************************************************************************/
#include "stdafx.h"
#include "SEFileInfo.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif


/*******************************************************************************
* 
* Function: CSEFileInfo::CSEFileInfo
* 
* Description: 
*	 Default Constructor 
* 
* Parameters: 
*    None
* 
* Return: 
*    None
*******************************************************************************/
CSEFileInfo::CSEFileInfo()
{
	Reset();
}

/*******************************************************************************
* 
* Function: CSEFileInfo::~CSEFileInfo
* 
* Description: 
*	Destructor 
* 
* Parameters: 
*    None
* 
* Return: 
*    None
*******************************************************************************/
CSEFileInfo::~CSEFileInfo()
{
}

/*******************************************************************************
* 
* Function: CSEFileInfo::SetData
* 
* Description: 
*Set the data members for the class 
* 
* Parameters: 
*    CString Filename: Filename of file to gather data about 
* 
* Return: 
*    BOOL : Success or Failure
*******************************************************************************/
BOOL CSEFileInfo::SetData(CString Filename)
{
	CFile f;

	//Open the file
	if(!f.Open(Filename, CFile::modeRead))
		return FALSE;
	
	//Get the length in bytes
	m_nSize = f.GetLength();
	f.Close();

	m_strPathname = Filename;
	m_strFilename = Filename.Mid(Filename.ReverseFind('\\') + 1);
	return TRUE;
}

/*******************************************************************************
* 
* Function: CSEFileInfo::Reset
* 
* Description: 
*	 Reset the class data members 
* 
* Parameters: 
*    None
* 
* Return: 
*    None
*******************************************************************************/
void CSEFileInfo::Reset()
{
	m_nSize = 0;
	m_strPathname = "";
	m_strFilename = "";
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Web Developer
United Kingdom United Kingdom
James is currently working as a Software Engineer providing large scale Warehouse Management Systems and Airport Baggage Handling Systems. He is a Windows specialist but nowadays spends about 65% of his time fighting with VI in a vain attempt to get his UNIX C code to compile. He has been programming in C/C++ for 6 years and Visual C++/MFC for 4 years.

In his spare time James plays a variety of musical instruments including guitar and piano with varying degrees of success. He has been told he spends too much time and money in the pub but doesn't everyone have their own stool at the bar?

James is originally from Nottingham (no Robin Hood jokes please) but is now based in sunny Manchester, UK.

The attached photo shows James in his favourite position, drinking beer with a hand growing out of his neck.

Comments and Discussions