how to link multiple Files using Bcc or MSVC

how to link multiple Files using Bcc or MSVC

Postby Jimmy » Tue Sep 10, 2024 12:43 pm

hi,

when my Project have multiple PRG Files i use

for BCC i use *.MAK File
for MSVC i use *.HBP File

is this right :?:

https://forums.fivetechsupport.com/viewtopic.php?f=3&t=44842&sid=9b1de7d556860056c7dd40843e1ee91b
please always read "build??.bat" corresponding to your version in the samples folder and ensure make your linkscript includs the same libs linked in the build??.bat

or should i make a Copy of BUILD??.BAT and include all my *.PRG into it :?:
how will it look like when include multiple PRG into BUILD??.BAT :?:
greeting,
Jimmy
User avatar
Jimmy
 
Posts: 1732
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: how to link multiple Files using Bcc or MSVC

Postby Antonio Linares » Tue Sep 10, 2024 1:10 pm

regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42099
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: how to link multiple Files using Bcc or MSVC

Postby hua » Wed Sep 11, 2024 3:03 am

.hbp (Harbour project files) is used when you use hbmk2

I normally use .mak files.
There are a lot of make sample files in FWH\MAKES folder
FWH 11.08/FWH 19.12
BCC5.82/BCC7.3
xHarbour/Harbour
hua
 
Posts: 1072
Joined: Fri Oct 28, 2005 2:27 am

Re: how to link multiple Files using Bcc or MSVC

Postby Jimmy » Thu Sep 12, 2024 4:19 pm

hi,

hua wrote:I normally use .mak files.

so do i
but as i understand, we are recommend to use hbmk2.exe and *.hbp file

hua wrote:There are a lot of make sample files in FWH\MAKES folder

