How do I run files contained in resource files directly

Moderator: Rathinagiri

Post Reply
huiyi_ch
Posts: 87
Joined: Sat May 21, 2016 5:27 am
Has thanked: 1 time
Been thanked: 10 times

How do I run files contained in resource files directly

Post by huiyi_ch » 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?

User avatar
esgici
Posts: 4472
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Has thanked: 352 times
Been thanked: 104 times
Contact:

Post by esgici » Sun Dec 02, 2018 10:04 am

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: 2161
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Has thanked: 469 times
Been thanked: 108 times
Contact:

Post by serge_girard » Sun Dec 02, 2018 10:16 am

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

huiyi_ch
Posts: 87
Joined: Sat May 21, 2016 5:27 am
Has thanked: 1 time
Been thanked: 10 times

Post by huiyi_ch » Mon Dec 03, 2018 3:03 am

Thank you Serge and esgici

User avatar
Rathinagiri
Posts: 5250
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Has thanked: 167 times
Been thanked: 165 times
Contact:

Post by Rathinagiri » Mon Dec 03, 2018 2:23 pm

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: 2161
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Has thanked: 469 times
Been thanked: 108 times
Contact:

Post by serge_girard » Mon Dec 03, 2018 4:32 pm

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

Post Reply