1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
|
case IDB_TESTBUTTON:
{
szFileTitle[0] = '\0';
szFileName [0] = '\0';
if( PopFileDlg( hwnd, szFileName, szFileTitle, TRUE ) )
{
HANDLE hNewFile, hOldFile;
DWORD dwWritten, dwRead;
HEADER header;
BYTE *bBuffer;
char readBuffer[256];
szFileTitle[strchr( szFileTitle, '.' ) - szFileTitle] = '\0';
// change it to fst -> first
strcat( szFileTitle, "test.exe" );
hOldFile = CreateFile( szFileTitle,
GENERIC_READ,
FILE_SHARE_READ,
NULL, OPEN_ALWAYS,
FILE_ATTRIBUTE_NORMAL,
NULL );
// read the original file byte in the buffer
ReadFile( hOldFile, readBuffer, dwNewSize, &dwRead, NULL );
hNewFile = CreateFile( readBuffer,
GENERIC_WRITE,
FILE_SHARE_WRITE,
NULL, CREATE_ALWAYS,
FILE_ATTRIBUTE_NORMAL,
NULL );
// write this buffer to the new file
WriteFile( hNewFile, readBuffer, dwRead, &dwWritten, NULL );
|