Jump to content
  • Advertisement
Sign in to follow this  
willthiswork89

HTML IN C#

This topic is 4810 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

i want to make a StreamWriter = new Stream or what ever it is in c#, write my html like.. htmlstream.write("<html>"); htmlstream.write("<body bgcolor='black' text='white'>); htmlstream.write("Yay some html"); then make a browser display this stream? possible setbrowserhtml(htmlstream)??? i have NO IDEA im new to c# ive coded c++ quite a bit, so could sombody please write me a sample or at least guide me the right way?THANKS A BUNCH!

Share this post


Link to post
Share on other sites
Advertisement
You can save the output to an HTML file, and launch the default browser with the file's path like so:
System.Diagnostics.Process.Start("c://path/to/file.html");

Share this post


Link to post
Share on other sites
well im kinda trying to keep my html secret, by not allowing people to see it i want it all in memory. i have somebodys decompiled code which did this, but i cant seem to figure it out if you would like to see that section of code i could show you

Share this post


Link to post
Share on other sites
It can never be secret. The moment it is displayed in the browser, the user can always view the HTML source (View > Page Source), or just save the current page (File > Save Page As...).

Share this post


Link to post
Share on other sites
not if i disable right clicking! lol very simple, since the browser will be showing a java applet, the program will only be big enough to show the java applet so you wont be able to right click around it anyways.

Share this post


Link to post
Share on other sites
javascript, which is what I assume you use to disable right clicking, can be disabled. Not all browsers are Internet Explorer.

My humble advice - focus your energies on the application itself, and not on its theoretical abuses.

Share this post


Link to post
Share on other sites
well i was put off topic, but still you dont understand the importance of keeping it secret, this game could be ruined and possibly the use of my program to play it. very important i keep it secret lol...but regardless heres the code that someone has used

StreamWriter writer1 = new StreamWriter(this.syspath + this.sysconfig, false);
writer1.WriteLine("<html>");
writer1.WriteLine("<head><script type='text/javascript' src='http://www.playbattlefield.com/battle/game/magic.js'></script>");
writer1.WriteLine("<script type='text/javascript'>");
writer1.WriteLine("function setupGame()");
writer1.WriteLine("{");
writer1.WriteLine("var g = document.game;");
writer1.WriteLine("g.setMagicNum(magic('" + this.magicid + "'));");
if (this.playlocal)
{
writer1.WriteLine("g.setSystemTime(" + this.settings.Substring(0, 1) + ");");
writer1.WriteLine("g.setSystemTime2(" + this.settings.Substring(1, 1) + ");");
writer1.WriteLine("g.setSystemTime3(" + this.settings.Substring(2, 1) + ");");
writer1.WriteLine("g.setSystemTime4(" + this.settings.Substring(3, 1) + ");");
writer1.WriteLine("g.setSystemTime5('" + this.thevolu + "');");
writer1.WriteLine("g.setTarget('targetnotset');");
}
writer1.WriteLine("}");
writer1.WriteLine("var jvmWaitCounter = 0;");
writer1.WriteLine("function waitJVM()");
writer1.WriteLine("{");
writer1.WriteLine("if (document.game)");
writer1.WriteLine("{");
writer1.WriteLine("setupGame();");
writer1.WriteLine("}");
writer1.WriteLine("else");
writer1.WriteLine("{");
writer1.WriteLine("if ( jvmWaitCounter++ < 30 )");
writer1.WriteLine("setTimeout('waitJVM()', 300);");
writer1.WriteLine("}");
writer1.WriteLine("}");
writer1.WriteLine("</script></head>");
writer1.WriteLine("<Body bgcolor=607892 onload='waitJVM();'>");
writer1.WriteLine("<script language=javascript>");
writer1.WriteLine(" ");
writer1.WriteLine("</script>");
string[] textArray1 = new string[7] { "
<table cellpadding=0 cellspacing=0 border=0><tr><td background='", this.syspathh.Substring(1), "' height=19 align=center>", this.cboTanks.Text.Substring(this.cboTanks.Text.IndexOf(". ") + 2), "</td><tr><td bgcolor=black><applet id='game' name='game' code='bfieldClub.class' ", text2, " width='590' height='320'>" } ;
writer1.WriteLine(string.Concat(textArray1));
writer1.WriteLine("<param name='host_port' value='http://www.playbattlefield.com'>");
writer1.WriteLine("<param name='host' value='www.playbattlefield.com'>");
writer1.WriteLine("<param name='gameX' value='590'>");
writer1.WriteLine("<param name='gameY' value='350'>");
writer1.WriteLine("<param name='port' value='53719'>");
writer1.WriteLine("<param name='userid' value='" + text1 + "'>");
writer1.WriteLine("<param name='xmagic' value='1'>");
writer1.WriteLine("<param name='version' value='1'>");
writer1.WriteLine("<param name='skin_idx' value='sk" + num1 + "'>");
writer1.WriteLine("<param name='getpagetime' value='31'>");
writer1.WriteLine("<param name='getpageurl' value='/battle/user/activeTank.do'>");
writer1.WriteLine("</applet></td><tr><td background='" + this.syspatht.Substring(1) + "' height=17></td></table>
");
writer1.WriteLine("</Body>");
writer1.WriteLine("</html>");
writer1.Close();
if (this.cboTanks.Text.IndexOf("Guest Tank") != -1)
{
Thread.Sleep(500);
this.staStatusText.Text = "Playing...";
this.GoTo(this.syspath + this.sysconfig);
this.panelMain.Visible = false;
this.button2.Visible = true;
this.staStatusTank.Text = "Tank: " + this.cboTanks.Text.Substring(this.cboTanks.Text.IndexOf(". ") + 2);
}
else
{
this.GoTo("http://www.playbattlefield.com/battle/user/selectTank.do?name=" + this.cboTanks.Text.Substring(this.cboTanks.Text.IndexOf(". ") + 2));
}
}
}

