A Digital Age Deserves A Digital Leader

Visual C# .NET : 2 adjustments in application

Visual C# .NET : 2 adjustments in application

Postby styx » Thu Feb 23, 2006 9:34 pm

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
;
" 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: 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 :)
PRO Level 4
Posts: 102
Joined: Fri Feb 18, 2005 3:58 pm
Location: belgium

Re: Visual C# .NET : 2 adjustments in application

Postby _Taz_ » Thu Feb 23, 2006 10:01 pm

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
;
" 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: 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.
PRO Level 13
User avatar
Posts: 848
Joined: Tue Jun 29, 2004 2:01 pm
Location: Florida

Re: Visual C# .NET : 2 adjustments in application

Postby styx » Thu Feb 23, 2006 10:03 pm

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
PRO Level 4
Posts: 102
Joined: Fri Feb 18, 2005 3:58 pm
Location: belgium

Re: Visual C# .NET : 2 adjustments in application

Postby Telos » Thu Feb 23, 2006 11:33 pm

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
Code: Select all
;
" 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: 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
PRO Level 5
User avatar
Posts: 172
Joined: Wed Jul 13, 2005 12:04 am
Location: Tonawanda, NY

Re: Visual C# .NET : 2 adjustments in application

Postby styx » Fri Feb 24, 2006 7:37 pm

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 :)
PRO Level 4
Posts: 102
Joined: Fri Feb 18, 2005 3:58 pm
Location: belgium

Postby coreyw2000 » Fri Feb 24, 2006 9:07 pm

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
PROfessional Member
Posts: 4644
Joined: Tue Oct 05, 2004 5:30 am
Location: Saskatchewan, Canada

Postby THE ONE » Mon Feb 27, 2006 11:43 am

Just Replace

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");
   }
Image
PRO Level 2
User avatar
Posts: 28
Joined: Fri Oct 01, 2004 4:10 pm
Location: Pakistan

Postby styx » Fri Sep 05, 2008 12:32 am

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! :oops:
PRO Level 4
Posts: 102
Joined: Fri Feb 18, 2005 3:58 pm
Location: belgium

Return to HTML, CSS, and Scripts

Who is online

Users browsing this forum: No registered users and 3 guests