Visual C# .NET : 2 adjustments in application
8 posts
• Page 1 of 1
Visual C# .NET : 2 adjustments in application
I downloaded a source code of a C# .NET application, because it was the only thing working I've found.
Fact is, I don't know this language, and I only have to do 2 adjustments in the code, so I'll ask you guys :D Hope someone can help me here
- Code: Select all
public static void Main(string[] args)
{
if (!AuthClass.AuthCheck())
MessageBox.Show("Not an administrator","Need more privileges",MessageBoxButtons.OK,MessageBoxIcon.Stop);
else
MessageBox.Show("Preparing to install\n\n(Nothing will install... Just for demo)","Admin OK",MessageBoxButtons.OK,MessageBoxIcon.Information);
}
instead of
- Code: Select all
MessageBox.Show("Not an administrator","Need more privileges",MessageBoxButtons.OK,MessageBoxIcon.Stop);
there should be nothing. But when I just simply remove it, and type
- Code: Select all
;
And the other adjustment :
instead of
- Code: Select all
MessageBox.Show("Preparing to install\n\n(Nothing will install... Just for demo)","Admin OK",MessageBoxButtons.OK,MessageBoxIcon.Information);
the program should open "c:\documents and settings\all users\application.exe"
Can somebody please help? Thanks in advance
Re: Visual C# .NET : 2 adjustments in application
instead of
- Code: Select all
MessageBox.Show("Not an administrator","Need more privileges",MessageBoxButtons.OK,MessageBoxIcon.Stop);
there should be nothing. But when I just simply remove it, and type
- Code: Select all
;
Well I don't know much about it either but in this one it's trying to show a message box, since I don't know that much about it either I would simply change it to
- Code: Select all
MessageBox.Show(" "," ",MessageBoxButtons.OK,MessageBoxIcon.Stop);
I think you would just get a blank message box then.
I don't know how to make it launch an app. I'm sure someone will be along shortly to help the correct way.
Re: Visual C# .NET : 2 adjustments in application
hmmm, but if I type ";" instead of that messagebox, I don't get an error.
It just says "possible mistaken null statement".
I'll leave it the way it is, I suppose, because the user may dislike it to click on an empty message
But thanks anyway
It just says "possible mistaken null statement".
I'll leave it the way it is, I suppose, because the user may dislike it to click on an empty message
But thanks anyway
Re: Visual C# .NET : 2 adjustments in application
styx wrote:I downloaded a source code of a C# .NET application, because it was the only thing working I've found.
Fact is, I don't know this language, and I only have to do 2 adjustments in the code, so I'll ask you guys :D Hope someone can help me here
- Code: Select all
public static void Main(string[] args)
{
if (!AuthClass.AuthCheck())
MessageBox.Show("Not an administrator","Need more privileges",MessageBoxButtons.OK,MessageBoxIcon.Stop);
else
MessageBox.Show("Preparing to install\n\n(Nothing will install... Just for demo)","Admin OK",MessageBoxButtons.OK,MessageBoxIcon.Information);
}
instead of
- Code: Select all
MessageBox.Show("Not an administrator","Need more privileges",MessageBoxButtons.OK,MessageBoxIcon.Stop);
there should be nothing. But when I just simply remove it, and type" I don't get an error, but the ";" is underlined red. So is this bad? And how would I write it better?
- Code: Select all
;
And the other adjustment :
instead of
- Code: Select all
MessageBox.Show("Preparing to install\n\n(Nothing will install... Just for demo)","Admin OK",MessageBoxButtons.OK,MessageBoxIcon.Information);
the program should open "c:\documents and settings\all users\application.exe"
Can somebody please help? Thanks in advance
So you just want it to show the "Preparing to install..." popup right?
Just change the if statement. You want to display "Preparing to install..." if Authclass.AuthCheck is true, and not have anything happen otherwise. This would look like this:
- Code: Select all
//notice the ! is gone
if (AuthClass.AuthCheck())
{
MessageBox.Show("Preparing to install\n\n(Nothing will install... Just for demo)","Admin OK",MessageBoxButtons.OK,MessageBoxIcon.Information);
}
You were getting the warning because a semi-colon all by itself doesn't really mean anything. It's just what appears at the end of a statement, so you had nothing followed by a semi-colon, which is basically an empty statement.
Hope that helps.
...I'm prepared to passionately argue the point until nothing makes sense anymore! - Red Mage
Re: Visual C# .NET : 2 adjustments in application
So you just want it to show the "Preparing to install..." popup right?
Just change the if statement. You want to display "Preparing to install..." if Authclass.AuthCheck is true, and not have anything happen otherwise. This would look like this:
- Code: Select all
//notice the ! is gone
if (AuthClass.AuthCheck())
{
MessageBox.Show("Preparing to install\n\n(Nothing will install... Just for demo)","Admin OK",MessageBoxButtons.OK,MessageBoxIcon.Information);
}
Actually, no :emberassed:
I want it to launch application.exe instead of showing that message.
Sorry if I didn't explain it that well But thanks for trying !
You were getting the warning because a semi-colon all by itself doesn't really mean anything. It's just what appears at the end of a statement, so you had nothing followed by a semi-colon, which is basically an empty statement.
Hope that helps.
Thanks
Try it without the ;
Be nice to nerds.... chances are you will end up working for one
<u><b>Current system</b></u>
ASUS M3A78-EMH HDMI
AMD Athlon X2 6000+ o/c'd at 3.2GHz
4GB (2x2GB) OCZ RAM
Integrated Radeon HD 3200 (HDMI out)
500GB SATA/360GB IDE HDD's
32" Sharp 1080p Monitor/TV
Vista RTM/Vista SP2 Beta/7 6801
<u><b>Current system</b></u>
ASUS M3A78-EMH HDMI
AMD Athlon X2 6000+ o/c'd at 3.2GHz
4GB (2x2GB) OCZ RAM
Integrated Radeon HD 3200 (HDMI out)
500GB SATA/360GB IDE HDD's
32" Sharp 1080p Monitor/TV
Vista RTM/Vista SP2 Beta/7 6801
- coreyw2000
- PROfessional Member
- Posts: 4644
- Joined: Tue Oct 05, 2004 5:30 am
- Location: Saskatchewan, Canada
Just Replace
with
- Code: Select all
public static void Main(string[] args)
{
if (!AuthClass.AuthCheck())
MessageBox.Show("Not an administrator","Need more privileges",MessageBoxButtons.OK,MessageBoxIcon.Stop);
else
MessageBox.Show("Preparing to install\n\n(Nothing will install... Just for demo)","Admin OK",MessageBoxButtons.OK,MessageBoxIcon.Information);
}
with
- Code: Select all
public static void Main(string[] args)
{
System.Diagnostics.Process.Start(@"c:\documents and settings\all users\application.exe");
}
Computer Guru wrote:already solved via email....
He was more than happy to continue emailing me to explain his problem, but the minute he got a solution he abandons the forums and "forgets" to send a "thank you it worked" back...
whatever.
that's so me, sorry to bump this topic.. I really appreciated it actually!
d*mn that's so me, really!
8 posts
• Page 1 of 1
Return to HTML, CSS, and Scripts
Who is online
Users browsing this forum: No registered users and 3 guests