Click here to Skip to main content
15,916,189 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: need some help here Pin
JohnJ21-Jul-03 21:03
JohnJ21-Jul-03 21:03 
GeneralRe: need some help here Pin
FASTian21-Jul-03 21:29
FASTian21-Jul-03 21:29 
Questionif I add a text file to the resource, how could I get this file in the programe? Pin
benben21-Jul-03 20:29
benben21-Jul-03 20:29 
AnswerRe: if I add a text file to the resource, how could I get this file in the programe? Pin
Eugene Pustovoyt21-Jul-03 20:41
Eugene Pustovoyt21-Jul-03 20:41 
GeneralRe: if I add a text file to the resource, how could I get this file in the programe? Pin
benben22-Jul-03 4:42
benben22-Jul-03 4:42 
AnswerRe: if I add a text file to the resource, how could I get this file in the programe? Pin
Jens Doose21-Jul-03 22:05
Jens Doose21-Jul-03 22:05 
GeneralThanks Pin
benben22-Jul-03 0:25
benben22-Jul-03 0:25 
GeneralRe: Thanks Pin
Jens Doose22-Jul-03 1:06
Jens Doose22-Jul-03 1:06 
Sure.
Let's assume you have added a textfile to your resource with ID=IDR_TEXTFILE, and your custom resource type has the name "TEXTFILE".

You can extract the resource with the following code:

#include "stdafx.h"
#include "resource.h"

#include <TCHAR.h>

int APIENTRY WinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPSTR     lpCmdLine,
                     int       nCmdShow)
{
  HRSRC hRsrc = ::FindResource( hInstance,
                                MAKEINTRESOURCE( IDR_TEXTFILE ),
                                _T("TEXTFILE") ); // *** My custom res type

  if ( NULL != hRsrc )
  {
    HGLOBAL hGlob = ::LoadResource( NULL, hRsrc );

    if ( NULL != hGlob )
    {
      DWORD dwSize  = ::SizeofResource( NULL, hRsrc );
      LPVOID lpVoid = ::LockResource( hGlob );

      if ( NULL != lpVoid )
      {
        // *** Now you can work with the loaded resource.

        // *** In this case, we now it is a text file,
        // *** so cast it to a string
        LPCTSTR lpszString = reinterpret_cast< LPCTSTR>( lpVoid );

        MessageBox( NULL, lpszString, _T("From resource"), MB_OK );
      }
    }
  };

  return 0;
}


That's it Wink | ;-)

Jens
GeneralThanks Pin
benben22-Jul-03 4:32
benben22-Jul-03 4:32 
GeneralRe: Thanks Pin
Jens Doose23-Jul-03 21:35
Jens Doose23-Jul-03 21:35 
GeneralAmazing problem Help!!!!!!!!!!!!!!!!!!!!!!!!!!! Pin
xxhimanshu21-Jul-03 20:22
xxhimanshu21-Jul-03 20:22 
GeneralRe: Amazing problem Help!!!!!!!!!!!!!!!!!!!!!!!!!!! Pin
J. Dunlap21-Jul-03 20:39
J. Dunlap21-Jul-03 20:39 
GeneralRe: Amazing problem Help!!!!!!!!!!!!!!!!!!!!!!!!!!! Pin
xxhimanshu21-Jul-03 21:15
xxhimanshu21-Jul-03 21:15 
QuestionHow to use CString variable in regular DLL Pin
Eugene Pustovoyt21-Jul-03 19:01
Eugene Pustovoyt21-Jul-03 19:01 
AnswerRe: How to use CString variable in regular DLL Pin
Toni7821-Jul-03 19:35
Toni7821-Jul-03 19:35 
GeneralRe: How to use CString variable in regular DLL Pin
Eugene Pustovoyt21-Jul-03 19:56
Eugene Pustovoyt21-Jul-03 19:56 
GeneralRe: How to use CString variable in regular DLL Pin
Toni7821-Jul-03 20:09
Toni7821-Jul-03 20:09 
GeneralTranfer double data between dialogs Pin
spaced_out21-Jul-03 17:58
spaced_out21-Jul-03 17:58 
GeneralRe: Tranfer double data between dialogs Pin
Eugene Pustovoyt21-Jul-03 19:07
Eugene Pustovoyt21-Jul-03 19:07 
GeneralRe: Tranfer double data between dialogs Pin
melwyn21-Jul-03 22:05
melwyn21-Jul-03 22:05 
GeneralRe: Tranfer double data between dialogs Pin
Bob Stanneveld22-Jul-03 3:01
Bob Stanneveld22-Jul-03 3:01 
GeneralRe: Tranfer double data between dialogs Pin
spaced_out22-Jul-03 5:07
spaced_out22-Jul-03 5:07 
GeneralProblem Solved!! Pin
spaced_out22-Jul-03 18:24
spaced_out22-Jul-03 18:24 
Generaloutput "%" to Text Pin
wow999921-Jul-03 17:20
wow999921-Jul-03 17:20 
GeneralRe: output "%" to Text Pin
John M. Drescher21-Jul-03 17:30
John M. Drescher21-Jul-03 17:30 

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.