|
|
|
styx
|
Posted:
Thu Feb 23, 2006 5:34 pm |
|
|
|
PRO Level 5
Joined: 18 Feb 2005
Posts: 188
Location: belgium
|
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: |
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: |
| 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?
And the other adjustment :
instead of
| Code: |
| 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 
|
|
|
|
|
|
|
|
Back to top
|
|
|
|
_Taz_
Bobby Creech |
Posted:
Thu Feb 23, 2006 6:01 pm |
|
|
|
Moderator Support Team
Joined: 29 Jun 2004
Posts: 1217
Location: Florida
|
instead of
| Code: |
| 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?[/quote]
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: |
| 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.
|
|
|
|
|
|
|
|
Back to top
|
|
|
|
styx
|
Posted:
Thu Feb 23, 2006 6:03 pm |
|
|
|
PRO Level 5
Joined: 18 Feb 2005
Posts: 188
Location: belgium
|
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
|
|
|
|
|
|
|
|
Back to top
|
|
|
|
Telos
|
Posted:
Thu Feb 23, 2006 7:33 pm |
|
|
|
PRO Level 6
Joined: 12 Jul 2005
Posts: 238
Location: Tonawanda, NY
|
| 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: |
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: |
| 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?
And the other adjustment :
instead of
| Code: |
| 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: |
//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.
|
|
|
|
|
|
|
|
Back to top
|
|
|
|
styx
|
Posted:
Fri Feb 24, 2006 3:37 pm |
|
|
|
PRO Level 5
Joined: 18 Feb 2005
Posts: 188
Location: belgium
|
| Quote: |
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: |
//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 !
| Quote: |
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 
|
|
|
|
|
|
|
|
Back to top
|
|
|
|
Computer Guru
|
Posted:
Fri Feb 24, 2006 4:48 pm |
|
|
|
Disabled User
Joined: 06 Jul 2004
Posts: 9604
Location: Far Far Away
|
well, you are missing hte rest ofhte code.
This code only displays the approproate message boxes...
email me the full code (neosmart@gmail.com) {@mods: advanced spam filters, and too late to get me off the spam lists anyway  }
|
|
|
|
|
|
|
|
Back to top
|
|
|
|
Computer Guru
|
Posted:
Fri Feb 24, 2006 5:03 pm |
|
|
|
Disabled User
Joined: 06 Jul 2004
Posts: 9604
Location: Far Far Away
|
Got your email..
See, that is only a demo... replied with answers.. 
|
|
|
|
|
|
|
|
Back to top
|
|
|
|
coreyw2000
Corey Welsh |
Posted:
Fri Feb 24, 2006 5:07 pm |
|
|
|
PRO VETERAN
Joined: 05 Oct 2004
Posts: 9256
Location: Saskatchewan, Canada
|
|
|
Back to top
|
|
|
|
THE ONE
|
Posted:
Mon Feb 27, 2006 7:43 am |
|
|
|
PRO Level 6
Joined: 01 Oct 2004
Posts: 218
Location: Pakistan
|
Just Replace
| Code: |
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: |
public static void Main(string[] args)
{
System.Diagnostics.Process.Start(@"c:\documents and settings\all users\application.exe");
} |
|
|
|
|
|
|
|
|
Back to top
|
|
|
|
Computer Guru
|
Posted:
Mon Feb 27, 2006 8:04 am |
|
|
|
Disabled User
Joined: 06 Jul 2004
Posts: 9604
Location: Far Far Away
|
|
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.
|
|
|
|
|
|
|
|
Back to top
|
|
|
|
|
Back to top |
|
|
|
|
|