these *.MAK files use Bcc32 or BCC64 which is NOT include in Harbour Distribution
(see viewtopic.php?f=3&t=44844&sid=6d13308ac7629a237afc44676ab96671#p273119 )
Postby Antonio Linares » Wed Sep 11, 2024 6:43 am
bcc32.exe has never been included in Harbour builds distributions
greeting,
Jimmy
User avatar
Jimmy
 
Posts: 1732
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: how to link multiple Files using Bcc or MSVC

Postby hua » Thu Sep 12, 2024 6:18 pm

Jimmy wrote:so do i
but as i understand, we are recommend to use hbmk2.exe and *.hbp file

hbmk2 is a powerful harbour built utility to make changing C compiler easy. It will auto detect C compiler to use based on path with minimal to no change to the link script
I still use .mak most of the time though because with hbmk2 I am not sure of the sequence of libs that it linked-in.
With .mak I can be sure my custom lib is link first before fivewin's lib.

Jimmy wrote:these *.MAK files use Bcc32 or BCC64 which is NOT include in Harbour Distribution

Correct. These mak files are templates for you to customize as per your requirement.
Embarcadero allows BCC to be downloaded only from their website
Note that with latest FWH, you'll need BCC 7.7
FWH 11.08/FWH 19.12
BCC5.82/BCC7.3
xHarbour/Harbour
hua
 
Posts: 1072
Joined: Fri Oct 28, 2005 2:27 am

Re: how to link multiple Files using Bcc or MSVC

Postby mauri.menabue » Thu Sep 12, 2024 10:20 pm

Hi Jimmy

for BCC i use *.MAK File

Code: Select all  Expand view

1 Files Build.bat
*--------------------------------------------------------------------------------------------------
REM BUILD FILE
*--------------------------------------------------------------------------------------------------
@echo off

:BUILD
 
   cd d:\zephir\NwCoge
   if exist Sigah.exe del Sigah.exe
   \Bcc7\bin\make -f prog\makeh.mak  
   if errorlevel 1 goto BUILD_ERR

:BUILD_OK

   REM upx Sigah.exe
   if exist Sigah.exe Sigah.exe
   goto EXIT

:BUILD_ERR

   Echo Premere un tasto per terminare l'esecuzione del batch.
   pause > NUL
   goto EXIT

:EXIT


2 Files Mak file
*--------------------------------------------------------------------------------------------------
REM MAK FILE
*--------------------------------------------------------------------------------------------------
!if !$d(DEL)
   DEL = del
!endif

#------------------------------------------------------------------------------
# Make directives
#------------------------------------------------------------------------------

.autodepend
.swap
.suffixes: .prg .hrb

#------------------------------------------------------------------------------
# Flags for modules to include: YES | NO (must be UPPERCASE)
#------------------------------------------------------------------------------

RES_FILE      = YES
LNK_DBFNTX    = YES
LNK_DBFCDX    = YES
LNK_DEBUG     = NO
LNK_ADVANTAGE = NO
LNK_ODBC      = NO
MAP_FILE      = NO

#------------------------------------------------------------------------------
# Application directories & filenames
#------------------------------------------------------------------------------

APP_NAME         = Sigah  # (Your EXE name without extension)
APP_PRG_DIR      = prog
APP_OBJ_DIR      = objh   # (create the app\obj directory first)
APP_INCLUDE_DIR  = include
APP_EXE_DIR      = .
APP_RES_DIR      = $(APP_PRG_DIR)
APP_STD_PRG      = \servizio\prog
APP_STD_OBJ      = \servizio\objh

APP_EXE  = $(APP_EXE_DIR)\$(APP_NAME).exe
APP_RC   = $(APP_RES_DIR)\Risorse.rc
APP_RES  = $(APP_RES_DIR)\Risorse.res
APP_MAP  = $(APP_RES_DIR)\$(APP_NAME).map

#------------------------------------------------------------------------------
# Paths for dependent files
#------------------------------------------------------------------------------

.path.prg = $(APP_PRG_DIR);$(APP_STD_PRG)
.path.hrb = $(APP_OBJ_DIR)
.path.obj = $(APP_OBJ_DIR)

#------------------------------------------------------------------------------
# Application PRG files (your PRG files go here)
#------------------------------------------------------------------------------

APP_PRG_LIST =  \
   Main.prg     \
   LncGet.prg   \
   GesEse.prg   \
   GesnPco.prg  \
   GesOrd.prg   \
   GesFor.prg   \
   GesCli.prg   \
   GesBan.prg   \
   GesPag.prg   \
   GesPar.prg   \
   GesPpr.prg   \
   GesIva.prg   \
   GesBan.prg   \
   GesMsc.prg   \
   GesMrc.prg   \
   GesCom.prg   \
   GesAge.prg   \
   GesReg.prg   \
   GesCnt.prg   \
   GesLav.prg   \
   GesArt.prg   \
   GesFal.prg   \
   GesDba.prg   \
   GesCms.prg   \
   LncDom.prg   \
   GesDcm.prg   \
   GesPst.prg   \
   GesCsc.prg   \
   GesCto.prg   \
   LncFvl.prg   \
   LncScd.prg   \
   LncPrf.prg   \
   GesAcs.prg   \
   GesDiv.prg   \
   GesPae.prg   \
   GesLis.prg   \
   GesLst.prg   \
   GesUmi.prg   \
   GesTsc.prg   \
   GesMcm.prg   \
   GesDom.prg   \
   GesGmg.prg   \
   GesNote.prg  \
   GesMot.prg   \
   GesSar.prg   \
   StaLst.prg   \
   LncSto.prg   \
   LncRoi.prg   \
   LncCor.prg   \
   GesPro.prg   \
   LncPad.prg   \
   LncTcm.prg   \
   GesEpd.prg   \
   GesDes.prg   \
   LncSbl.prg   \
   LncDds.prg   \
   StaGio.prg   \
   GesTrc.prg   \
   GesFtt.prg   \
   GesFta.prg   \
   GesnCau.prg  \
   GesTxt.prg   \
   LncStf.prg   \
   GesPno.prg   \
   GesSca.prg   \
   GesPer.prg   \
   LncFbl.prg   \
   GesSvi.prg   \
   LncSvi.prg   \
   GesCal.prg   \
   GesPor.prg   \
   GesPof.prg   \
   GesDic.prg   \
   GesEqu.prg   \
   GesEqa.prg   \
   GesOff.prg   \
   GesTpm.prg   \
   GesDef.prg   \
   GesAut.prg   \
   LncRdb.prg   \
   LncNcn.prg   \
   GesEdb.prg   \
   GesMtr.prg   \
   LncCsm.prg   \
   GesScd.prg   \
   GesXsc.prg   \
   GesScn.prg   \
   LncInv.prg   \
   LncOsc.prg   \
   GesCof.prg   \
   GesSet.prg   \
   GesSpr.prg   \
   GesUbi.prg   \
   GesToo.prg   \
   GesIso.prg   \
   LncIsp.prg   \
   LncInd.prg   \
   LncPag.prg   \
   LncPan.prg   \
   LncIna.prg   \
   GesNum.prg   \
   GesGbl.prg   \
   GesRbl.prg   \
   StaPno.prg   \
   StaReg.prg   \
   StaRiv.prg   \
   LncCfa.prg   \
   GesSft.prg   \
   LncBil.prg   \
   GesEfl.prg   \
   LncMag.prg   \
   LNcNeg.prg   \
   LncPin.prg   \
   GesFlv.prg   \
   GesLsv.prg   \
   GesSlv.prg   \
   LncChi.prg   \
   GesXpn.prg   \
   GesCcs.prg   \
   GesCoe.prg   \
   GesRag.prg   \
   GesMan.prg   \
   GesCes.prg   \
   LncQam.prg   \
   StaCess.prg  \
   StaCesr.prg  \
   StaCesa.prg  \
   StaCesc.prg  \
   StaMovc.prg  \
   GesCea.prg   \
   GesCee.prg   \
   GetTot.prg   \
   GesSes.prg   \
   LncRtm.prg   \
   LncDnr.prg   \
   GesCmb.prg   \
   GesAll.prg   \
   LncAll.prg   \
   LncMli.prg   \
   GesRmd.prg   \
   GesRri.prg   \
   GesIsp.prg   \
   LncSsc.prg   \
   GesPab.prg   \
   GesTes.prg   \
   GesDet.prg   \
   LncDcf.prg   \
   GesOpe.prg   \
   LncPfo.prg   \
   LncPfa.prg   \
   LncOpe.prg   \
   GesOpr.prg   \
   GesAcf.prg   \
   GesDcf.prg   \
   StaCfp.prg   \
   StaFfp.prg   \
   GesRit.prg   \
   GesPrv.prg   \
   GesCom.prg   \
   GesFtp.prg   \
   LncSfp.prg   \
   LncMas.prg   \
   LncVai.prg   \
   LncCsc.prg   \
   LncMrc.prg   \
   LncSmo.prg   \
   GesRca.prg   \
   GesOpi.prg   \
   LncOpi.prg   \
   GesRcb.prg   \
   LncPfi.prg   \
   GesErr.prg   \
   GesCfo.prg   \
   GesTrt.prg   \
   GesTrr.prg   \
   GesBka.prg   \
   GesBkb.prg   \
   GesBoi.prg   \
   GesOpb.prg   \
   LncNcf.prg   \
   GesMcr.prg   \
   GesLin.prg   \
   GesMac.prg   \
   GesOpt.prg   \
   GesNli.prg   \
   GesNln.prg   \
   LncSup.prg   \
   GesMal.prg   \
   GesLee.prg   \
   GesRel.prg   \
   GesDma.prg   \
   GesDop.prg   \
   GesRap.prg   \
   GesGia.prg   \
   GesVof.prg   \
   GesSta.prg   \
   GesSmg.prg   \
   GesAst.prg   \
   GesAce.prg   \
   GesEbu.prg   \
   GesBus.prg   \
   LncIcl.prg   \
   GesUsa.prg   \
   GesUse.prg   \
   GesUss.prg   \
   LncTcg.prg   \
   GesVes.prg   \
   GesVtc.prg   \
   GesGio.prg   \
   GesSdo.prg   \
   GesSdc.prg   \
   GesSmt.prg   \
   GesSma.prg   \
   GesPis.prg   \
   GesFdf.prg   \
   LncFdf.prg   \
   LncGef.prg   \
   LncErt.prg   \
   LncAtt.prg   \
   GesSsp.prg   \
   GesMes.prg   \
   GesInv.prg   \
   GesTra.prg   \
   GesDdi.prg   \
   LncXml.prg   \
   GesUtd.prg   \
   LncUtd.prg   \
   LncSlc.prg   \
   LncSlf.prg   \
   GesTpp.prg   \
   LncSor.prg   \
   LncSof.prg   \
   LncSfa.prg   \
   LncSam.prg   \
   LncOrd.prg   \
   GesOri.prg   \
   GesSog.prg   \
   GesMmg.prg   \
   LncIpp.prg   \
   CheckRes.prg \
   LncMsg.prg   \
   GesPrc.prg   \
   GesAzi.prg   \
   GesGp90.prg  \
   GesFas.prg   \
   GesFsa.prg   \
   GesLog.prg   \
   GesVlt.prg   \
   Lib_Func.prg \
   StdGes.prg   \
   LncSof.prg   \
   LncOst.prg   \
   Fwxlsxlb.prg \
   StdSta.prg  

#------------------------------------------------------------------------------
# Contruction of the rest dependency lists
#   xBrowse.prg  \
#------------------------------------------------------------------------------

APP_PRGS = $(APP_PRG_LIST)
APP_HRBS = $(APP_PRG_LIST:.prg=.hrb)
APP_OBJS = $(APP_PRG_LIST:.prg=.obj)

#------------------------------------------------------------------------------
# Fivewin directories
#------------------------------------------------------------------------------

FIVEWIN_INCLUDE_DIR = \fwh\include
FIVEWIN_LIB_DIR     = \fwh\lib

#------------------------------------------------------------------------------
# TsBrowse libraries
#------------------------------------------------------------------------------

TSBRO_LIB  = \fw24\tsbrowse\lib\sbrowseh
BTNGET_LIB = \fw24\btnget\tbtngth
TSBUTT_LIB = \fw24\tsbutton\lib\sbuttonh

#------------------------------------------------------------------------------
# Fivewin libraries
#------------------------------------------------------------------------------

FIVE_LIB  = $(FIVEWIN_LIB_DIR)\fiveH.lib
FIVEC_LIB = $(FIVEWIN_LIB_DIR)\fiveHC.lib
FIVE_XLSX = $(FIVEWIN_LIB_DIR)\xlsxlibhbbcc.lib

#------------------------------------------------------------------------------
# Harbour directories & flags
#------------------------------------------------------------------------------

HARBOUR_INCLUDE_DIR = \harbour\include
HARBOUR_EXE_DIR     = \harbour\bin
HARBOUR_LIB_DIR     = \harbour\lib
HARBOUR_FLAGS       = -i$(APP_INCLUDE_DIR);$(FIVEWIN_INCLUDE_DIR);$(HARBOUR_INCLUDE_DIR) -n -m -w -es2 -gc0 -u+rddleto.ch
HARBOUR_EXE         = $(HARBOUR_EXE_DIR)\harbour.exe

#------------------------------------------------------------------------------
# Harbour libraries
#------------------------------------------------------------------------------

CPAGE_LIB     = $(HARBOUR_LIB_DIR)\hbcpage.lib
LANG_LIB      = $(HARBOUR_LIB_DIR)\hblang.lib
VM_LIB        = $(HARBOUR_LIB_DIR)\hbvm.lib
RTL_LIB       = $(HARBOUR_LIB_DIR)\hbrtl.lib
RDD_LIB       = $(HARBOUR_LIB_DIR)\hbrdd.lib
HBSIX_LIB     = $(HARBOUR_LIB_DIR)\hbsix.lib
MACRO_LIB     = $(HARBOUR_LIB_DIR)\hbmacro.lib
PP_LIB        = $(HARBOUR_LIB_DIR)\hbpp.lib
DBFNTX_LIB    = $(HARBOUR_LIB_DIR)\rddntx.lib
DBFCDX_LIB    = $(HARBOUR_LIB_DIR)\rddcdx.lib
DBFFPT_LIB    = $(HARBOUR_LIB_DIR)\rddfpt.lib
CPLR_LIB      = $(HARBOUR_LIB_DIR)\hbcplr.lib
DEBUG_LIB     = $(HARBOUR_LIB_DIR)\hbdebug.lib
COMMON_LIB    = $(HARBOUR_LIB_DIR)\hbcommon.lib
GTWIN_LIB     = $(HARBOUR_LIB_DIR)\gtgui.lib
WIN_LIB       = $(HARBOUR_LIB_DIR)\hbwin.lib
CT_LIB        = $(HARBOUR_LIB_DIR)\hbct.lib
XHB_LIB       = $(HARBOUR_LIB_DIR)\xhb.lib
HBZIPARC_LIB  = $(HARBOUR_LIB_DIR)\hbziparc.lib
HBMZIP_LIB    = $(HARBOUR_LIB_DIR)\hbmzip.lib
HBZLIB_LIB    = $(HARBOUR_LIB_DIR)\hbzlib.lib
MINIZIP_LIB   = $(HARBOUR_LIB_DIR)\minizip.lib
HBPCRE_LIB    = $(HARBOUR_LIB_DIR)\hbpcre.lib
RDDLETO_LIB   = $(HARBOUR_LIB_DIR)\rddleto.lib
HBZEBRA_LIB   = $(HARBOUR_LIB_DIR)\hbzebra.lib
HBXLSXML_LIB  = $(HARBOUR_LIB_DIR)\hbxlsxml.lib

#------------------------------------------------------------------------------
# Advantage libraries
#------------------------------------------------------------------------------

RDDADS_LIB = $(HARBOUR_LIB_DIR)\rddads.lib
ACE32_LIB  = $(HARBOUR_LIB_DIR)\ace32.lib

#------------------------------------------------------------------------------
# Borlanc directories & flags
#------------------------------------------------------------------------------

BORLANDC_INCLUDE_DIR = \Bcc7\include
BORLANDC_EXE_DIR     = \Bcc7\bin
BORLANDC_LIB_DIR     = \Bcc7\lib
BORLANDC_COMP_FLAGS  = -c -O2 -6 -D"__HARBOUR__" -I$(HARBOUR_INCLUDE_DIR);$(BORLANDC_INCLUDE_DIR)
BORLANDC_COMP_EXE    = $(BORLANDC_EXE_DIR)\bcc32.exe
BORLANDC_LINK_FLAGS  = -Gn -aa -Tpe -s -I$(APP_OBJ_DIR) -L$(BORLANDC_LIB_DIR)
BORLANDC_LINK_FDEBUG = -Gn -Tpe -s -I$(APP_OBJ_DIR) -L$(BORLANDC_LIB_DIR)
BORLANDC_LINK_EXE    = $(BORLANDC_EXE_DIR)\ilink32.exe
BORLANDC_RES_EXE     = $(BORLANDC_EXE_DIR)\brc32.exe

!if $(MAP_FILE) != YES
   BORLANDC_LINK_FLAGS = $(BORLANDC_LINK_FLAGS) -x
!endif

#------------------------------------------------------------------------------
# Borland libraries & files
#------------------------------------------------------------------------------

STARTUP_OBJ  = $(BORLANDC_LIB_DIR)\c0w32.obj
CW32_LIB     = $(BORLANDC_LIB_DIR)\cw32.lib
UUID_LIB     = $(BORLANDC_LIB_DIR)\uuid.lib
IMPORT32_LIB = $(BORLANDC_LIB_DIR)\import32.lib
ODBC32_LIB   = $(BORLANDC_LIB_DIR)\psdk\odbc32.lib
MSIM32_LIB   = $(BORLANDC_LIB_DIR)\psdk\msimg32.lib
NDDEAPI_LIB  = $(BORLANDC_LIB_DIR)\psdk\nddeapi.lib
IPHLPAPI_LIB = $(BORLANDC_LIB_DIR)\psdk\iphlpapi.lib
RASAPI32_LIB = $(BORLANDC_LIB_DIR)\psdk\rasapi32.lib
PSAPI_LIB    = $(BORLANDC_LIB_DIR)\psdk\psapi.lib
GDIPLUS_LIB  = $(BORLANDC_LIB_DIR)\psdk\gdi32.lib
SHELL32_LIB  = $(BORLANDC_LIB_DIR)\psdk\shell32.lib
CW32MT_LIB   = $(BORLANDC_LIB_DIR)\cw32mt.lib

#------------------------------------------------------------------------------
# Dependencies
#------------------------------------------------------------------------------

all: $(APP_OBJS) $(APP_HRBS) $(APP_EXE)

!if $(RES_FILE) == YES
all: $(APP_RES)
!endif

#------------------------------------------------------------------------------
# Implicit Rules
#------------------------------------------------------------------------------

.prg.hrb:
   $(HARBOUR_EXE) $(HARBOUR_FLAGS) $** -o$@

.hrb.obj:
   $(BORLANDC_COMP_EXE) $(BORLANDC_COMP_FLAGS) -o$@ $**

#------------------------------------------------------------------------------
# Explicit Rules
#------------------------------------------------------------------------------

!if $(RES_FILE) == YES
$(APP_RES) : $(APP_RC)
   $(BORLANDC_RES_EXE) -r $**

$(APP_EXE) :: $(APP_RES)
   @if exist $(APP_EXE) $(DEL) $(APP_EXE) > nul
!endif

$(APP_EXE) :: $(APP_OBJS)
!if $(LNK_DEBUG) == YES
   $(BORLANDC_LINK_EXE) $(BORLANDC_LINK_FDEBUG) @&&|
!else
   $(BORLANDC_LINK_EXE) $(BORLANDC_LINK_FLAGS) @&&|
!endif
   $(STARTUP_OBJ) +
   $(**), +
   $(APP_EXE), +
   $(APP_MAP), +
   $(TSBRO_LIB) +
   $(FIVE_LIB) +
   $(FIVEC_LIB) +
   $(FIVE_XLSX) +
   $(BTNGET_LIB) +
   $(VM_LIB) +
   $(RTL_LIB) +
   $(CT_LIB) +
   $(GTWIN_LIB) +
   $(CPLR_LIB) +
   $(WIN_LIB) +
   $(LANG_LIB) +
   $(MACRO_LIB) +
   $(RDD_LIB) +
   $(HBSIX_LIB) +
   $(HBPCRE_LIB) +
   $(CPAGE_LIB) +
   $(XHB_LIB) +
   $(HBZIPARC_LIB) +
   $(HBMZIP_LIB) +
   $(HBZLIB_LIB) +
   $(MINIZIP_LIB) +
!if $(LNK_DBFNTX) == YES
   $(DBFNTX_LIB) +
!endif
!if $(LNK_DBFCDX) == YES
   $(DBFCDX_LIB) +
   $(DBFFPT_LIB) +
!endif
   $(RDDLETO_LIB)+
   $(HBZEBRA_LIB)+
   $(HBXLSXML_LIB)+
!if $(LNK_DEBUG) == YES
   $(DEBUG_LIB) +
!endif
   $(COMMON_LIB) +
   $(PP_LIB) +
!if $(LNK_ADVANTAGE) == YES
   $(RDDADS_LIB) +
   $(ACE32_LIB) +
!endif
!if $(LNK_ODBC) == YES
   $(ODBC32_LIB) +
!endif
   $(MSIM32_LIB) +
   $(CW32MT_LIB) +
   $(UUID_LIB) +
   $(NDDEAPI_LIB) +
   $(IMPORT32_LIB) +
   $(IPHLPAPI_LIB) +
   $(RASAPI32_LIB) +
   $(PSAPI_LIB) +
   $(GDIPLUS_LIB) +
   $(SHELL32_LIB), +
!if $(RES_FILE) == YES
   ,$(APP_RES)
!endif
|
#------------------------------------------------------------------------------
# Delete temporary file
#------------------------------------------------------------------------------

   @$(DEL) $(APP_EXE_DIR)\$(APP_NAME).tds
User avatar
mauri.menabue
 
Posts: 155
Joined: Thu Apr 17, 2008 2:38 pm

Re: how to link multiple Files using Bcc or MSVC

Postby Jimmy » Fri Sep 13, 2024 5:17 am

hi,
mauri.menabue wrote:for BCC i use *.MAK File

THX for Answer and your Sample
i don´t think that it is a Problem of my *.MAK Files, it have been working before
Code: Select all  Expand view
111 BOOL EjectVolume( TCHAR * cDriveLetter )
112 {
113   HANDLE hVolume;
114   BOOL fRemoveSafely ; //  = FALSE;
115   BOOL fAutoEject    ; //  = FALSE;
116
117   BOOL fRemoveSafely = FALSE;
118   BOOL fAutoEject    = FALSE;
119
120   hVolume = OpenVolume(cDriveLetter);
121   if( hVolume == INVALID_HANDLE_VALUE )
122     return FALSE;
123
124  if( LockVolume(hVolume) && DismountVolume(hVolume) )
125     fRemoveSafely = TRUE;
126   {
127     if (PreventRemovalOfVolume(hVolume, FALSE) && AutoEjectVolume(hVolume))
128           fAutoEject = TRUE;
129   }
130
131   if( ! CloseVolume(hVolume) )
132     return FALSE;
133
134   return TRUE;
135}
136
137    HB_FUNC( EJECTREMOVABLE )
138    {
139        const char* szDrive = hb_parc(1);
140        TCHAR tszDrive[3] = TEXT("\0\0");
141
142        if (szDrive && szDrive[0] != '\0')
143        {
144            #ifdef UNICODE
145                MultiByteToWideChar(CP_ACP, 0, szDrive, 1, tszDrive, 1);
146            #else
147                tszDrive[0] = szDrive[0];
148            #endif
149            tszDrive[1] = TEXT(':');
150        }
151
152        hb_retl(EjectVolume(tszDrive));
153    }

Warning W8004 HB_FUNC.PRG 135: 'fAutoEject' is assigned a value that is never used in function EjectVolume
Warning W8004 HB_FUNC.PRG 135: 'fRemoveSafely' is assigned a value that is never used in function EjectVolume
Warning W8080 HB_FUNC.PRG 135: 'fAutoEject' is declared but never used in function EjectVolume
Warning W8080 HB_FUNC.PRG 135: 'fRemoveSafely' is declared but never used in function EjectVolume
Warning W8057 HB_FUNC.PRG 135: Parameter 'cDriveLetter' is never used in function EjectVolume
Error E2342 HB_FUNC.PRG 152: Type mismatch in parameter 'cDriveLetter' (wanted 'signed char', got 'signed char *') in
function HB_FUN_EJECTREMOVABLE

i don´t understand why i got 8 Errors, as it show me 5 WARNING
greeting,
Jimmy
User avatar
Jimmy
 
Posts: 1732
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: how to link multiple Files using Bcc or MSVC

Postby Antonio Linares » Fri Sep 13, 2024 12:17 pm

I get these here:

Warning W8045 jimmy.prg 20: No declaration for function 'OpenVolume' in function EjectVolume
Warning W8069 jimmy.prg 20: Nonportable pointer conversion in function EjectVolume
Warning W8045 jimmy.prg 24: No declaration for function 'LockVolume' in function EjectVolume
Warning W8045 jimmy.prg 24: No declaration for function 'DismountVolume' in function EjectVolume
Warning W8045 jimmy.prg 27: No declaration for function 'PreventRemovalOfVolume' in function EjectVolume
Warning W8045 jimmy.prg 27: No declaration for function 'AutoEjectVolume' in function EjectVolume
Warning W8045 jimmy.prg 31: No declaration for function 'CloseVolume' in function EjectVolume
Warning W8004 jimmy.prg 35: 'fAutoEject' is assigned a value that is never used in function EjectVolume
Warning W8004 jimmy.prg 35: 'fRemoveSafely' is assigned a value that is never used in function EjectVolume

Where are OpenVolume, LockVolume, etc defined ?
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42099
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: how to link multiple Files using Bcc or MSVC

Postby Jimmy » Fri Sep 13, 2024 1:23 pm

hi Antonio,

i have posted only line 111 - 153 so the missing CODE are before Line 111
here is the full HB_FUNC.PRG CODE
Code: Select all  Expand view

#pragma begindump

#include <windows.h>
#include <winioctl.h>
#include <tchar.h>
#include <stdio.h>
#include "hbapi.h"
#include "hbapifs.h"

// Prototypes
BOOL EjectVolume(TCHAR cDriveLetter);
HANDLE OpenVolume(TCHAR cDriveLetter);
BOOL LockVolume(HANDLE hVolume);
BOOL DismountVolume(HANDLE hVolume);
BOOL PreventRemovalOfVolume(HANDLE hVolume, BOOL fPrevent);
BOOL AutoEjectVolume(HANDLE hVolume);
BOOL CloseVolume(HANDLE hVolume);

LPTSTR szVolumeFormat = TEXT("\\\\.\\%c:");
LPTSTR szRootFormat = TEXT("%c:\\");

HANDLE OpenVolume(TCHAR cDriveLetter)
{
   HANDLE hVolume;
   UINT uDriveType;
   TCHAR szVolumeName[8];
   TCHAR szRootName[5];
   DWORD dwAccessFlags;

   wsprintf(szRootName, szRootFormat, cDriveLetter);
   uDriveType = GetDriveType(szRootName);

   switch(uDriveType)
   {
   case DRIVE_REMOVABLE:
     dwAccessFlags = GENERIC_READ | GENERIC_WRITE;
     break;
   case DRIVE_CDROM:
     dwAccessFlags = GENERIC_READ;
     break;
   default:
     return INVALID_HANDLE_VALUE;
   }

   wsprintf(szVolumeName, szVolumeFormat, cDriveLetter);

   hVolume = CreateFile( szVolumeName,
                         dwAccessFlags,
                         FILE_SHARE_READ | FILE_SHARE_WRITE,
                         NULL,
                         OPEN_EXISTING,
                         0,
                         NULL );
   return hVolume;
}

BOOL CloseVolume(HANDLE hVolume)
{
   return CloseHandle(hVolume);
}

#define LOCK_TIMEOUT        10000       // 10 Seconds
#define LOCK_RETRIES        20

BOOL LockVolume( HANDLE hVolume )
{
   DWORD dwBytesReturned;
   DWORD dwSleepAmount;
   int nTryCount;

   dwSleepAmount = LOCK_TIMEOUT / LOCK_RETRIES;

   for( nTryCount = 0; nTryCount < LOCK_RETRIES; nTryCount++ )
   {
     if( DeviceIoControl( hVolume, FSCTL_LOCK_VOLUME, NULL, 0, NULL, 0,
                          &dwBytesReturned, NULL ) )
         return TRUE;

     Sleep( dwSleepAmount );
   }

   return FALSE;
}

BOOL DismountVolume( HANDLE hVolume )
{
   DWORD dwBytesReturned;
   return DeviceIoControl( hVolume, FSCTL_DISMOUNT_VOLUME, NULL, 0, NULL, 0,
                           &dwBytesReturned, NULL );
}

BOOL PreventRemovalOfVolume(HANDLE hVolume, BOOL fPreventRemoval)
{
   DWORD dwBytesReturned;
   PREVENT_MEDIA_REMOVAL PMRBuffer;
   PMRBuffer.PreventMediaRemoval = fPreventRemoval;
   return DeviceIoControl( hVolume, IOCTL_STORAGE_MEDIA_REMOVAL,
                           &PMRBuffer, sizeof(PREVENT_MEDIA_REMOVAL),
                           NULL, 0, &dwBytesReturned, NULL );
}

AutoEjectVolume( HANDLE hVolume )
{
   DWORD dwBytesReturned;
   return DeviceIoControl( hVolume, IOCTL_STORAGE_EJECT_MEDIA, NULL, 0, NULL, 0,
                         &dwBytesReturned,
                         NULL );
}

BOOL EjectVolume( TCHAR * cDriveLetter )
{
   HANDLE hVolume;
   BOOL fRemoveSafely ; //  = FALSE;
   BOOL fAutoEject    ; //  = FALSE;

   BOOL fRemoveSafely = FALSE;
   BOOL fAutoEject    = FALSE;

   hVolume = OpenVolume(cDriveLetter);
   if( hVolume == INVALID_HANDLE_VALUE )
     return FALSE;

   if( LockVolume(hVolume) && DismountVolume(hVolume) )
     fRemoveSafely = TRUE;
   {
     if (PreventRemovalOfVolume(hVolume, FALSE) && AutoEjectVolume(hVolume))
           fAutoEject = TRUE;
   }

   if( ! CloseVolume(hVolume) )
     return FALSE;

   return TRUE;
}

    HB_FUNC( EJECTREMOVABLE )
    {
        const char* szDrive = hb_parc(1);
        TCHAR tszDrive[3] = TEXT("\0\0");

        if (szDrive && szDrive[0] != '\0')
        {
            #ifdef UNICODE
                MultiByteToWideChar(CP_ACP, 0, szDrive, 1, tszDrive, 1);
            #else
                tszDrive[0] = szDrive[0];
            #endif
            tszDrive[1] = TEXT(':');
        }

        hb_retl(EjectVolume(tszDrive));
    }

#pragma enddump
 

and here the Main Programm CODE
Code: Select all  Expand view
#include "FIVEWIN.ch"
#include "common.ch"

PROCEDURE MAIN()
LOCAL oDlg, oListbox
LOCAL cDrive  := SPACE( 2 )
LOCAL cTitle  := "Please, select " + FWVERSION
LOCAL aDrives := aDrives()
LOCAL bSetGet      := { | x | cDrive := x }
LOCAL bChange
LOCAL bValid
LOCAL bLDblClicked
LOCAL bWhen
LOCAL bDrawItem

   DEFINE DIALOG oDlg FROM 5, 10 TO 24, 55 TITLE cTitle

      oListbox := TListBox() :New( 10, 20, bSetGet, aDrives, 145, 95, bChange, ;
                             oDlg, bValid,,, .T., .F., ;
                             bLDblClicked,, "", .T., bWhen,, ;
                             bDrawItem, .F., .F. )

      @  7,  7 BUTTON "&OK" OF oDlg SIZE 40, 12 ;
             ACTION( USBeject( cDrive ), oDlg:End() ) DEFAULT

      @  7, 17 BUTTON "&Cancel" OF oDlg SIZE 40, 12 ;
              ACTION( cDrive := nil, oDlg:End() )

#IFDEF __HMG__
   END DIALOG
#ENDIF

   ACTIVATE DIALOG oDlg CENTERED

RETURN

STATIC PROCEDURE USBeject(cDriveLetter )
   IF EjectRemovable( cDriveLetter )
      MsgInfo( "The Drive " + cDriveLetter + " Can be Safely Removed", "Atenttion ! , Remove USB Ok" )
   ELSE
      MsgInfo( "Failed to Safely Remove/Eject Drive " + cDriveLetter , "Atenttion ! , Failed Remove USB" )
   ENDIF
RETURN

*+ EOF: FWEJECT.PRG
 
greeting,
Jimmy
User avatar
Jimmy
 
Posts: 1732
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 40 guests