|
shabonaa wrote: how can i get my computer in a safe mode using c#?
You can't. Safe mode is only available on boot.
shabonaa wrote: simply i want to get my pc sleep and wake it up after a period of time
Far from simple. You're looking at using the Windows Power Management functions to set a wake timer and put the system in StandBy. See this[^] for more information. I wasn't able to find any examples of anyone using this. It's just functionality that's rarely ever used from inside an application.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Dave Kreskowiak wrote: shabonaa wrote:
how can i get my computer in a safe mode using c#?
even using APIs?
THE ONLY WISDOM THAT YOU KNOW YOU KNOW NOTHING
|
|
|
|
|
Is it possible that you mean "Sleep" or "Standby" instead (S3/S1) ?
If you want to "force" your computer into Safe-Mode (which you get when you boot, press F8 and mark "safe mode"), you will have to deliberately crash your computer in a bad way, so that Windows (on reboot) automatically chooses "Safe Mode" because it thinks that it might be broken.
Well, that might happen. If you try to force your computer into a failsafe modus, you might DESTROY your data in the process, so I sincerely suggest you dont try it.
Cheers,
Sebastian
--
Contra vim mortem non est medicamen in hortem.
|
|
|
|
|
sorry there was a missunderstading i meaned standbye not safe mode
|
|
|
|
|
does anybody have queen mc_klaski(the method on making breif bool algebra) method code.
if somebody has, please send me or present me some links.
thanks alot...
thanks
rastegar
|
|
|
|
|
I have serval forms f1 f2 f3 f4 in my application. How can i make f1 f2 f3 f4 exact same size in width and height?
THX
|
|
|
|
|
f4.Width = 300;
f4.Height = 300;
f1.Width = f2.Width = f3.Width = f4.Width;
f1.Height = f2.Height = f3.Height = f4.Height;
"we must lose precision to make significant statements about complex systems."
-deKorvin on uncertainty
|
|
|
|
|
assume u want to make them all the same size of f1 then
in f2 do that:
f1 TempForm=new f1();
f2.Size=f1.Size;
the same for f3 and f4.
|
|
|
|
|
I overload operator== in a class, say, MyClass, like this
public static bool operator==(MyClass lhs, MyClass rhs) {<br />
return lhs.someValue == rhs.someValue;<br />
}
Which will fail if either lhs or rhs is null. Fix
public static bool operator==(MyClass lhs, MyClass rhs) {<br />
try {<br />
return lhs.someValue == rhs.someValue;<br />
} catch (Exception) {<br />
return false;<br />
}<br />
}
But this will result in the following code not working
void MyFunction(MyClass anInstance) {<br />
if (anInstance == null) {<br />
}<br />
}
Fix
public static bool operator==(MyClass lhs, MyClass rhs) {<br />
if (lhs == null && rhs == null) {<br />
return true;<br />
}<br />
<br />
try {<br />
return lhs.someValue == rhs.someValue;<br />
} catch (Exception) {<br />
return false;<br />
}<br />
}
But this causes a stack overflow since the check on "lhs == null" calls operator== again ...
Help someone pls
-- modified at 15:05 Tuesday 10th January, 2006
|
|
|
|
|
I've never done anything with operator overloading, this is just a guess tho:
if(Object.Equals(lhs, null) && Object.Equals(rhs, null)) return true;
Dunno if this works, but it's worth a try.
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
You're right check works!
And as I see it, you have to do this whenever you overload operator== !!!
Thx
|
|
|
|
|
Only overload operator== on value (i.e., non-reference) types such as structures and enumerations. You'll be much safer.
"we must lose precision to make significant statements about complex systems."
-deKorvin on uncertainty
|
|
|
|
|
FxCop says that you should not override operator== on reference types ]^].
Instead, override Object.Equals( object ) and use that in your code:
MyClass a = new MyClass( someValue );
MyClass b = new MyClass( someValue );
MyClass c = new MyClass( anotherValue );
a.Equals( b );
a.Equals( c ); Now, you can handle null s.
"we must lose precision to make significant statements about complex systems."
-deKorvin on uncertainty
|
|
|
|
|
Ok, and that advice might be due to the exact reason i've just discovered.
Yes using Equals will do the trick, but the code is much less intuitive to read, as opposed to some syntactic sugar, like "a == b"
Thx
|
|
|
|
|
Whoa, that FxCop found 100 errors/warnings in my little 3D-engine. Is there a reason to be afraid now?
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
<chuckle>No, not at all!</chuckle>
FxCop just contains the "best practices" as defined by Microsoft and some other folks. <smile /> I often hit the ignore button because I need to use an out or ref param in my code. They don't like that.
"we must lose precision to make significant statements about complex systems."
-deKorvin on uncertainty
|
|
|
|
|
Casting to object will cause the default == operator to be called:
Use this:
public static bool operator==(MyClass lhs, MyClass rhs) {
if ((object)lhs == (object)rhs) {
return true;
}
if ((object)lhs == null || (object)rhs == null) {
return false;
}
return lhs.someValue == rhs.someValue;
}
|
|
|
|
|
Don't you mean
public static bool operator==(MyClass lhs, MyClass rhs) {<br />
if ((object)lhs == null && (object)rhs == null) {<br />
return true;<br />
}<br />
if ((object)lhs == null || (object)rhs == null) {<br />
return false;<br />
}<br />
return lhs.someValue == rhs.someValue;<br />
}
Otherwise Object.operator== will be used for all comparisons, as I see it.
Thx
|
|
|
|
|
No, the first if ("if ((object)lhs == (object)rhs) {") will only return true when the instances are the same, ie when both are null or when both point to the same instance (in that case, the values will always be the same).
When they point to different instances, the if-block will not be entered and the next statment will compare the values.
|
|
|
|
|
|
I am trying to create a mailbox from a web applicattion that it is not in a domain controller (a webservice) using CDOEXCH. The code works fine when the web service is in the domain controller but no way out of it. If we put the code in a Windows applicattion then everything work fine even in a non domain controller computer. We have try to impersonate the asp, or even the application pool. The security context was ok but there is something wrong with any permission or something like that though the credentials have domain administrator rights.
I have tried to encapsulate the code in a COM+ object and impersonating with administrator rights but I didn´t success. I copy the general idea from our code and the return error. Any idea wolud be really apreciate
DirectoryEntry container, user;
CDOEXM.IMailboxStore mailbox;
//This creates the new user in the "users" container.
//Set the sAMAccountName and the password
container = new DirectoryEntry("LDAP://cn=users," + defaultNC);
user = container.Children.Add("cn=" + fullName, "user");
user.Properties["sAMAccountName"].Add(alias);
user.CommitChanges();
user.Invoke("SetPassword", new object[]{password});
//This enables the new user.
user.Properties["userAccountControl"].Value = 0x200; //ADS_UF_NORMAL_ACCOUNT
user.CommitChanges();
//Obtain the IMailboxStore interface, create the mailbox, and commit the changes.
mailbox = (IMailboxStore)user.NativeObject;
mailbox.CreateMailbox(homeMDB);
user.CommitChanges();
RETURN ERROR:
Unable to create a mailbox for the specified user. Using homeMDB path: LDAP://PRSRVDCCAM1.redcam.local/CN=Mailbox Store (PRSRVDCCAM1),CN=First Storage Group,CN=InformationStore,CN=PRSRVDCCAM1,CN=Servers,CN=First Administrative Group,CN=Administrative Groups,CN=CAM,CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=REDCAM,DC=local. Inner exception attached from: mscorlib. Current user context: REDCAM\AdministratorWith error
Facility: LDAP Provider
ID no: 80072020
Microsoft CDO for Exchange Management
|
|
|
|
|
I don't know if this helps, but according to the article ASP.NET Web Application Security[^] from MSDN, ASP.NET has client impersonation set to false. I don't know if this affects your ASP.NET application (I don't do that kind of thing), but I thought it might be a direction for you to look.
"we must lose precision to make significant statements about complex systems."
-deKorvin on uncertainty
|
|
|
|
|
Hi:
Is it possible for showing when an option has been toggled on/off on a menu? If so, how do I program it?
Thanks, Smurfy
|
|
|
|
|
Well, first you need to set the MenuItem 's Checked property to the appropriate Boolean value.
From here, you have a couple of choices.
1) If the user can only change the state of the application through clicking that MenuItem , then hook up an event handler to the Click event of the MenuItem (which I'm sure you already have) and set the MenuItem 's Checked property equal to the Boolean inverse of its current value. For example: menuItem1.Checked = !menuItem1.Checked; .
2) If the state of the application can change without the use of the MenuItem , then hook up an event handler to the MenuItem 's parent MenuItem 's Popup event. In that event handler, have something like targetMenuItem.Checked = ShouldICheckThisMenuItem(); where ShouldICheckThisMenuItem() is some method that returns a Boolean value determining if the MenuItem should get checked.
Hope that helps.
"we must lose precision to make significant statements about complex systems."
-deKorvin on uncertainty
|
|
|
|
|
I have a window form and I have label with the text "open file" on the form. I want the text "open file" to appear in red (not the defaul black). How can i do it?
THX.
|
|
|
|