View Full Version : I have my app now what???
AlphaAddict
10-31-2005, 07:29 PM
Thanks to his help ive managed to produce these two aps .
http://tinypic.com/f4px0w.jpg http://tinypic.com/f4pxxf.jpg
Thr problem is its all very well at the mo butr i actuly want these to do something .
So ive constructed a third app to try to figure it out and for the crack : )
http://tinypic.com/f4qiiw.jpg
So ill be grand if i can figure out how to
1) Learn how to use the button to set this registry value
2) Learn how to use the button to run a command eg c:/windows/.. avalon.exe startdwmcomposition
3) Learn how to use the button to kill and restart explorer.exe
thats as advanced as ill need to go apart from the trakbar above : ( it has to set a different value in a reg key for each position
Can anyone tell me how to do the above but please no leet talk i need to know where to add the code (newbie ).
The source code is here
/*
* Created by SharpDevelop.
* User: AlphaAddict
* Date: 30/10/2005
* Time: 21:51
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;
using System.Drawing;
using System.Windows.Forms;
namespace _
{
/// <summary>
/// Description of MainForm.
/// </summary>
public class MainForm : System.Windows.Forms.Form
{
private System.Windows.Forms.Button button1;
public MainForm()
{
//
// The InitializeComponent() call is required for Windows Forms designer support.
//
InitializeComponent();
//
// TODO: Add constructor code after the InitializeComponent() call.
//
}
[STAThread]
public static void Main(string[] args)
{
Application.Run(new MainForm());
}
#region Windows Forms Designer generated code
/// <summary>
/// This method is required for Windows Forms designer support.
/// Do not change the method contents inside the source code editor. The Forms designer might
/// not be able to load this method if it was changed manually.
/// </summary>
private void InitializeComponent() {
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(MainForm));
this.button1 = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// button1
//
this.button1.DialogResult = System.Windows.Forms.DialogResult.OK;
this.button1.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.button1.Font = new System.Drawing.Font("Tahoma", 36F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.button1.Location = new System.Drawing.Point(0, 0);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(496, 231);
this.button1.TabIndex = 0;
this.button1.Text = "!!! Enable Avalon !!!";
this.button1.Click += new System.EventHandler(this.Button1Click);
//
// MainForm
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 14);
this.ClientSize = new System.Drawing.Size(496, 232);
this.Controls.Add(this.button1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MaximizeBox = false;
this.MaximumSize = new System.Drawing.Size(502, 256);
this.MinimumSize = new System.Drawing.Size(502, 256);
this.Name = "MainForm";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "AlphaAddict\'s Avalon Tool";
this.Click += new System.EventHandler(this.Button1Click);
this.ResumeLayout(false);
}
#endregion
void Form1(object sender, System.EventArgs e)
{
}
void Button1Click(object sender, System.EventArgs e)
{
}
}
}
LOL
You need to learn basic controls and message handling long before you should be messing with anyone's registry..
Google "Hello World" :)
AlphaAddict
11-01-2005, 01:23 PM
can you show the code to make it run a comand and run a reg key ?
if i can manage this i should be able to get any app running
I'm going to save you alot of grief and NOT tell you how to run registry commands. Your friends will hate you when you get them to try you program and it screws up their registry and they have to reinstall Windows. Registry manipulation is not for beginner programmers.
You need to start of smaller. Learn from tutorials and pre-written code you find on the net. Start with the basics, learn about Windows message handling. and basic language concepts. It's probably best to start off with console programming, then move into GUI programming. I know these RAD tools like SharpDevelop make it seem like you can do something, but all they do automate a basic framework. You need to learn how the framework works so you can build on top of it.
Also, learning to run commands does not mean you can get any app running. There's at least a one year learning curve before you can understand enough to do something useful... or at least do something that isn't dangerous to your computer's health.
AlphaAddict
11-02-2005, 08:32 PM
Well to be fair i know exactly what im doing in the registry theres no chance of me fecking up someones pc.The reason why i want to modify reg keys is because in longhorn there aer reams of "hidden" fetures such as 3d wallpaper , Avalon , Super Prefetch (1/2s ram usage)
And reams of others if i can learn how to create these keys with an app i will be able to just switch the reg key and create a new app to enable another hidden feture in seconds.
So can you explain how to make the button create this reg key
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer]
"MILDesktop"=dword:00000001
which will allow me to create the final version of my avalon controls (they all use reg keys)
i know im a total newbie with programing but im an expert with Alpha operating systems hell my name is AlphaAddict :thumbsup:
thanks in advance
I hope people don't hit me for feeding you code...
Anyway, this is a function I made to add a value to the "run" registry key (so program runs at startup)
void regkeyrun(const char *location)
{
HKEY hkey;
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", 0,
KEY_ALL_ACCESS, &hkey) != ERROR_SUCCESS) {
MessageBox(NULL, "error: \"run\" registry key could not be opened. author to lazy to implement \
RegCreateKeyEx. program will not work :-(", appname, MB_OK|MB_ICONERROR);
return;
}
if (RegSetValueEx(hkey, REG_KEY, 0, REG_SZ, (const BYTE *)location, strlen(location) + 1) != ERROR_SUCCESS) {
MessageBox(NULL, "error setting registry value. program will not work :-(", appname, MB_OK|MB_ICONERROR);
return;
}
RegFlushKey(hkey); /* make absolute sure it's added */
}
Well I must go now. Maybe that snippet might help you a bit...:p
AlphaAddict
11-04-2005, 09:52 PM
thanks but how would i get the button to apply that reg key ?
thanks but how would i get the button to apply that reg key ?
:eek:
You just proved my point.
You already posted the code that gets called when the button gets clicked.
thanks but how would i get the button to apply that reg key ?
Look for this in the code:
void Button1Click(object sender, System.EventArgs e)
{
}
Now any code you put between those brackets {} should be run when the button is clicked. Think on that for a while.:p
Edit: as an exercise in you learning to code, try putting this function between the brackets.
MessageBox(NULL, "Button pressed!", "Happy Message Box", MB_OK);
:D
oracleguy
11-04-2005, 11:33 PM
Edit: as an exercise in you learning to code, try putting this function between the brackets.
MessageBox(NULL, "Button pressed!", "Happy Message Box", MB_OK);
Actually, you gotta call the Show method on the MessageBox object.
MessageBox.Show(this, "Button Pressed!", "Happy Message Box");
AlphaAddict
11-06-2005, 02:03 PM
Allright im starting to get this so from another forum
i got this
Set a value in the registry:
using Microsoft.Win32;
...
RegistryKey k = Registry.LocalMachine.OpenSubKey(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer", true);
k.SetValue("LIMExplorer", 1 /* or 0 */);
Kill explorer:
using System.Diagnostics;
foreach (Process p in Process.GetProcessesByName("explorer.exe")) {
p.Kill();
}
If explorer doesn't restart automatically after that:
Process.Start("explorer.exe");
how would i go about implimenting this into that button? seems i just have to insert it in the
{
}
right?
First of all: you're using some framework I have never used so I may be wrong about whatever I say.
seems i just have to insert it in the
{
}
right?
Yes. This seems to be the code for setting the registry value:
RegistryKey k = Registry.LocalMachine.OpenSubKey(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer", true);
k.SetValue("LIMExplorer", 1 /* or 0 */);
So put that between those brackets and see what happens. You might also want to put that messagebox code oracleguy posted to show that the button has actually been clicked, just for testing.
Edit:
Note that the code
k.SetValue("LIMExplorer", 1);
Sets the key "LIMExplorer" to 1, you wanted "MILDesktop"=dword:00000001
so that would be
k.SetValue("MILDesktop", 00000001);
... I think. :p
AlphaAddict
11-07-2005, 11:00 AM
i got an error with the one in the codebox last night :mad:
any ideas?
i got an error with the one in the codebox last night :mad:
You need to be specific! Which "one" (there are several code boxes, quote it if necessary). What error? Divide By Cucumber Error?:(
AlphaAddict
11-07-2005, 06:08 PM
allright im going to insert that tonight
is this right
button1 function.....
{
RegistryKey k = Registry.LocalMachine.OpenSubKey(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer", true);
k.SetValue("MILDesktop", 00000001);
}
sage45
11-07-2005, 06:42 PM
sker ipt ki dee...
AlphaAddict
11-08-2005, 10:01 AM
https://www.godaddy.com/gdshop/default.asp?isc=gppg1601&domain=www.longhornforums.com
I get these errors when compiling
http://tinypic.com/ff0kyt.jpg
Using this code
/*
* Created by SharpDevelop.
* User: AlphaAddict
* Date: 30/10/2005
* Time: 21:51
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;
using System.Drawing;
using System.Windows.Forms;
namespace _
{
/// <summary>
/// Description of MainForm.
/// </summary>
public class MainForm : System.Windows.Forms.Form
{
private System.Windows.Forms.Button button1;
public MainForm()
{
//
// The InitializeComponent() call is required for Windows Forms designer support.
//
InitializeComponent();
//
// TODO: Add constructor code after the InitializeComponent() call.
//
}
[STAThread]
public static void Main(string[] args)
{
Application.Run(new MainForm());
}
#region Windows Forms Designer generated code
/// <summary>
/// This method is required for Windows Forms designer support.
/// Do not change the method contents inside the source code editor. The Forms designer might
/// not be able to load this method if it was changed manually.
/// </summary>
private void InitializeComponent() {
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(MainForm));
this.button1 = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// button1
//
this.button1.DialogResult = System.Windows.Forms.DialogResult.OK;
this.button1.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.button1.Font = new System.Drawing.Font("Tahoma", 36F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.button1.Location = new System.Drawing.Point(0, 0);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(496, 231);
this.button1.TabIndex = 0;
this.button1.Text = "!!! Enable Avalon !!!";
this.button1.Click += new System.EventHandler(this.Button1Click);
//
// MainForm
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(496, 232);
this.Controls.Add(this.button1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MaximizeBox = false;
this.MaximumSize = new System.Drawing.Size(502, 256);
this.MinimumSize = new System.Drawing.Size(502, 256);
this.Name = "MainForm";
this.Opacity = 0.7;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = " AlphaAddict\'s Avalon Tool" +
"";
this.Click += new System.EventHandler(this.Button1Click);
this.ResumeLayout(false);
}
#endregion
void Form1(object sender, System.EventArgs e)
{
}
void Button1Click(object sender, System.EventArgs e)
{
RegistryKey k = Registry.LocalMachine.OpenSubKey(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer", true);
k.SetValue("MILDesktop", 00000001);
}
void ControlArray1TabStopChanged(object sender, System.EventArgs e)
{
}
}
}
Any Ideas ?
finaly how would i get it to run
C:\WINDOWS\I386\sbctl.exe start
as if it were entered in start > run
See in your code the lines that say "using system" etc, well after that try putting
using System.Security.Permissions;
using Microsoft.Win32;
(from here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfMicrosoftWin32RegistryKeyClassTopic.asp)
The Microsoft.Win32 class contains the registry functions, so you have to tell the compiler you are "using" it... Something like that anyhow.
Edit: You really should try googling you know
http://www.google.co.uk/search?hl=en&q=c%23+set+registry+values&meta=
gives this very helpful article
http://www.csharphelp.com/archives2/archive430.html
AlphaAddict
11-08-2005, 02:28 PM
Thanks ive saved them ill try it out tonight
What about the command above
how would i run that from a button
finaly how would i get it to run
C:\WINDOWS\I386\sbctl.exe start
as if it were entered in start > run
read everything on this page --> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemDiagnosticsProcessClassTopic.asp
:p
In short,
using System.Diagnostics;
(with the other "using"s)
Process.Start("C:\WINDOWS\I386\sbctl.exe");
...as the button code.
AlphaAddict
11-08-2005, 06:54 PM
great both saved :thumbsup:
and im assuming i just replace pstart with p kill to kill a proccess?
assuming i just replace pstart with p kill to kill a proccess?
Not that simple methinks.
I quick gooooooooogle (http://www.google.co.uk/search?hl=en&q=c%23+kill+process&btnG=Google+Search&meta=) later gives me this:
To kill a process by process name:
Process[] myProcesses;
myProcesses = Process.GetProcessesByName("Notepad");
myProcesses[0].Kill();
To kill a process by MainWindowsTitle name:
Process[] myProcesses;
myProcesses = Process.GetProcesses();
foreach(Process p in myProcesses)
{
string Name = p.MainWindowTitle.ToLower();
if(Name.IndexOf("title") != -1)
p.Kill();
}
You should try google, all the code you need is out there.
AlphaAddict
11-09-2005, 10:07 AM
The good news is thanks to dans help i now have a functional app well sort of.....
I get errors in the compier and application itself
When Running A Command :
Works like clockwork with iexplorer.exe but when i try run Process.Start("C:\WINDOWS\I386\sbctl.exe");
The code you posted dident support the start and stop elaments which are needed can i just add them in at the end
using
using System;
using System.Drawing;
using System.Windows.Forms;
using System.Security.Permissions;
using System.Diagnostics;
using Microsoft.Win32;
Compiler Error
http://tinypic.com/fjhy0n.jpg
When Changing A Reg Value
Which works like clockwork in the compiler but when i try to use it by clicking the button
Error
http://tinypic.com/fjhxzk.jpg
Error Code
See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.
************** Exception Text **************
System.NullReferenceException: Object reference not set to an instance of an object.
at Avalon_Controls_V_13.MainForm.Button4Click(Object sender, EventArgs e) in c:\Documents and Settings\Windows User\Desktop\Source Code\Avalon Controls V 1.3\MainForm.cs:line 605
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
************** Loaded Assemblies **************
mscorlib
Assembly Version: 1.2.3300.0
Win32 Version: 1.2.2125.7
CodeBase: file:///c:/windows/microsoft.net/framework/v1.2.2125/mscorlib.dll
----------------------------------------
Avalon Controls V 1.3
Assembly Version: 1.0.2138.40145
Win32 Version: 1.0.2138.40145
CodeBase: file:///C:/Documents%20and%20Settings/Windows%20User/Desktop/Source%20Code/Avalon%20Controls%20V%201.3/bin/Debug/Avalon%20Controls%20V%201.3.exe
----------------------------------------
System.Windows.Forms
Assembly Version: 1.2.3300.0
Win32 Version: 1.2.2125.7
CodeBase: file:///c:/windows/assembly/gac/system.windows.forms/1.2.3300.0__b77a5c561934e089/system.windows.forms.dll
----------------------------------------
System
Assembly Version: 1.2.3300.0
Win32 Version: 1.2.2125.7
CodeBase: file:///c:/windows/assembly/gac/system/1.2.3300.0__b77a5c561934e089/system.dll
----------------------------------------
System.Drawing
Assembly Version: 1.2.3300.0
Win32 Version: 1.2.2125.7
CodeBase: file:///c:/windows/assembly/gac/system.drawing/1.2.3300.0__b03f5f7f11d50a3a/system.drawing.dll
----------------------------------------
************** JIT Debugging **************
To enable just in time (JIT) debugging, the config file for this
application or machine (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.
For example:
<configuration>
<system.windows.forms jitDebugging="true" />
</configuration>
When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the machine
rather than being handled by this dialog.
When Killing Explorer.exe
The app just stalls for a second when i run click the restart explorer button the explorer.exe process remains untouched
Button Code
void Button7Click(object sender, System.EventArgs e)
{
foreach (Process p in Process.GetProcessesByName("explorer.exe")) {
p.Kill();
}
}
Thats all thats stopping me from relesing the final versions of my apps but iive created a hyperlink to my Longhorn Gallery in the picture box and using the method before added a onclick event to it whats the code to get it to open a webpage ?
At the mo im using ie to open it but not everyone uses ie how do i get it to open with the systems defalt beowser
Link Code
void pictureBox1Click(object sender, System.EventArgs e)
{
Process.Start("IExplore.exe", "www.AlphaAddictsLonghornStuff.Dl.Am");
}
The backslashes should be escaped, I forgot:
Process.Start("C:\\WINDOWS\\I386\\sbctl.exe start");
Default browser, i'm not sure, but have you tried just
Process.Start("http://www.alphaaddictslonghornstuff.dl.am");
To kill explorer try
Process[] myProcesses;
myProcesses = Process.GetProcessesByName("explorer");
myProcesses[0].Kill();
But i'm not sure if windows will let you kill explorer?
AlphaAddict
11-09-2005, 06:58 PM
what about the reg key errors
Well the message says the problem is with the "Button4Click" function, so you could post that (edit: or even have a look at it yourself...). Although I have no experience with c# so I am not the best person to be helping you.:p
Hey, just a wild guess, but have you looked at MainForm.cs:line 605 for an Object reference not set to an instance of an object? :)
AlphaAddict
11-11-2005, 10:07 AM
This is the code
using System;
using System.Drawing;
using System.Windows.Forms;
using System.Security.Permissions;
using Microsoft.Win32;
namespace _
{
/// <summary>
/// Description of MainForm.
/// </summary>
public class MainForm : System.Windows.Forms.Form
{
private System.Windows.Forms.Button button1;
public MainForm()
{
//
// The InitializeComponent() call is required for Windows Forms designer support.
//
InitializeComponent();
//
// TODO: Add constructor code after the InitializeComponent() call.
//
}
[STAThread]
public static void Main(string[] args)
{
Application.Run(new MainForm());
}
#region Windows Forms Designer generated code
/// <summary>
/// This method is required for Windows Forms designer support.
/// Do not change the method contents inside the source code editor. The Forms designer might
/// not be able to load this method if it was changed manually.
/// </summary>
private void InitializeComponent() {
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(MainForm));
this.button1 = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// button1
//
this.button1.DialogResult = System.Windows.Forms.DialogResult.Ignore;
this.button1.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.button1.Font = new System.Drawing.Font("Tahoma", 36F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.button1.Location = new System.Drawing.Point(0, 0);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(496, 231);
this.button1.TabIndex = 0;
this.button1.Text = "!!! Enable Avalon !!!";
this.button1.Click += new System.EventHandler(this.Button1Click);
//
// MainForm
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 14);
this.ClientSize = new System.Drawing.Size(496, 232);
this.Controls.Add(this.button1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MaximizeBox = false;
this.MaximumSize = new System.Drawing.Size(502, 262);
this.MinimumSize = new System.Drawing.Size(502, 262);
this.Name = "MainForm";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "AlphaAddict\'s Avalon Tool";
this.Click += new System.EventHandler(this.Button1Click);
this.ResumeLayout(false);
}
#endregion
void Form1(object sender, System.EventArgs e)
{
}
void Button1Click(object sender, System.EventArgs e)
{
RegistryKey X = Registry.LocalMachine;
X = X.OpenSubKey(@".HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\",true);
X.SetValue("StartupOptions",00000001);
}
}
}
and this is the line it keeps naging about in any app not just this one
X.SetValue("StartupOptions",00000001);
ive tried X.SetValue("StartupOptions",1); but it still wont work
I don't think your copy and paste skills are quite up to scratch! :(
RegistryKey k = Registry.LocalMachine.OpenSubKey("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer", true);
k.SetValue("StartupOptions", 1);
If that doesn't work I don't know what will.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfmicrosoftwin32registrykeyclasstopic.asp
AlphaAddict
11-14-2005, 02:21 PM
Thanks for the help everyone it works :thumbsup: check out the story Here (http://www.flexbeta.net/)
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.