|
Is there a way to know whether windows is doing a Restart OR a Shut Down?
I mean by any means in the world?
It's easy to catch the WM_ENDSESSION message but it regroups these both modes.
Also is there a way to do the same thing but with Stand By and Hibernate??
I can't and won't believe there is no way whatsoever to do this.
It's another of these things that seems ridiculously easy but turn out to be an hardcore nightmare when you attempt it.
Thanks
Olograph
|
|
|
|
|
Why would it matter?
A restart is (effectively) just a shut down that doesn't need the user to push a button to get going again. He could easily enough turn a restart into a shutdown by turning off the power, couldn't he?
Unless you have defective hardware that needs a complete power down cycle to fix a problem, it really shouldn't matter, so I could understand Windows not giving you the information.
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
Hi everybody,
I'm trying to make a simple contactlist in VS2008 C#.
1) I need to display a table in a mdb db file in a datagrid.
2) Above the grid in the UI i have a searchcritera on which column i want to make the search on.
Think a dropdownbox with column names and a textbox that is the relevant searchtext.
3) When i change the searchtext char by char i want to show a subset of the datagrid(growing or shrinking), ie filter out rows that
doesn't meet the "searchtext".
Don't need complete solutions, just point me in the direction of which controls and approaches to use.
Am a bit anti against datasets, but probably in this case i would use them ?
/Daniel S
|
|
|
|
|
babbelfisken wrote: anti against datasets
Ignoring the double negative - why? Datasets are useful. They are, after all, sets of data, which is what we all deal with every day.
More often than not, it's really one of the underlying data tables we want, so bind to that instead.
If the data table represents a class, then convert to the class in your business layer (or in the background if you're not using an n-tier type structure) and bind to the class instance.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
Ok now I got the User Names now I am needing help on learning how to filter the list so that I get all persons and not the junk loging such as DHCP Administrator, DNSUpdateProxy groups, etc...
I only want persons...
<code> public void ShowDomainUsers()
{
string filter = "";
//DirectoryEntry domain = new DirectoryEntry("LDAP://domain.com/CN=Users,DC=Domain,DC=com");
try
{
if (File.Exists(Environment.CurrentDirectory + "\\Debug.txt"))
{
MessageBox.Show("LDAP://" + cboDomains.Text + "/CN=Users,DC=" + Left(cboDomains.Text, (cboDomains.Text.IndexOf(".", 0))) + ",DC=" + Right(cboDomains.Text, (cboDomains.Text.Length - cboDomains.Text.IndexOf(".", 0) - 1)));
}
using (DirectoryEntry domain = new DirectoryEntry("LDAP://" + cboDomains.Text + "/CN=Users,DC=" + Left(cboDomains.Text, (cboDomains.Text.IndexOf(".", 0))) + ",DC=" + Right(cboDomains.Text, (cboDomains.Text.Length - cboDomains.Text.IndexOf(".", 0) - 1))))
//root and filter and propertiestoload I do not know what to put
//filter = "(objectCategory=person)(objectClass=user)";
//using (DirectorySearcher searcher = new DirectorySearcher(root,filter,propertiestoload))
//using (SearchResultCollection results = searcher.FindAll())
//sAMAccountName -- THIS IS WHAT I want to get the USER Login names
foreach (DirectoryEntry child in domain.Children)
{
//Console.WriteLine(child.Name);
//lbxDomainUsers.Items.Add(new ListViewItem(new string[] {Right(child.Name, (child.Name.Length - 3)), child.Username}));
lbxDomainUsers.Items.Add(Right(child.Name, (child.Name.Length - 3)) + " | " + child.Properties["sAMAccountName"].Value);// Username);
}
}
catch
{
MessageBox.Show("We are having a problem with the active directory.");
}
}
modified on Friday, July 10, 2009 5:37 PM
|
|
|
|
|
Ok this finally gives me what I am wanting but now I can not bring in multiple properties without it erroring.
public void ShowDomainUsers()
{
//string path = "LDAP://xxxx/CN=Users,DC=firm,DC=xxxx,DC=com";
string Path = "LDAP://" + cboDomains.Text + "/CN=Users,DC=" + Left(cboDomains.Text, (cboDomains.Text.IndexOf(".", 0))) + ",DC=" + Right(cboDomains.Text, (cboDomains.Text.Length - cboDomains.Text.IndexOf(".", 0) - 1));
string Filter = "(&(objectCategory=person)(objectClass=user))";//(!userAccountControl:1.2.840.113556.1.4.803:=2))";
string[] PropertiesToLoad = new string[2] { "name", "sAMAccountName" };
//DirectoryEntry domain = new DirectoryEntry("LDAP://domain.com/CN=Users,DC=Domain,DC=com");
try
{
if (File.Exists(Environment.CurrentDirectory + "\\Debug.txt"))
{
MessageBox.Show("LDAP://" + cboDomains.Text + "/CN=Users,DC=" + Left(cboDomains.Text, (cboDomains.Text.IndexOf(".", 0))) + ",DC=" + Right(cboDomains.Text, (cboDomains.Text.Length - cboDomains.Text.IndexOf(".", 0) - 1)));
}
using (DirectoryEntry domain = new DirectoryEntry("LDAP://" + cboDomains.Text + "/CN=Users,DC=" + Left(cboDomains.Text, (cboDomains.Text.IndexOf(".", 0))) + ",DC=" + Right(cboDomains.Text, (cboDomains.Text.Length - cboDomains.Text.IndexOf(".", 0) - 1))))
using (DirectorySearcher searcher = new DirectorySearcher(domain, Filter, PropertiesToLoad))
using (SearchResultCollection results = searcher.FindAll())
{
foreach (SearchResult result in results)
{
string name = (string)result.Properties["name"][0];
MessageBox.Show(name);
string name1 = (string)result.Properties["sAMAccountName"][1];
MessageBox.Show(name1);
lbxDomainUsers.Items.Add(name);
}
}
//sAMAccountName -- THIS IS WHAT I want to get the USER Login names
/*
foreach (DirectoryEntry child in domain.Children)
{
//Console.WriteLine(child.Name);
//lbxDomainUsers.Items.Add(new ListViewItem(new string[] {Right(child.Name, (child.Name.Length - 3)), child.Username}));
lbxDomainUsers.Items.Add(Right(child.Name, (child.Name.Length - 3)) + " | " + child.Properties["sAMAccountName"].Value);// Username);
}
*/
}
catch
{
MessageBox.Show("We are having a problem with the active directory.");
}
}
|
|
|
|
|
Figured it out....
public void ShowDomainUsers()
{
//string path = "LDAP://xxxx/CN=Users,DC=firm,DC=xxxx,DC=com";
string Path = "LDAP://" + cboDomains.Text + "/CN=Users,DC=" + Left(cboDomains.Text, (cboDomains.Text.IndexOf(".", 0))) + ",DC=" + Right(cboDomains.Text, (cboDomains.Text.Length - cboDomains.Text.IndexOf(".", 0) - 1));
string Filter = "(&(objectCategory=person)(objectClass=user))";//(!userAccountControl:1.2.840.113556.1.4.803:=2))";
string[] PropertiesToLoad = new string[2] { "name", "sAMAccountName" };
//DirectoryEntry domain = new DirectoryEntry("LDAP://domain.com/CN=Users,DC=Domain,DC=com");
try
{
if (File.Exists(Environment.CurrentDirectory + "\\Debug.txt"))
{
MessageBox.Show("LDAP://" + cboDomains.Text + "/CN=Users,DC=" + Left(cboDomains.Text, (cboDomains.Text.IndexOf(".", 0))) + ",DC=" + Right(cboDomains.Text, (cboDomains.Text.Length - cboDomains.Text.IndexOf(".", 0) - 1)));
}
using (DirectoryEntry domain = new DirectoryEntry("LDAP://" + cboDomains.Text + "/CN=Users,DC=" + Left(cboDomains.Text, (cboDomains.Text.IndexOf(".", 0))) + ",DC=" + Right(cboDomains.Text, (cboDomains.Text.Length - cboDomains.Text.IndexOf(".", 0) - 1))))
using (DirectorySearcher searcher = new DirectorySearcher(domain, Filter, PropertiesToLoad))
using (SearchResultCollection results = searcher.FindAll())
{
foreach (SearchResult result in results)
{
string name = (string)result.Properties["name"][0];
string winuserlogon = (string)result.Properties["sAMAccountName"][0];
//MessageBox.Show(name);
//string name1 = (string)result.Properties["sAMAccountName"][1];
//MessageBox.Show(name1);
lbxDomainUsers.Items.Add(name + " | " + winuserlogon);
}
}
//sAMAccountName -- THIS IS WHAT I want to get the USER Login names
/*
foreach (DirectoryEntry child in domain.Children)
{
//Console.WriteLine(child.Name);
//lbxDomainUsers.Items.Add(new ListViewItem(new string[] {Right(child.Name, (child.Name.Length - 3)), child.Username}));
lbxDomainUsers.Items.Add(Right(child.Name, (child.Name.Length - 3)) + " | " + child.Properties["sAMAccountName"].Value);// Username);
}
*/
}
catch
{
MessageBox.Show("We are having a problem with the active directory.");
}
}
|
|
|
|
|
Wondering if I'm missing something fundamental.
I want tabbed planes with the exact gui/functionality on each. Each will load different data.
The tabbed planes seem to be such that each pane is different.
Is there a setting for this or do I need to clone what VS does for the first tab for each added tab?
--av
|
|
|
|
|
This is an ideal candidate for a user contol.
Put all your controls and the functionality into a user control and drop one onto each tab. Any communication with the parent form or other objects that the form references can be done with events and you get good reusability of your code.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
|
Whilst your question is not absolutely clear, can I suggest that you look at TabConrol Class[^].
If that does not help, please come back, and if you could find a way to reword your question, it might make it easier for others to help you.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Hi Friends,
Are Methods and Functions the similar thing? I mean, are they same. I surfed the net and on some forum I found this definition, which I modified: "Methods are in-built whereas Functions are user-defined, in a programming environment". Is this definition correct to some extent? I mean, it would have been very nice of you all, if you guys could provide me an advanced definition for this. And please say, whether the same definition work out for both OOP and other non-OOP HLL language.
Thanks in advance,
Help would be appreciated,
Rajdeep
I calculate my days on earth..... approximately 55 years remaining for me to expire
|
|
|
|
|
|
In my mind, a method is a named block of code which may accept an input, usually performs an action, and may either alter the input, return output, or both. A function is a method which returns output. These are just working definitions, so may not be technically correct. They just work in most scenarios
Between the idea
And the reality
Between the motion
And the act
Falls the Shadow
|
|
|
|
|
Hi freak!
Well, thanks for the definition man. Actually, in C#, the concept of methods and functions are eventually different, whereas, in Java, theres no concept of functions. Only methods.
Well, suddenly I was struck with the lightening of knowledge
The stuff also can be defined like: "A method can be declared within a function, however, its not possible to declare functions within a method". How's that? Silly aint it? Does this make any sense. Do let me know!
I calculate my days on earth..... approximately 55 years remaining for me to expire
|
|
|
|
|
That doesn't make any sense. I've already said how I view methods and functions to be different, how is this inaccurate - it implies that functions and methods are different, with functions being a subtype of methods
The definition you gave is odd. If I declared some C# code like so:
public int Function()
{
private void Method()
{
}
} It wouldn't compile AFAIK (not got access to csc, so can't check). The same point applies to the second clause of your sentence.
Between the idea
And the reality
Between the motion
And the act
Falls the Shadow
|
|
|
|
|
Indeed, C-like languages can't do that. (Probably for good reason.)
|
|
|
|
|
They are really just terms for the same thing, but...
Pascal makes the following distinction:
A function returns a value, and does not alter the parameters (if any) -- x = ABS(y)
A procedure does not return a value, but does alter the parameters -- CLOSE(f)
C (and its descendants) don't really make that distinction, so a function may alter the parameter and return a value -- e = CLOSE(f)
** Although allowed by the language, many practitioners frown on "functions" that have "side-effects", regardless of the language in use. **
With Object Oriented Programming, functions that are part of a class (or struct) are called methods.
Unlike C++, C# enforces OOP so all functions must be part of a class, and are therefore methods.
If you choose, you may write methods that conform to the above definition of "function" or "procedure"
Likewise, in C# some methods are properties, some are indexers, etc.
|
|
|
|
|
How about static functions/methods then? Math.Abs doesn't really care that it happens to be in Math, and you're not even passing a pointer to Math as implicit first parameter either.
|
|
|
|
|
static nethods (IMO) are more like functions.
Functions = Sledge Hammer that does what it says on the tin.
Methods = More subtle to massage and manipulte fields/properties/data
Obviously these can be interchanged but...
BTW, I hesitated to reply on this thread. You do recognise the OP? Encouragement is probably not a good idea!
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
Uh, yeah? So?
If they belong to a class they're methods, big fat hairy deal.
|
|
|
|
|
That's not what I learned at school
that was: methods operate on an object, functions don't.
That makes static functions functions.
For you it only seems to matter where they are written and not what they actually do.
But a quick search on google reveals that the opinions of The Masses are pretty much divided into those two trains of thought.
It's not like it actually matters though, a rose by any other name would smell as sweet
|
|
|
|
|
harold aptroot wrote: It's not like it actually matters though, a rose by any other name would smell as sweet
Absolutely.
I sit corrected; the C# spec says:
"
7.4 Function members
Function members are members that contain executable statements. Function members are always members of types and cannot be members of namespaces. C# defines the following categories of function members:
• Methods
• Properties
• Events
• Indexers
• User-defined operators
• Instance constructors
• Static constructors
• Destructors
"
So as far as C# is concerned, "function" is a rather generic term. I had been using the term "member" for that meaning.
However, I still feel that we need to consider non-OOP and "multi-paradigm" languages when discussing this topic. Pascal clearly has function s and procedure s, C has only functions (as a concept, not as a keyword), C++ has functions and members.
The purpose of defining such concepts and terminology is so we may communicate.
|
|
|
|
|
Anybody knows what happened to subroutines?
and procedures?
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Subroutines can't take parameters.
Procedures may remove your spleen.
|
|
|
|
|