CECGen…


It looks like some people are struggling to get their applications integrated into Platform Builder.


In my previous posting I mentioned that you could modify the source for CEWSDLGen (shipped with PB) to create a very simple C# application to create the .CEC file for hosting an application in the PB catalog.


I had a couple of spare minutes, so I hacked CEWSDLGen to get the following…


 


using System;


using System.IO;


using System.Drawing;


using System.Collections;


using System.ComponentModel;


using System.Windows.Forms;


using System.Data;


using System.Diagnostics;


using Microsoft.Win32;


//


// Copyright (c) Microsoft Corporation. All rights reserved.


// CEWSDLGen V1.1 Mike Hall (EAPG) – mikehall 11/2/2002


// v1.2 – (CEC) Added support for XML Web Service components. 11/11/02


namespace CEWsdlGen


{


/// <summary>


/// Summary description for Form1.


/// </summary>


public class Form1 : System.Windows.Forms.Form


{


private System.Windows.Forms.Button OpenProject;


private System.Windows.Forms.OpenFileDialog openFileDialog1;


private System.ComponentModel.IContainer components;


private string strWorkingFolder;


private string strBaseName;


private string strOSDir;


private string strVCP;


private string strTypelib;


private System.Windows.Forms.GroupBox groupBox1;


private System.Windows.Forms.Label label9;


private string strVersion;


private System.Windows.Forms.TextBox rgsFileName;


private System.Windows.Forms.Button BuildCEC;


private bool fPrjInited;


public string strPreFixNamestrFile;


public string strFile;


public Form1()


{


//


// Required for Windows Form Designer support


//


InitializeComponent();


//


// TODO: Add any constructor code after InitializeComponent call


//


fPrjInited = false;


}


/// <summary>


/// Clean up any resources being used.


/// </summary>


protected override void Dispose( bool disposing )


{


if( disposing )


{


if (components != null)


{


components.Dispose();


}


}


base.Dispose( disposing );


}


#region Windows Form Designer generated code


/// <summary>


/// Required method for Designer support – do not modify


/// the contents of this method with the code editor.


/// </summary>


private void InitializeComponent()


{


this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog();


this.OpenProject = new System.Windows.Forms.Button();


this.groupBox1 = new System.Windows.Forms.GroupBox();


this.label9 = new System.Windows.Forms.Label();


this.rgsFileName = new System.Windows.Forms.TextBox();


this.BuildCEC = new System.Windows.Forms.Button();


this.groupBox1.SuspendLayout();


this.SuspendLayout();


//


// openFileDialog1


//


this.openFileDialog1.Filter = “All Files|*.*”;


this.openFileDialog1.Title = “File for CEC”;


//


// OpenProject


//


this.OpenProject.Location = new System.Drawing.Point(16, 24);


this.OpenProject.Name = “OpenProject”;


this.OpenProject.Size = new System.Drawing.Size(432, 24);


this.OpenProject.TabIndex = 0;


this.OpenProject.Text = “Select…”;


this.OpenProject.Click += new System.EventHandler(this.OpenProject_Click);


//


// groupBox1


//


this.groupBox1.Controls.Add(this.OpenProject);


this.groupBox1.Controls.Add(this.label9);


this.groupBox1.Location = new System.Drawing.Point(8, 8);


this.groupBox1.Name = “groupBox1”;


this.groupBox1.Size = new System.Drawing.Size(456, 104);


this.groupBox1.TabIndex = 20;


this.groupBox1.TabStop = false;


this.groupBox1.Text = “Select File…”;


//


// label9


//


this.label9.Location = new System.Drawing.Point(24, 72);


this.label9.Name = “label9”;


this.label9.Size = new System.Drawing.Size(96, 16);


this.label9.TabIndex = 21;


this.label9.Text = “File Name”;


//


// rgsFileName


//


this.rgsFileName.Location = new System.Drawing.Point(152, 72);


this.rgsFileName.Name = “rgsFileName”;


this.rgsFileName.Size = new System.Drawing.Size(304, 20);


this.rgsFileName.TabIndex = 1;


this.rgsFileName.Text = “”;


//


// BuildCEC


//


this.BuildCEC.Location = new System.Drawing.Point(8, 120);


this.BuildCEC.Name = “BuildCEC”;


this.BuildCEC.Size = new System.Drawing.Size(456, 32);


this.BuildCEC.TabIndex = 21;


this.BuildCEC.Text = “Generate CEC”;


this.BuildCEC.Click += new System.EventHandler(this.BuildCEC_Click);


//


// Form1


//


this.AutoScale = false;


this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);


this.ClientSize = new System.Drawing.Size(470, 180);


this.Controls.Add(this.BuildCEC);


this.Controls.Add(this.rgsFileName);


this.Controls.Add(this.groupBox1);


this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D;


this.MaximizeBox = false;


this.Name = “Form1”;


this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;


this.Text = “CECGen”;


this.Load += new System.EventHandler(this.Form1_Load);


this.groupBox1.ResumeLayout(false);


this.ResumeLayout(false);


}


#endregion


/// <summary>


/// The main entry point for the application.


/// </summary>


[STAThread]


static void Main()


{


Application.Run(new Form1());


}


private void OpenProject_Click(object sender, System.EventArgs e)


{


if (openFileDialog1.ShowDialog() == DialogResult.OK)


{


rgsFileName.Text=openFileDialog1.FileName;


strWorkingFolder=openFileDialog1.FileName;


int iSlashLocation=strWorkingFolder.LastIndexOf(“\\”);


strFile=strWorkingFolder.Substring(iSlashLocation+1,strWorkingFolder.Length-(iSlashLocation+1));


int iDotLocation=strFile.LastIndexOf(“.”);


strPreFixNamestrFile=strFile.Substring(0,iDotLocation );


strWorkingFolder=strWorkingFolder.Substring(0,iSlashLocation+1);


fPrjInited = true;


}


}


private void Form1_Load(object sender, System.EventArgs e)


{


Menu = new MainMenu(new MenuItem[] { new MenuItem(“&About!”,new EventHandler(MenuAboutOnClick)) });


}


public void MenuAboutOnClick(object obj, EventArgs ea )


{


MessageBox.Show(“CECGen v0.1\nCopyright (C) 2004 Microsoft Corporation\n”,”CECGen”);


}


private void GenerateCEC( )


{


// strWorkingFolder == C:\folder\


// strFile == myFile.exe


// strPreFixNamestrFile = MyFile


string CECFileName=strWorkingFolder+strPreFixNamestrFile+”.cec”;


File.Delete(CECFileName);


Console.WriteLine(“Generate_CEC_File\n”);


StreamWriter sWrite=new StreamWriter( CECFileName );


sWrite.WriteLine(“CECInfo (“);


sWrite.WriteLine(” Name(“+strPreFixNamestrFile+”)”);


sWrite.WriteLine(” CECVersion(4.20)”);


sWrite.WriteLine(” GUID( {“+Guid.NewGuid().ToString( )+”} )” );


sWrite.WriteLine(” Vendor( \”Microsoft\” )”);


sWrite.WriteLine(” Description( \””+strPreFixNamestrFile+” CECGen Component\” )”);


sWrite.WriteLine(“)”);


sWrite.WriteLine(“”);


sWrite.WriteLine(“ComponentType”);


sWrite.WriteLine(“(“);


sWrite.WriteLine(” Name( \””+strPreFixNamestrFile+” CECGen Component\” )”);


sWrite.WriteLine(” GUID( {“+Guid.NewGuid().ToString( )+”} )” );


sWrite.WriteLine(” Description( \””+strPreFixNamestrFile+” CECGen Component\” )”);


sWrite.WriteLine(” Group( \”\\CECGen\” )”);


sWrite.WriteLine(” Vendor( \”Microsoft\” )”);


sWrite.WriteLine(” MaxResolvedImpsAllowed( 1 )”);


sWrite.WriteLine(” Implementations”);


sWrite.WriteLine(” (“);


sWrite.WriteLine(” Implementation”);


sWrite.WriteLine(” (“);


sWrite.WriteLine(” Name( \””+strPreFixNamestrFile+” CECGen Component\” )”);


sWrite.WriteLine(” GUID( {“+Guid.NewGuid().ToString( )+”} )” );


sWrite.WriteLine(” Version ( \”4.2.0.0\” )”);


sWrite.WriteLine(” Locale ( 0409 )”);


sWrite.WriteLine(” Vendor( \”Microsoft\” )”);


sWrite.WriteLine(” Date( \””+DateTime.Now.ToString( )+”\” )”);


sWrite.WriteLine(” SizeIsCPUDependent( 0 )”);


sWrite.WriteLine(” BuildMethods”);


sWrite.WriteLine(” (“);


sWrite.WriteLine(” BuildMethod”);


sWrite.WriteLine(” (“);


sWrite.WriteLine(” GUID( {“+Guid.NewGuid().ToString( )+”} )” );


sWrite.WriteLine(” Step( PreMakeImg )”);


sWrite.WriteLine(” CoreOS ( \”HLBASE\” )”);


sWrite.WriteLine(” CoreOS ( \”IABASE\” )”);


sWrite.WriteLine(” CPU( \”DEFAULT\” )”);


sWrite.WriteLine(” Action ( ‘#COPY(\””+strWorkingFolder+strFile+”\”, \”$(_FLATRELEASEDIR)\”)’ )”);


sWrite.WriteLine(” )”);


sWrite.WriteLine(” )”);


sWrite.WriteLine(” BibInfo”);


sWrite.WriteLine(” (“);


sWrite.WriteLine(” Files”);


sWrite.WriteLine(” (“);


sWrite.WriteLine(” File”);


sWrite.WriteLine(” (“);


sWrite.WriteLine(” GUID( {“+Guid.NewGuid().ToString( )+”} )” );


sWrite.WriteLine(” CPU( \”DEFAULT\” )”);


sWrite.WriteLine(” BibRecord( ‘#MODULES( \””+strFile+”\”, \”$(_FLATRELEASEDIR)\\”+strFile+”\”, \”NK\” , \”S\” )’ )”);


sWrite.WriteLine(” )”);


sWrite.WriteLine(” )”);


sWrite.WriteLine(” )”);


sWrite.WriteLine(” )”);


sWrite.WriteLine(” )”);


sWrite.WriteLine(“)”);


sWrite.Close( );


}


private void BuildCEC_Click(object sender, System.EventArgs e)


{


if (fPrjInited == false)


{


MessageBox.Show(“Select a File!”,”CECGen”);


}


else


{


GenerateCEC( );


MessageBox.Show(“CECGen Completed”);


}


}


}


}


Simply create a new C# project in Visual Studio .NET 2003, call this “CECGen” or similar, delete all the contents of the .cs file – and drop the code above into the empty .cs file. Build, and run…


This application generates a .CEC file which copies your application to the _FLATRELEASEDIR, and then includes a BIB record to make sure your application appears in the final O/S image.


Enjoy…


– Mike


Comments (0)