How to Save an Embedded Resource to a File

By: mykle hoban

Abstract: This article describes how to save a resource embedded in your application to a file.

How dow I save an embedded resource to a file?


The following code sample illustrates how to save an embedded resource to a file.

BOOL SaveResourceToFile(char *fn, char *res)
{ HRSRC hrsrc = FindResource(HInstance,res,RT_RCDATA);
  if (hrsrc == NULL) return FALSE;
  DWORD size = SizeofResource(HInstance,hrsrc);
  HGLOBAL hglob = LoadResource(HInstance,hrsrc);
  LPVOID rdata = LockResource(hglob);
  HANDLE hFile =
  DWORD writ; WriteFile(hFile,rdata,size,&writ,NULL);
  return TRUE;

Published on: 12/4/2000 12:19:24 PM

Server Response from: ETNASC03

Copyright© 1994 - 2013 Embarcadero Technologies, Inc. All rights reserved.