Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version
Go to top

dotNetInstaller - Setup Bootstrapper for .NET Application

, 4 Jan 2004
With this tool the developer can define the application prerequisites and install the correct version of these components in the correct order based on the user operating system type and language, allow the user to download these components from the web or install these components directly.
dotnetinstaller_source.zip
dotNetInstaller_source
dotNetInstaller
dotNetInstaller.vcproj.vspscc
dotNetInstaller.vssscc
mssccprj.scc
res
banner.bmp
dotNetInstaller.ico
dotNetInstaller.manifest
Thumbs.db
vssver.scc
Tools
vssver.scc
vssver.scc
InstallerEditor
App.ico
banner.bmp
bin
Release
InstallerEditor.exe
SourceLibrary.dll
vssver.scc
InstallerEditor.csproj.user
InstallerEditor.csproj.vspscc
InstallerEditor.suo
InstallerEditor.vssscc
mssccprj.scc
References
SourceLibrary.dll
vssver.scc
Thumbs.db
vssver.scc
Sample
banner.bmp
dotNetInstaller.exe
SupportFiles
DataAccess
Jet
Jet40Sp7
Win2000_English
Win2000_Italiano
Win9x_NT
WinME
WinXp_English
WinXp_Italiano
MDAC2.7Sp1Refresh
Win_98_ME_NT_2000
dotNet
v1.1
English
Italiano
InternetExplorer
IE60SP1_English
IE60SP1_Italiano
ServicePack
2000_SP4_English
2000_SP4_Italiano
NT4_SP6a_English
NT4_SP6a_Italiano
Win98_Y2k_Update_English
Win98_Y2k_Update_Italiano
using System;
using System.Drawing;
using System.Runtime.InteropServices;

namespace InstallerEditor
{
	/// <summary>
	/// Summary description for ResourceUpdate.
	/// </summary>
	public class ResourceUpdate
	{

		[DllImport("KERNEL32.DLL", 
			 EntryPoint="BeginUpdateResourceW",
			 SetLastError=true,
			 CharSet=CharSet.Unicode,
			 ExactSpelling=true,
			 CallingConvention=CallingConvention.StdCall)]
		private static extern IntPtr BeginUpdateResource(
			string pFileName,             // executable file name
			bool bDeleteExistingResources  // deletion option
			);


		[DllImport("KERNEL32.DLL", 
			 EntryPoint="UpdateResourceW",
			 SetLastError=true,
			 CharSet=CharSet.Unicode,
			 ExactSpelling=true,
			 CallingConvention=CallingConvention.StdCall)]
		private static unsafe extern bool UpdateResource(
			IntPtr hUpdate, // update-file handle
			string lpType, // resource type (l'API � molto strana perch� puo prendere ho una stringa o un intero, vedi MAKEINTRESOURCE)
			string lpName, // resource name
			UInt16 wLanguage, // language identifier
			void * lpData,  // resource data
			UInt32 cbData    // length of resource data
			);


		[DllImport("KERNEL32.DLL", 
			 EntryPoint="EndUpdateResourceW",
			 SetLastError=true,
			 CharSet=CharSet.Unicode,
			 ExactSpelling=true,
			 CallingConvention=CallingConvention.StdCall)]
		private static extern bool EndUpdateResource(
			IntPtr hUpdate, // update-file handle
			bool fDiscard   // write option 
			);


		public ResourceUpdate()
		{
		}

		public static unsafe void UpdateResourceWithFile(string p_BinFileName, string p_ResourceName, string p_ResourceType, UInt16 p_ResourceLanguage, string p_UpdateSource)
		{
			byte[] l_bmpBuffer;
			using (System.IO.FileStream l_ImageStream = new System.IO.FileStream(p_UpdateSource,System.IO.FileMode.Open, System.IO.FileAccess.Read))
			{
				l_bmpBuffer = new byte[l_ImageStream.Length];
				l_ImageStream.Read(l_bmpBuffer, 0, (int)l_ImageStream.Length);
				l_ImageStream.Close();
			}

			UpdateResource(p_BinFileName, p_ResourceName, p_ResourceType, l_bmpBuffer, p_ResourceLanguage);
		}

		public static unsafe void UpdateResource(string p_BinFileName, string p_ResourceName, string p_ResourceType, byte[] p_Buffer, UInt16 p_ResourceLanguage)
		{
			// Open the file to which you want to add the dialog box resource. 
			IntPtr hUpdateRes = BeginUpdateResource(p_BinFileName, false); 
			if (hUpdateRes == IntPtr.Zero) 
				throw new ApplicationException("Could not open file for writing."); 

			bool l_retVal;

			fixed (byte * l_BytePtr = p_Buffer)
			{
				// Add the dialog box resource to the update list. 
				l_retVal = UpdateResource(hUpdateRes,       // update resource handle 
					p_ResourceType,                   //  resource type
					p_ResourceName,                  // resource name box name 
					p_ResourceLanguage,  // neutral language, equivalente a MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL)
					l_BytePtr,                   // ptr to resource info 
					(UInt32)p_Buffer.Length); // size of resource info. 
			}

			if (l_retVal == false) 
				throw new ApplicationException("Could not add resource."); 
 
			// Write changes to FOOT.EXE and then close it. 
			l_retVal = EndUpdateResource(hUpdateRes, false);
			if (l_retVal == false) 
				throw new ApplicationException("Could not write changes to file."); 
		}
	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The MIT License

Share

About the Author

Davide Icardi
Software Developer
Italy Italy
No Biography provided

| Advertise | Privacy | Mobile
Web04 | 2.8.140905.1 | Last Updated 5 Jan 2004
Article Copyright 2003 by Davide Icardi
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid