Page 1 of 1

How do I run files contained in resource files directly

Posted: Sun Dec 02, 2018 9:48 am
by huiyi_ch
Suppose I include a help file in the resource file:
CFILE RCDATA HELP.CHM
I want to run this HELP.CHM directly in the program,How do I write code?

Re: How do I run files contained in resource files directly

Posted: Sun Dec 02, 2018 10:04 am
by esgici
huiyi_ch wrote: Sun Dec 02, 2018 9:48 am Suppose I include a help file in the resource file:
CFILE RCDATA HELP.CHM
I want to run this HELP.CHM directly in the program,How do I write code?
Hi Huiyi

Not all type of file usable in resource file, resource manner;

please look at: http://www.hmgforum.com/viewtopic.php?f=24&t=2291

Happy HMG'ing :D

Re: How do I run files contained in resource files directly

Posted: Sun Dec 02, 2018 10:16 am
by serge_girard
Hi Huiyi,

What you can do is following: include in RC:

RC file: (example)

Code: Select all

README    RCDATA read_me.txt
libmysql  RCDATA c:\hmg.3.0.44\libmysql.dll
Prg file:

Code: Select all

#Include <hmg.ch>

Function Main()
LOCAL cFileRes := ResToFile("README")

MsgInfo(cFileRes)

cFileRes := ResToFile("libmysql")

IF !FILE('libmysql.dll')
	STRFILE(HMG_LoadResourceRawFile ( 'libmysql', RT_RCDATA ),'libmysql.dll')
ENDIF

Return Nil

#pragma BEGINDUMP
#include <Windows.h>
#include <hbApi.h>

HB_FUNC( RESTOFILE )
{
 static HRSRC hr;
 static HGLOBAL hg;

 hr = FindResource( NULL, (LPSTR) hb_parc( 1 ), RT_RCDATA );
 if( ! ( hr == 0 ) )
   {
    hg = LoadResource( NULL, hr );
    if( ! ( hg == 0 ) )
      {
       char *lpRcData=( char *)LockResource( hg );
       hb_retc( lpRcData );
      }
   }
}

#pragma ENDDUMP
I hope this can serve you!

Serge

Re: How do I run files contained in resource files directly

Posted: Mon Dec 03, 2018 3:03 am
by huiyi_ch
Thank you Serge and esgici

Re: How do I run files contained in resource files directly

Posted: Mon Dec 03, 2018 2:23 pm
by Rathinagiri
Super. Thank you Esgici and Serge.

Re: How do I run files contained in resource files directly

Posted: Mon Dec 03, 2018 4:32 pm
by serge_girard
Rathi,

It was just some copy and paste from several samples from this forum...

Especially including the libmysql.dll was for great interest of me because it isn't standard included and in all my programs I need it.

Serge