return 0;
}
if((fpwriteTem=fopen(strFileTemname, "wb "))==NULL)
{
printf( "write tem file fail ");
return 0;
}
fseek(fpreadHost,0,SEEK_SET);
fseek(fpreadClient,0,SEEK_SET);
fseek(fpreadUnbind,0,SEEK_SET);
fseek(fpwriteTem,0,SEEK_SET);
int c;//nCount;
while((c=fgetc(fpreadUnbind))!=EOF)
{
fputc(c,fpwriteTem);
}
while((c=fgetc(fpreadHost))!=EOF)
{
//c=fgetc(fpreadHost);
fputc(c,fpwriteTem);
}
while((c=fgetc(fpreadClient))!=EOF)
{
//c=fgetc(fpreadClient);
fputc(c,fpwriteTem);
}
//while((c=fgetc(fpreadClient))!=EOF)
//{
//fputc(c,fpwriteTem);
//}
fwrite(&bind,1,sizeof(bind),fpwriteTem);
fclose(fpreadUnbind);
fclose(fpreadHost);
fclose(fpreadClient);
fclose(fpwriteTem);
_stat(strFileTemname,&ST);
printf( "the size of bind 's file is %d ",ST.st_size);
return 0;
//读文件信息,三个文件信息,
//建立一个临时文件,往这个临时文件里增加unbind.exe,host.exe,client.exe,还有三个文件信息
}
// unbind.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h "
#include "stdio.h "
#include <sys/stat.h>
#include <windows.h>
#include "atlstr.h "
//#define MAX_PATH 40
typedef struct tagMyBINDSTRUCT
{
TCHAR cFilenameHost[40]; // 宿主文件名.
TCHAR cFilenameClient[40]; // 被捆绑文件名.
TCHAR cFilenameUnbind[40];//解压缩程序名
DWORD nFileSizeUnbind;// 解压缩程序大小
DWORD nFileSizeHost; // 宿主文件长.
DWORD nFileSizeClient; // 被捆绑文件长.
DWORD nFileSizeBind; // 已捆绑文件长.
} MYBINDINFO;
int main(int argc, char* argv[])
{
CString strFilenameTem=argv[0];
MYBINDINFO bind;
//char szModule[MAX_PATH];
memset(&bind,0,sizeof(MYBINDINFO));
//if(GetModuleFileName(0,szModule,MAX_PATH)==0)
//{
// printf( "get module file name error\n\r ");
// return 0;
//}
//printf( "the path is %s ",szModule);
struct _stat ST;
if(0!=_stat(strFilenameTem,&ST))
{
printf( "there is error ");
return 0;
}
DWORD nFilesize=ST.st_size;
printf( "the size of the file is %d ",nFilesize);
DWORD offset=nFilesize-sizeof(MYBINDINFO);
if(offset <0) return 0;
FILE *fpreadbind,*fpwrite;
if((fpreadbind=fopen(strFilenameTem, "rb "))==NULL)
{
printf( "open the self fail\n\r ");
return 0;
}
fseek(fpreadbind,offset,SEEK_SET);
fread(&bind,1,sizeof(bind),fpreadbind);
if(bind.nFileSizeBind!=nFilesize)
{
fclose(fpreadbind);
printf( "has 't bind ");
return 0;
}
DWORD nPos=bind.nFileSizeUnbind;
CString srFilenameHost=bind.cFilenameHost;