|
I would say, that in that case you would have to add your own ack/nak layer. You would have to have the receiver acknowledge every message you sent by sending back an "ack" message.
|
|
|
|
|
Hi,
How to get a coloured button?
Thanks,
Deepak Samuel.
|
|
|
|
|
Hi,
Your question has been posted several times! You should search the comments and you'll get your answer!
A student knows little about a lot.
A professor knows a lot about little.
I know everything about nothing.
|
|
|
|
|
checkout for CxShadeButton class its a 'Class' of its own
|
|
|
|
|
Is there a way to convert the value of a string to an 'enum' value? For example:
string pos = "first";
enum ePOS {first, second, third, etc} POS;
POS = pos; OK, I know "first" as a string, is different than "first" as an 'enum' value (the 'enum' value being the equivalent of integer 0). But if the user enters "first" I'm trying to equate that to the 'enum' value "first" (without having to do a lot of "if - else" testing).
William
Fortes in fide et opere!
|
|
|
|
|
Yes
Could you use a CStringArray instead / or in addition (like build from)? If so find returns the pos of "First" and then enum from there.
Best Wishes and Happy Holiday's,
ez_way
|
|
|
|
|
Not without using some secondary data structure, like a map, to facilitate the conversion.
map<string, ePOS> theMap;
theMap["first"] = first;
theMap["second"] = second;
string s = "first';
ePOS p = theMap[s]; // error checking needed here, obviously
--Mike--
Ericahist | CP SearchBar v2.0.2 | Homepage | RightClick-Encrypt | 1ClickPicGrabber
Four fonts walk into a bar. The bartender says "Hey - get out! We don't want your type in here."
|
|
|
|
|
Thanks for replying.
I decided to use an array of the values, and check what the user entered against the values in the array, then use the relative address of the value in the array (if there was a match) and equate that with the relative value of the 'enum' variable. (Almost the same thing you were suggesting.)
William
Fortes in fide et opere!
|
|
|
|
|
Yes, it is quite same. Only when you have a lot of strings, the Michael Dunn's idea is better, because the map algorithm of matching string-type keys is quicker.
Robert-Antonio
|
|
|
|
|
I have spent the last 24 hours tracking down a heap corruption problem. I think I now know vaguely what the problem is, but it has made it clear I have no idea what I'm doing when it comes to heap usage with DLLs under windows. I am hoping some seasoned windows programmer out there can first look at my sad story below, and then either educate me as to the do's and don'ts of heap usage with DLLs under windows or point me to an article or book that will educate me. I'm not looking to be an expert, but I don't want to hit any more snafus like this one.
MY SAD STORY:
I'm working on my first windows DLL. I have an exported function that looks much like this one:
void __declspec(dllexport) getCommandString(std::string& commandString);
In case it's not obvious, usage of this function is for the application to pass in a string by reference, then some code in the DLL sets it for you.
Perhaps you already know my problem. If you do, YOU are the person I hope to hear from. But I'll finish my sad story for those of you who don't.
So I had some application code that called this function, much like this:
void doSomething()
{
std::string commandString;
getCommandString(commandString);
return;
}
doSomething() fails at the return statement with an assertion failure when memory for commandString was being freed. Digging into the stack trace I found the assertion failure was occuring somewhere in the implementation of this system call:
HeapValidate( _crtheap, 0, pHdr(pUserData) );
I read the docs for HeapValidate and discovered you could set the thrid arg to NULL to force the entire heap to be validated. So I immediately had the idea of sprinkling my own calls to HeapValidate throughout my code to track down the time when I was corrupting the heap. But then I couldn't figure out where to get the symbol _crtheap. I could see it in the debugger, but couldn't find it declared in any headers that came with VC6. So I says to myself, "I'll just hard code the address since surely _crtheap won't change values from run to run." But this caused me problems too. Eventually I figured out that that value of the global symbol _crtheap was changing within a single run! After some additional contemplation, I says to myself, "Perhaps there is more than one heap for my process!" Through additional experimentation, I now believe that my DLL is allocating and freeing memory from one heap, and my application is using another. The above functions cause memory to be allocated in the context of the DLL and freed in the context of the application (and vice-versa).
Voila! Crash!
MY QUESTIONS:
I would like someone to confirm my theorys and perhaps provide me any additional information as to the usage of heaps in DLLs. Does every DLL have its own heap? I currently believe that I must eliminate any interfaces where memory is allocated in one library context and freed in another. What if I changed the signature of my fucntion to:
std::string __declspec(dllexport) getCommandString();
Would this eliminate my problem?
Thanks much,
Matt
|
|
|
|
|
You've got it essentially right. The CRT new /delete operators alloc/free from a heap set up by the CRT. If the DLLs are linked statically to the CRT code, each DLL does its own CRT initialization, thus each gets a different heap.
To alloc memory that's availble to the whole process, use CoTaskMemAlloc() and free it with CoTaskMemFree() . This prevents you from passing a string as a param, however.
--Mike--
Ericahist | CP SearchBar v2.0.2 | Homepage | RightClick-Encrypt | 1ClickPicGrabber
"That probably would've sounded more commanding if I wasn't wearing my yummy sushi pajamas."
-- Buffy
|
|
|
|
|
If I understand correctly, you can only pass string objects to exported functions if the dll was explicitly loaded via LoadLibrary?
|
|
|
|
|
Hi
I have a small app that is included with my main app's. All it does is collet the users feedback and emails the same to me.
When the mod goes to email should I ?
Use my send mail account to carry the mail?
or
Use the cleints email account?
Since send does not require a password either will be easy.
I need some input on this as a friend said if I used my mail server in the U.S. from the other side of the world it might not work.
Best Wishes and Happy Holiday's,
ez_way
|
|
|
|
|
i would prefer using the client's email account. why should u use ur email acc for other users?
Don't try it, just do it!
|
|
|
|
|
Thank you for your input.
Best Wishes and Happy Holiday's,
ez_way
|
|
|
|
|
I too would go 'client side' - as long as it was stipulated somewhere that 'use of this program/xyz requires a working email setup'
I remember writing a commercial email interface for an acquantance, and one of his customers came back and said 'it doesnt work' .. when I received the error log, the customer didnt have the right smtp account at his isp .. groan
'G'
|
|
|
|
|
Yes, I understand. What if I used both, orr let me correct that. If one failed use the other.
If I use my own I know the ports, the authinication,an all the bells and whistles. If it timed out I would know that there is a long hop between the user and my mail server, and grab the default email account from the reg and send it that way.
Best Wishes and Happy Holiday's,
ez_way
|
|
|
|
|
the problem with this, as I see it, is, what if you user has to go through a firewall to get to you ??
I can imagine the smirk (and answer) from our comms team If I said 'Ive got this app that instead of using our mail client set up, wants you to open a port on the firewall for it to speak directly home' ...
See, it depends if you're talking small or large .. in our case, every desktop is going to have a valid mail client - (we use Novell Groupwise), so, we would invoke a 'mailto' - ditto any clients I have that use Outlook, anything Mapi compliant etc ... only in rare circumstances do we allow 'things' to speak direct smtp to our mail server, these are usually automated programs (and they have to traverse an inner firewall to get to the smtp server)
'G'
|
|
|
|
|
That is why I love you guy's! Great Answer! Thanks
Best Wishes and Happy Holiday's,
ez_way
|
|
|
|
|
You don't need an email account to send email.
Take a look PJ Naughter's SMTP software http://www.naughter.com/smtp.html[^]. It will allow you to send the email directly to your email servers without having to go through any email forwarding servers. However, it does mean that your email server will have to be available 24/7 since there is no in between server to retry if the email fails to be delivered.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
Why email? Why not just do an HTTP post to a script running on your server? You could capture a lot more data in an organized manner that way. (Your script can even send a notification message to a tech support address).
/ravi
Let's put "civil" back in "civilization"
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
How to find system information using MFC?
May the Lord bless thee abundantly
|
|
|
|
|
i assume, that u don't know what MFC is when ur posting such a question!
Don't try it, just do it!
|
|
|
|
|
It is a fine question, nothing wrong with it at all. There is however something wrong with the young man who wrote you such an elitist answer as above.
GetSystemMetrics is a handy group of details about your system.
It returns an integer.
The integer can be one of many, here is a couple of examples.
if(GetSystemMetrics(SM_SLOWMACHINE) == TRUE)
m_proslowfast = "this computer has a low-end (slow) processor";
or
int b = GetSystemMetrics(SM_CLEANBOOT);
if(b == 0)// Normal boot
m_strHowBooted = "Normal boot";
else if(b == 1) //Fail-safe boot
m_strHowBooted = "Fail-safe boot";
else if(b == 2)// Fail-safe with network boot
m_strHowBooted = "Fail-safe with network boot";
else
m_strHowBooted.Format("Error: int b = GetSystemMetrics(SM_CLEANBOOT) returned %d",b);
/////////////////////
SystemParametersInfo is also good, it returns a Boolean value.
BOOL SystemParametersInfo(
UINT uiAction, // system parameter to query or set
UINT uiParam, // depends on action to be taken
PVOID pvParam, // depends on action to be taken
UINT fWinIni // user profile update flag
);
You may search for both of these on this website.
Any time you do not understand, email me and we will figure it out. We all need help from time to time!
Best Wishes and Happy Holiday's,
ez_way
|
|
|
|
|
Ez
I commend this reply. I for one am tired of the bitchy attitudes that some of these programmers have in here. Not everyone that comes to this site is a master programmer that has a hotline phone to Bill Gates. It's like they have a prickly pear stuck up their arse.
Great answer. I raise my beer and say HERE HERE!!
Tom Wright
tawright915@yahoo.com
|
|
|
|