How do I run files contained in resource files directly

Moderator: Rathinagiri

Post Reply
huiyi_ch
Posts: 172
Joined: Sat May 21, 2016 5:27 am

How do I run files contained in resource files directly

Post 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?
User avatar
esgici
Posts: 4543
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Contact:

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

Post 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
Viva INTERNATIONAL HMG :D
User avatar
serge_girard
Posts: 3161
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Contact:

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

Post 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
There's nothing you can do that can't be done...
huiyi_ch
Posts: 172
Joined: Sat May 21, 2016 5:27 am

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

Post by huiyi_ch »

Thank you Serge and esgici
User avatar
Rathinagiri
Posts: 5471
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

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

Post by Rathinagiri »

Super. Thank you Esgici and Serge.
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
User avatar
serge_girard
Posts: 3161
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Contact:

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

Post 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
There's nothing you can do that can't be done...
Post Reply