|
Thanks guys I really appreciate your comments. I am never going to use this class. I am not in a traditional classroom but online instead and other than Microsoft Office this is my only other computer class. I would not be here asking for help had I not been in and out of the hospital due to seizures this entire semester. Occassionally people make judgement on people that they truely have no clue about and remember that it is not our please to judge. WE are ALL here on barrowed time! It is just a requirement for becoming a math teacher not a computer programer. And speaking of harsh, TEACHING High School students Algebra will almost always be a much more rewarding carreer than what you do including the door and cocktail deal that you claim to be such a great life! I am a single mother due to domestic violence and a dead beat dad who owes us $52,000 in back child support I am only trying to better our lives because he also thouht that meeting me at the door with more than a cocktail was the high light of my day lol......so maybe being harsh is not the best way to be. What if it was your mom trying to graduate college before you graduate high school, because she knew that it was the only way to give you a better future? Just something to think about next time before you post a comment like the one you posted last night!!!
Thanks and have a very blessed day!
modified on Saturday, April 4, 2009 4:29 PM
|
|
|
|
|
I apologise if I was over-harsh. I know I wasn't in fluffy bunny land.
Given your personal circumstances (which do sound very dramatic!), then it is probably worth getting in touch with the Online University and seeing if there is anything they can do - maybe they could pretend this semester never happened, and you could resit the class.
I wish you every luck with your health and future success in teaching. It's a path I considered, but I'm aware of my deficiencies. Tolerating 15 year olds who didn't want to be there would be something I'd fail at. Probably get arrested for "Assault with projectile chalk"...
Iain.
In the process of moving to Sweden for love (awwww).
If you're in Scandinavia and want an MVP on the payroll (or happy with a remote worker), give me a job!
|
|
|
|
|
Rajesh, you realise you've just doomed her to fail if her lecturer comes along and finds this? Not to mention you're perpetuating the attitude that this forum is a place for students to come have their assignments done for them? I know it was hard to resist because it probably took you less than 2 minutes to write that slab of code, but you haven't taught her anything in the process! That's just basic C++ syntax which either A) a decent C++ resource, or B) her compiler could have taught her!
In future, please only give hints to people looking for help with their homework. Her main problem was trying to compare char arrays in a switch statement. You could have simply told her to look into enum's (and kindly linked her to an article about them). Always keep in mind that the more you "help" these people by giving them a slab of code they can copy and paste to make their grade, the more likely you will one day end up working with them, having to debug their terrible code.
modified on Saturday, April 4, 2009 11:08 PM
|
|
|
|
|
I agree with you. But I see the OP was struggling with more than a week and wasn't able to make anything out, so I gave a working solution and also asked to see how it works. I will refrain from providing complete solutions to such posts in the future though.
Thanks for your comments.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
Hi All
How can i get USB COnnected Drive information?Plz help me
|
|
|
|
|
Have look at my article: Detecting when drives are added or removed[^]. Hopefully it can help a bit!
Iain.
In the process of moving to Sweden for love (awwww).
If you're in Scandinavia and want an MVP on the payroll (or happy with a remote worker), give me a job!
|
|
|
|
|
Hi,
I have a process where the name of a function is in a file text. I Read this file and i whould like to call a function associated with a Execute=[] parameter.
Is it possible ?
|
|
|
|
|
Hi SNArruda,
This is possible if function you want to call is of dll.
You can use GetProcAddress [^] along with LoadLibrary[^]
regards,
Divyang Mithaiwala
Software Engineer
|
|
|
|
|
Divyang's answer is a good one - if the function you want to call is in a DLL.
There is no "execute" command like there is in BASIC. You'll have to roll your own.
int Fred ()
{
return 1;
}
int Wilma ()
{
return 10;
}
int HowHotIs(char *szName)
{
if (!lstrcmpi (szName, "fred"))
return Fred ();
if (!lstrcmpi (szName, "wilma"))
return Wilma ();
return -1;
}<pre>
and call with:
<pre>HowHotIs("Fred");
HowHotIs("Wilma");
HowHotIs(szTextFromFile);
That's a brute force approach. More elegantly, you could have a CString to function pointer map class, or take the approach of self-registering classes from this article: Enumerate your leaf classes[^].
But as you're asking your question, you may want to stick with the brute force approach to start with. But read the article - it's very good! And if you're happy with maps / function pointers - go wild. It's better and more flexible than the function I wrote above.
Iain.
ps: Other ways exist - I've just giving 3.
In the process of moving to Sweden for love (awwww).
If you're in Scandinavia and want an MVP on the payroll (or happy with a remote worker), give me a job!
|
|
|
|
|
Alright, I'm trying to wrap a server written in c for the most part in a class. From inside one of the methods I want to launch a thread to another method. My attempt looks something like this:
void WebServer::ListenServer(void)
{
unsigned threadID;
while(true)
{
int fromlen = sizeof (from);
messageSocket = accept (listenSocket, (struct sockaddr*)&from, &fromlen);
if (messageSocket != INVALID_SOCKET)
{
_beginthreadex(NULL, 1000, (void*)&WebServer::HandleRequest, NULL, 0, &threadID);
}
}
}
void WebServer::HandleRequest()
{
}
Can this even be done? I have tried multiple castings etc of the beginthreadex() function. What would be an alternative to this?
|
|
|
|
|
Hi, from the code you posted I can't be certain if WebServer::HandleRequest is a static function or not. But it must be a static function.
This is because the 3rd argument of _beginthreadex is a pointer to function, which must have exactly the same parameters and return type as the the function that is required.
In this case the function you supply must look like this:
unsigned __stdcall ThreadProc(void * param);
It MUST return an unsigned, and it MUST accept a void* as parameter, and it MUST NOT be a member function. You can still make it part of the class, but as a static function.
Also, never try to fool the compiler by casting the function pointer you pass as your callback - your program is going to try to execute this code, giving it the parameters it expects the function requires. So what if you cast a function that requires more parameters as one that requires less? It will get its arguments from uninitialized memory and will probably crash or cause memory corruption.
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|
|
This article[^] should explain a) why you can't use a bare method pointer as a Win32 callback, and b) help you make an adaptor that will let you call the method you want.
It even mentions _beginthreadex !
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
OK, I have had my head in the sand.... I use VS 6 SP5 MFC. I maintain a legacy application which Vista has broken.
Currently I am using Codejocks Extreme toolkit Automatically linking with ToolkitPro1010vc60SD.lib
I have upgragrated to the latest, but not yet tried a build (too much other stuff going on).
My SDK libs are probably old. I understand the issues with UAC and MS's Stupid vituraliztion scheme unless you have a manifest entry telling them you know about UAC. I also understand their renaming the directory stuctures.
Years ago when they were pushing their com tecnology I bought in and split my program (500k+ lines of code) into several different EXEs which communicate with each other via COM.
Big mistake. Anyway, I won't rant. Back then they preached that you should write to the registry all the time (each time you started to make sure it hadn't gotten corrupted, so all my exe's have something like this in them)
//-----------------------------------------------------------------------------
//Check to make sure we have write permissions to the registry. If we don't, don't
//attempt to register. We won't have write permissions if we are running on
//Windows 200 or XP as a limited user.
LONG lResult = ::RegCreateKeyEx(HKEY_CLASSES_ROOT,sDocClass, 0, "", REG_OPTION_NON_VOLATILE,KEY_ALL_ACCESS, NULL,&hTestKey, NULL);
if ((ERROR_SUCCESS == lResult) && (hTestKey != NULL))
{
g_bLimitedUser = FALSE;
//-------------------------------------------------------------------------------------
// It's ok to call UpdateRegistry
m_server.UpdateRegistry(OAT_DISPATCH_OBJECT);
COleObjectFactory::UpdateRegistryAll();
//-------------------------------------------------------------------------------------
BOOL bResult = AfxOleRegisterTypeLib(m_hInstance, LIBID_NTUExplorer);
if (bResult == 0)
{
AfxMessageBox("AfxOleRegisterTypeLib Failed");
}
//-------------------------------------------------------------------------------------
if (RegisterComponents() == FALSE)
{
CString sCaption = BuildVerString2() + "Unrecoverable Error";
CString sError = "Unable to Register Components. Aborting Launch!!!";
SafeUserNotification(sError,sCaption);
if (g_pMainFrame)
g_pMainFrame->PrepareToClose();
return FALSE;
}
}
OK, so Vista comes along and
//Windows 200 or XP as a limited user.
LONG lResult = ::RegCreateKeyEx(HKEY_CLASSES_ROOT,sDocClass, 0, "", REG_OPTION_NON_VOLATILE,KEY_ALL_ACCESS, NULL,&hTestKey, NULL);
succeeds but
BOOL bResult = AfxOleRegisterTypeLib(m_hInstance, LIBID_NTUExplorer);
Fails. I hesitate to update the SDK because I am running VS 6 and things are very stable... Who knows what might crop up.
SO, as I see it, I have a couple of options...
Move all my registration to the install program as they now suggest (contratry to previous suggestions) add the manifest entry, dink with my directory structure and things will probably work, although VS 6 doesn't officially run on Vista (I have gotten it installed and it seems to run OK)
or
Bite the bullet, move to VS2008, regen my skeleton apps. Populate them with my code and Deal with the ansi compiler issues and hope for the best....
Any thoughts on what you would do? I have tried .net, 2003, 2005, and pitched them all in favor VS6. If you are a MFC developer there is little reason to move to those platforms... What about VS 2008?
|
|
|
|
|
Having many years of code successfully working and made in VC6, I still use it most days - and quite happily. Mind you, if I could still use Word 6 I would - lightweight, just what I need and not too much extra.
I am a little puzzled at your logic of NOT registering your COM objects in the registry as part of the setup process. That makes only the setup program need any sort of privilege - and you need a lot less privilege for the day to day running of your software.
So, all vista is doing is enforcing behaviour that should have been followed from the beginning.
Would it be a huge change to move the registration code to the setup and comment it out on your "real" programs?
Iain.
In the process of moving to Sweden for love (awwww).
If you're in Scandinavia and want an MVP on the payroll (or happy with a remote worker), give me a job!
|
|
|
|
|
I do register them in the install program.
MS also recommended at the time that you also register in InitInstance to make sure nothing in the registry had gotten corrupted....
Now not suprisingly they recommend the opposite.
I guess the real question is, given the issues with the compiler differences and the fact that I have a large code base, is it worth moving to VS2008, or patch the programs to run on vista and stick with VS6?
So which is better VS2008 or VS6.
Is it worth the move?
|
|
|
|
|
Not a simple problem you have.
I don't think you need to update the registry every time. If a user is stupid enough to delete your entries from the registry, then you'll get com errors and you'll have a chance to write a pithy and sarcastic message box.
AfxMessageBox (L"Please hit yourself. You deserve it. Really...");
The advantage of the way you've broken up your program is that you can slowly migrate - just one exe at a time, rather than all or nothing.
If you can tweak your current VS6 (which I use happily) codebase to work under Vista, then do new development work in later versions.
Parker M cCauley wrote: So which is better VS2008 or VS6?
Both!
Iain.
In the process of moving to Sweden for love (awwww).
If you're in Scandinavia and want an MVP on the payroll (or happy with a remote worker), give me a job!
|
|
|
|
|
I like the message box Idea.... LOL
Unfortuately, back then the theory was that some other program (like the operating system would be the culprit.
Back when I first started looking into it, I was able to find the original KB article that highly recommended you do this, and also the later KB article that says it's a bad idea.
My more recent searches on msdn don't turn up the first. Perhaps it has been removed.
I am interesting it your Both! comment....
Why both?
Do use visual assist with VS6?
|
|
|
|
|
By Both, I meant installing both environments. For the odd tweak, leave your code in VS6. If you have to do major changes to a module, take that chance to modernise it.
While having your code split into bits may give you headaches, it does have the advantage of being able to be converted module by module, instead of all or nothing.
I hope that's more clear.
In the process of moving to Sweden for love (awwww).
If you're in Scandinavia and want an MVP on the payroll (or happy with a remote worker), give me a job!
|
|
|
|
|
OK, thanks for the clarification...
-Parker
|
|
|
|
|
I have been searching the internet for days trying to figure this out and the only thing I can find is other people with this problem and no resolution.
I am writing a C++ application that does not require .NET of any kind.
I can get the currently logged in users information using the NetWkstaUserGetInfo() API call. I then pass the username and domain to the NetUserGetGroups() function and can get back the groups that the user is a member of, but it doesn't show nested groups.
Example:
Group 1
|____Group A
|____*User1*
Group 2
|____Group B
|____*User1*
If a user, *User1*, is a member of "Group A" and a member of "Group 2" I would like for the function to return:
Group A (explicit membership)
Group 1 (implicit membership thru Group A)
Group 2 (explicit membership)
Right now it is only showing:
Group A (explicit membership)
Group 2 (explicit membership)
Please tell me someone has done this before without .NET!
|
|
|
|
|
See here.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Dude I award you the Googling MOFO of the day trophy!
Of course not if you have that URL tattooed on the back of your hand.
|
|
|
|
|
union u
{
char ch[2];
int i;
};
int main()
{
union u x={0,2};
cout<<x.ch<<"\n\n\n";
cout<<x.i<<endl;
return 0;
}
Why does this print 512??? What is this x={0,2}; exactly doing?
----------------------------
286? WOWW!
|
|
|
|
|
The union looks something like this:
-----------------------
| 512 |
-----------------------
| 00000010 | 00000000 |
-----------------------
| 2 | 0 |
-----------------------
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Thanks.
----------------------------
286? WOWW!
|
|
|
|
|