Can this function call fail in some configuration of Windows NT 4.0 and later? The docs state that the complementary SetSystemTime call will fail if the user doesn't have the privileges to set the time on a system. I have an application that is failing to return this information. The function is void, so the only real valid check is to check the SYSTEMTIME struct for empty values.
What I need my application to do is allow the user to type in their username, password and Domain and then using the Net API validate the password with the username and then see if the user is a member of a certain group (A group which I have set up).
Could anyone help me on this subject (Really struggling).
Any sample code (Using C++ MFC/win32) or guide lines would be very much appreciated.
(CLASendMailApp* )AfxGetApp() casts that pointer to a pointer to a CLASendMailApp. that way, any functions called through that pointer will act on your CLASendMailApp application, and not on the CWinApp base class.
why ? CWinApp doesn't have a LoadSettings() member function. CLASendMailApp (hopefully) does.
Tom Wright wrote: I need to access a function that is in another class that I have I can "cast" it like this?
you can only safely cast a pointer like this if the To and From class are realted to each other (ie. if the To class is derived from the From class, or vice versa).
Tom Wright wrote: And in my first example can I cast a pointer to me class in the void OnClose function?
you can't cast a class pointer to something that isn't a class. if you need pointers to your class in a function that isn't a member of your class, you'll need to pass a pointer to an object of your class into that function (or maybe make it available as a global variable):
I'm trying to setup a Timer in my UI thread. While doing this I found that the easiest way was to do the SetTimer with the forth parameter being the callback function.
Problem is that I've never really worked with callback function and while working with this particular one I found that i did not have access to m_pconnection pointer and the thdID pointer.
I remembered that someone had helped me with another program that did a casting of a pointer like the one listed at the beginning of the post, but i wasn't sure if this is what I needed to do here and since i didn't really understand what was happening with that line of code I decided to post.
So comming full circle I'm still trying to understand when one needs to cast a pointer and when one needs to pass a pointer.
Heck I just found out how to initialize a char array on the fly (so to speak) using the new operator. I've always seen it used but never understood why until it was explained to me.
Tom Wright wrote: I'm trying to setup a Timer in my UI thread. While doing this I found that the easiest way was to do the SetTimer with the forth parameter being the callback function.
if you're doing this in an MFC app, you can just use the OnTimer function to handle this: use the class wizard, if you're using VC6, or change the window/dialog/app properties in VC7, to add a handler for WM_TIMER. that way, the function will be a member of your CWnd and you can use any class functions you want.
the problem with the callback method, in my opinion, is that it doesn't give you a way to pass any custom info into the callback function. some callbacks give you a parameter that you can use for things like pointers. this one requires you to get all the data from global variables.
Tom Wright wrote: So comming full circle I'm still trying to understand when one needs to cast a pointer and when one needs to pass a pointer.
you pass a pointer when you need a pointer to something.
you cast a pointer when the pointer doesn't point to what you need it to point to, but can safely interpreted as if it was pointing to what you need. for example, if you have a pointer to an object of type C, you can cast that pointer to anything that C is derived from; this lets you call functions from the base classes; ex. if class C is derived from class B, you can cast your C* pointer to B* and then call class B's functions. likewise, if you have a C* pointer (a pointer to an object of type C), and you've cast it to a base class of type "B" ( B* pB = (B*)pC; ), you can cast that back up to a "C". but, all this requires that you know what the pointer is really pointing to, and what the class heirarchy looks like.