Click here to Skip to main content
15,922,512 members
Home / Discussions / ATL / WTL / STL
   

ATL / WTL / STL

 
GeneralRe: downloader Pin
monsieur_jj13-May-08 17:27
monsieur_jj13-May-08 17:27 
GeneralRe: downloader Pin
Stuart Dootson13-May-08 22:31
professionalStuart Dootson13-May-08 22:31 
GeneralRe: downloader Pin
monsieur_jj13-May-08 22:50
monsieur_jj13-May-08 22:50 
GeneralRe: downloader Pin
monsieur_jj14-May-08 16:59
monsieur_jj14-May-08 16:59 
GeneralRe: downloader Pin
Stuart Dootson14-May-08 22:05
professionalStuart Dootson14-May-08 22:05 
GeneralRe: downloader Pin
monsieur_jj13-May-08 22:43
monsieur_jj13-May-08 22:43 
Questionhelp on exe generation by other exe Pin
alex7869-May-08 4:53
alex7869-May-08 4:53 
AnswerRe: help on exe generation by other exe Pin
Stuart Dootson12-May-08 22:27
professionalStuart Dootson12-May-08 22:27 
This is not really an ATL, WTL or STL question. But, as I'm a nice guy, I'll suggest you open your files in binary mode (fopen(filename, "rb") or fopen(filename, "wb"), so that the C run-time doesn't do any translation of line-ending characters.

Alternatively (and this is better), you can embed the executable file you want to write as a resource in the program that is generating it. Here's a function that should load and write a named resource:

#include <Windows.h>
#include <ShlWApi.h>

// Load the resource specified by ('hmodResource', 'name', 'type') and write it to 'destination'.
// 'type' may be zero, in which case we deduce it from the resource name.
bool WriteFileFromResource(HINSTANCE hmodResource, LPCTSTR name, LPCTSTR type, LPCTSTR destination)
{
   if (!type)
      type = ::PathFindExtension(name) + 1;
   HRSRC rsrcFile = ::FindResource(hmodResource, name, type);
   if (!rsrcFile) false;
   HGLOBAL gblFile = ::LoadResource(hmodResource, rsrcFile);
   if (!gblFile) false;
   DWORD sizeFile = ::SizeofResource(hmodResource, rsrcFile);
   if (!sizeFile) return false;
   LPVOID filePointer = ::LockResource(gblFile);
   if (filePointer)
   {
     bool ret = false;
      HANDLE hFile = ::CreateFile(destination, GENERIC_WRITE, 0, 0, CREATE_ALWAYS, 0, 0);
      if (hFile)
      {
        DWORD nBytesWritten;
        ret = (::WriteFile(hFile, filePointer, (DWORD)sizeFile, &nBytesWritten, 0) && sizeFile == nBytesWritten);
        ::CloseHandle(hFile);
      }
      ::FreeResource(gblFile);
      return ret;
   }
   return false;
}




QuestionRead data from a serial port Pin
hari_honey8-May-08 20:58
hari_honey8-May-08 20:58 
QuestionRe: Read data from a serial port Pin
Cedric Moonen8-May-08 21:11
Cedric Moonen8-May-08 21:11 
AnswerRe: Read data from a serial port Pin
hari_honey8-May-08 21:46
hari_honey8-May-08 21:46 
GeneralRe: Read data from a serial port Pin
CPallini11-May-08 21:54
mveCPallini11-May-08 21:54 
QuestionMinimize button does not work on Vista with Aero (using PropertySheets) Pin
howard_khan18-May-08 6:37
howard_khan18-May-08 6:37 
Questionerror compling dll Pin
alex7867-May-08 3:47
alex7867-May-08 3:47 
AnswerRe: error compling dll Pin
Cedric Moonen8-May-08 21:10
Cedric Moonen8-May-08 21:10 
QuestionFunctionality similar to mcafee site advisor browser plugin Pin
bikramthapa7-May-08 2:18
bikramthapa7-May-08 2:18 
QuestionCatching a WM_MOUSEMOVE from a popup menu opened from IE-toolbar Pin
amosygal6-May-08 23:42
amosygal6-May-08 23:42 
QuestionFire Event from Worker thread in ATL COM Loaded on a Web Page Pin
garammasala5-May-08 23:52
garammasala5-May-08 23:52 
QuestionAtlAdvise returns 0x80040201 [modified] Pin
Scorp1us1-May-08 8:28
Scorp1us1-May-08 8:28 
QuestionPopup Menu sends "UnInit" Before sending a command Pin
yytg1-May-08 4:43
yytg1-May-08 4:43 
QuestionC2440 Pin
T.RATHA KRISHNAN30-Apr-08 19:37
T.RATHA KRISHNAN30-Apr-08 19:37 
AnswerRe: C2440 Pin
Jörgen Sigvardsson1-May-08 0:14
Jörgen Sigvardsson1-May-08 0:14 
QuestionHow to use ATL COM dll in JavaScript? Pin
ritz123430-Apr-08 2:30
ritz123430-Apr-08 2:30 
AnswerRe: How to use ATL COM dll in JavaScript? Pin
led mike30-Apr-08 4:32
led mike30-Apr-08 4:32 
AnswerRe: How to use ATL COM dll in JavaScript? Pin
CPallini30-Apr-08 5:19
mveCPallini30-Apr-08 5:19 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.