PROnetworks »

Post new topic    Reply to topic
Login to print this topic
Author Message
styx
PostPosted: Thu Feb 23, 2006 5:34 pm Reply with quote

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
Code:
;
" 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 smile
 
Back to top
_Taz_
Bobby Creech
PostPosted: Thu Feb 23, 2006 6:01 pm Reply with quote

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
Code:
;
" 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
PostPosted: Thu Feb 23, 2006 6:03 pm Reply with quote

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 lol

But thanks anyway
 
Back to top
Telos
PostPosted: Thu Feb 23, 2006 7:33 pm Reply with quote

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
Code:
;
" 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 smile


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
PostPosted: Fri Feb 24, 2006 3:37 pm Reply with quote

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 smile 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 smile
 
Back to top
Computer Guru
PostPosted: Fri Feb 24, 2006 4:48 pm Reply with quote

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 tongue}
 
Back to top
Computer Guru
PostPosted: Fri Feb 24, 2006 5:03 pm Reply with quote

Disabled User
 
 


Joined: 06 Jul 2004
Posts: 9604
Location: Far Far Away
Got your email..
See, that is only a demo... replied with answers.. smile
 
Back to top
coreyw2000
Corey Welsh
PostPosted: Fri Feb 24, 2006 5:07 pm Reply with quote

PRO VETERAN
 
 


Joined: 05 Oct 2004
Posts: 9256
Location: Saskatchewan, Canada
Try it without the ;
 
Back to top
THE ONE
PostPosted: Mon Feb 27, 2006 7:43 am Reply with quote

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
PostPosted: Mon Feb 27, 2006 8:04 am Reply with quote

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
Index >> Webmaster Domain & Code Room >> Visual C# .NET : 2 adjustments in application

Goto page 1, 2  Next

Page 1 of 2

Post new topic   Reply to topic


Tired of the Ads? Registered users have 80% less adverts.