EXE to SWF file conversion code

Source: Internet
Author: User

//-------------------------------------------------------------

/* Exe format to SWF all kinds of conversion programs

Support FLASH6 Format

The source code is easy to read!

A letter live_on@sohu.com a problem

This function is part of my live Flash player

*/

#include <vcl.h>
#pragma hdrstop
#include "exef.h"
//-------------------------------------------------------------
#pragma package (smart_init)
Ansistring exe2swf (ansistring filename)//function name
{
int ifilehandle;
unsigned long ifilelength;
unsigned long ibytesread;
Ansistring Dfilename;
unsigned char *pszbuffer;
unsigned char *buffer;
Ifilehandle = FileOpen (Filename.c_str (), fmopenread);//Open File
Ifilelength = FileSeek (ifilehandle,0,2);//Determine length

FileSeek (ifilehandle,0,0);
Pszbuffer = new Char[ifilelength+1]; Read into source files
if (pszbuffer==null)
{
return (NULL);
}
Ibytesread = Fileread (Ifilehandle, Pszbuffer, ifilelength);
FileClose (ifilehandle);/close
Dfilename=
Dfilename=filename.uppercase (). SubString (1,filename.length ()-4) + ". SWF ";//Generate Target file name
if (FileExists (dfilename))//Determine whether there is
return (NULL);
printf ("%d \ n", ibytesread);
int i=0;
int ii=0;
for (i=0 i<ifilelength-2;i++)//matching recognition character FWS
{
pszbuffer++;
if ((pszbuffer[i-2]==0) && (pszbuffer[i-1]==0) && (pszbuffer[i]== ' F ') && (pszbuffer[i+1]== ' W ') ) && (pszbuffer[i+2]== ' S '))
{
Ii=i;
}
}
I=ii;
Pszbuffer=pszbuffer+i;
Ifilehandle = Filecreate (Dfilename.c_str ());
if (i!=376831&&i!=286719&&i!=811008)//Is 4. 5. 6 version
{
if (! Application->messageboxa ("File format exception! Force playback?", "Warning", IDOK))
return (NULL);
}
FileWrite (Ifilehandle, pszbuffer,ifilelength-i);
FileClose (Ifilehandle);
delete [] pszbuffer;
return (Dfilename);
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.