Here is the code that I forget to paste above after step 5.
Haste makes waste...
![[smile] [smile] [smile]](/data/assets/smilies/smile.gif)
___
Option Explicit
Private Declare Function EndUpdateResource Lib "kernel32" Alias "EndUpdateResourceA" (ByVal hUpdate As Long, ByVal fDiscard As Long) As Long
Private Declare Function UpdateResource Lib "kernel32" Alias "UpdateResourceA" (ByVal hUpdate As Long, ByVal lpType As Long, ByVal lpName As Long, ByVal wLanguage As Long, ByVal lpData As String, ByVal cbData As Long) As Long
Private Declare Function BeginUpdateResource Lib "kernel32" Alias "BeginUpdateResourceA" (ByVal pFileName As String, ByVal bDeleteExistingResources As Long) As Long
Const RT_MANIFEST = 24
Const CREATEPROCESS_MANIFEST_RESOURCE_ID = 1
Private Sub Form_Load()
AddManifestResource "D:\MyApp\Myapp.exe"
End
End Sub
Public Sub AddManifestResource(ExeFile As String)
'Read the manifest data from the .manifest file.
Dim Manifest As String
Open ExeFile & ".manifest" For Binary As #1
Manifest = Space$(LOF(1))
Get #1, , Manifest
Close
'Update(add) the manifest resource into the exe file.
Dim hRes As Long
hRes = BeginUpdateResource(ExeFile, 0)
UpdateResource hRes, RT_MANIFEST, _
CREATEPROCESS_MANIFEST_RESOURCE_ID, _
0, ByVal Manifest, Len(Manifest)
EndUpdateResource hRes, 0
End Sub