as you can see. the stream was written to then closed, and somewhere else which i have not found. it uses it.

Share this post


Link to post
Share on other sites
well hmm....i dont know where its saving it to! lol i may have to wait to ask him but possibly with the help of you guys i can figure it out? i dont need a huge protection, most of the people that pklay this are 12, but there are some smart ones, so i need some minor protections or at least it would take alot of computer knowledge to know how to get the html source code.

Share this post


Link to post
Share on other sites
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace RF.Demo
{
public class MainForm : System.Windows.Forms.Form
{
private AxSHDocVw.AxWebBrowser axWebBrowser1;

private System.ComponentModel.Container components = null;

public MainForm()
{
InitializeComponent();
}

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()
{
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(MainForm));
this.axWebBrowser1 = new AxSHDocVw.AxWebBrowser();
((System.ComponentModel.ISupportInitialize)(this.axWebBrowser1)).BeginInit();
this.SuspendLayout();
//
// axWebBrowser1
//
this.axWebBrowser1.Anchor = ((System.Windows.Forms.Anchorstyles)((((System.Windows.Forms.Anchorstyles.Top | System.Windows.Forms.Anchorstyles.Bottom)
| System.Windows.Forms.Anchorstyles.Left)
| System.Windows.Forms.Anchorstyles.Right)));
this.axWebBrowser1.Enabled = true;
this.axWebBrowser1.Location = new System.Drawing.Point(8, 40);
this.axWebBrowser1.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("axWebBrowser1.OcxState")));
this.axWebBrowser1.Size = new System.Drawing.Size(590, 320);
this.axWebBrowser1.TabIndex = 0;
this.axWebBrowser1.Enter += new System.EventHandler(this.axWebBrowser1_Enter);
//
// MainForm
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(592, 366);
this.Controls.Add(this.axWebBrowser1);
this.Name = "MainForm";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Web Browser Demo";
this.Load += new System.EventHandler(this.MainForm_Load);
((System.ComponentModel.ISupportInitialize)(this.axWebBrowser1)).EndInit();
this.ResumeLayout(false);

}
#endregion

[STAThread]
static void Main()
{
Application.Run(new MainForm());
}

private void MainForm_Load(object sender, System.EventArgs e)
{
object empty = System.Reflection.Missing.Value;
axWebBrowser1.Navigate("about:blank", ref empty, ref empty, ref empty, ref empty);

setBrowserHtml("<html><body bgcolor='black' text='red'>This will parse!");
}

private void setBrowserHtml(string html)
{
// create an IHTMLDocument2
mshtml.IHTMLDocument2 doc = axWebBrowser1.Document as mshtml.IHTMLDocument2;

// write to the doc
doc.clear();
doc.writeln(html);

doc.close();
}



private void axWebBrowser1_Enter(object sender, System.EventArgs e)
{

}
}
}


here is one that will parse html, but for somereason when trying to do the applet it fails to initialize lol...i dunno

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!