I am new to PB.
My primary language is not US/UK. I am using Google Translate.
I have a commandline executable file. I want to package it with the exe file made from PB.
Does PB support this?
Embed a file in the DataSection and write it to the temp directory.
Embed a file in the DataSection and write it to the temp directory
-
- User
- Posts: 97
- Joined: Wed Nov 16, 2022 1:51 pm
Embed a file in the DataSection and write it to the temp directory
PC: Windows 10 x64, 8GB RAM. PB ver: 6.x
--
I love PB5 vs PB6
--
I love PB5 vs PB6

Re: Embed a file in the DataSection and write it to the temp directory
You may have to activate the option for compiling in the source directory in the compiler options 'Compile/Run' so that the EXE is found without a path.
Peter
Peter
Code: Select all
EnableExplicit
#ExeName = "prog.exe"
Define iFileNr.i, sFileName.s, iResult.i
sFileName = GetTemporaryDirectory() + #ExeName
iFileNr = CreateFile(#PB_Any, sFileName)
If iFileNr
iResult = WriteData(iFileNr, ?ExeStart, ?ExeEnd - ?ExeStart)
Debug "Bytes: " + iResult + " - File: " + sFileName
CloseFile(iFileNr)
DeleteFile(sFileName)
EndIf
DataSection
ExeStart:
IncludeBinary #ExeName
ExeEnd: