Important alert: (current site time 7/15/2013 8:17:27 AM EDT)
 

VB icon

A Function To Create Manifest Files At Runtime

Email
Submitted on: 8/31/2002 11:51:26 PM
By: Christopher Hemple  
Level: Intermediate
User Rating: By 6 Users
Compatibility: VB.NET
Views: 47836
author picture
(About the author)
 
     No More Creating Manifest Files. Just Put This Code In Your Project And it Will AutoMaticly Make 1 If There isnt 1 there.
 
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
//**************************************
// for :A Function To Create Manifest Files At Runtime
//**************************************
Copyright Me!
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
 
Terms of Agreement:   
By using this code, you agree to the following terms...   
  1. You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
  2. You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
  3. You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
  4. You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.
				
//**************************************
// Name: A Function To Create Manifest Files At Runtime
// Description:No More Creating Manifest Files. Just Put This Code In Your Project And it Will AutoMaticly Make 1 If There isnt 1 there.
// By: Christopher Hemple
//
// Inputs:None ;o.
//
// Returns:Xp Look!
//
// Assumes:Just Run This Function On Form Load, Thats It :D.
//
// Side Effects:None :P.
//
//This code is copyrighted and has// limited warranties.Please see http://www.Planet-Source-Code.com/vb/scripts/ShowCode.asp?txtCodeId=515&lngWId=10//for details.//**************************************

Function Manifest()
If File.Exists(Application.StartupPath & "\" & Application.ProductName & ".exe.manifest") = True Then
Exit Function
Else
'Generate File Content
Dim Content As String
Dim bl As String = vbCrLf
Content = "<?xml version='1.0' encoding='UTF-8' standalone='yes'?>" & bl
Content &= "<assembly xmlns='urn:schemas-microsoft-com:asm.v1' manifestVersion='1.0'>" & bl
Content &= "<assemblyIdentity" & bl
Content &= "version='1.0.0.0'" & bl
Content &= "processorArchitecture='X86'" & bl
Content &= "name='Microsoft.Winweb."
Content &= Application.ProductName
Content &= ".exe'" & bl
Content &= "type='win32'" & bl
Content &= "/>" & bl
Content &= "<description>"
Content &= Application.ProductName
Content &= "</description>" & bl
Content &= "<dependency>" & bl
Content &= "<dependentAssembly>" & bl
Content &= " <assemblyIdentity" & bl
Content &= "type='win32'" & bl
Content &= "name='Microsoft.Windows.Common-Controls'" & bl
Content &= "version='6.0.0.0'" & bl
Content &= "processorArchitecture='X86'" & bl
Content &= "publicKeyToken='6595b64144ccf1df'" & bl
Content &= "language='*'" & bl
Content &= " />" & bl
Content &= "</dependentAssembly>" & bl
Content &= "</dependency>" & bl
Content &= "</assembly>"
'Create Manifest File
Dim sw As StreamWriter = File.CreateText(Application.StartupPath & "\" & Application.ProductName & ".exe.manifest")
sw.Write(Content)
sw.Close()
'Reload Me
Shell(Application.StartupPath & "\" & Application.ProductName & ".exe", AppWinStyle.NormalFocus, False)
Me.Close()
End If
End Function


Other 2 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Intermediate category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments

8/31/2002 11:52:28 PMChristopher Hemple

Please Comment & Vote , My First Submittion, in the .Net Section :D. :P. :D,Bye,Gone.
(If this comment was disrespectful, please report it.)

 
9/1/2002 11:18:55 AMCarl Mercier

This should be a sub, not a function!
(If this comment was disrespectful, please report it.)

 
9/1/2002 11:20:17 AMCarl Mercier

Also, you should use the StringBuilder object. The code you posted will be very slow/memory hungry since the framework wl create a new String everytime you add a little piece of text to Content.
(If this comment was disrespectful, please report it.)

 
9/1/2002 6:15:26 PM

Yes I agree with Carl you should use
a StringBuilder and you only use
a Function to return something to the
caller but other wise it probaly is
a good idea.
(If this comment was disrespectful, please report it.)

 
12/7/2002 12:52:17 PM

Help, i really suck at coding but i know that you need a manifest file for windows xp to generate nice buttons...

can anyone tell me exactly where in the program code i should put this function???

thanks, Daneel
mail your response to milen@tpg.com.au
(If this comment was disrespectful, please report it.)

 
1/4/2003 3:34:06 PM

Here is a good plaec to get more information on the manifest file

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_vstechar t/html/vbtchUsingWindowsXPVisualStylesWithControlsOnWindowsForms.asp

(If this comment was disrespectful, please report it.)

 
1/5/2003 11:51:22 AMtHe_cLeanER

very cool
(If this comment was disrespectful, please report it.)

 
2/5/2003 12:24:14 PM

I know this was written in August and you may have already figured this out. I looked at the code and thought it was kind of long. I never thought to write the manifest in my program and for that I am very grateful. The only change I made was to simplify the manifest... bummer, I'm not able to upload the changes. Jot me a line if you would like to see it.
(If this comment was disrespectful, please report it.)

 
7/24/2003 1:51:52 AMHom

Nice but you don't have to add the manifest file everytime you load the program. You can add the manifest file to the Application.
Check this out:
http://planetsourcecode.com/vb/scripts/ShowCode.asp?txtCodeId=36377&lngWId=1
(If this comment was disrespectful, please report it.)

 
10/25/2003 4:14:54 PM

If you want "Windows XP" buttons in "Visual Studio .NET 2003" then
you need to create "devenv.exe.manifest" file inside this folder.

C:\Program Files\Microsoft Visual Studio .NET 2003\Common7\IDE





Your application description here.







(If this comment was disrespectful, please report it.)

 
10/25/2003 4:15:11 PM

To add "Windows XP" style to .NET application (MS Framework 1.1+):


1. Open Form source code.
1. Expand region: "#Region "Windows Form Designer generated code "
2. Find Function "Public Sub New()"
3. After comment line "'Add any initialization after the InitializeComponent() call"
Add this line:

System.Windows.Forms.Application.EnableVisualStyles()


(If this comment was disrespectful, please report it.)

 
7/27/2004 5:28:18 AM

Nice stuff , u have in this site ..but i have 1 suggession i.e.
u should also set the link of demo here . It would be more easy to use the controls
(If this comment was disrespectful, please report it.)

 
4/11/2007 8:08:32 AMshankar

very nice, i got more advantage by use of this

(If this comment was disrespectful, please report it.)

 
4/11/2007 8:09:34 AMshankar

very nice
(If this comment was disrespectful, please report it.)

 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.