|
Thanks for some suggestions. I'm not certain how to implement all of them.
Member 754960 wrote: - properly handle the case of WinHttpQueryDataAvailable failure.
Are you talking about missing a return false; ? I can add that in, but I actually get a response, dwSize 753, so I don't think that's the problem.
Member 754960 wrote: - verify that m_strResponse is valid before you attempt to concatinate to it.
How would I validate m_strResponse?
|
|
|
|
|
AFAICS, on WinHttpQueryDataAvailable failure dwSize is undefined; it may be 0; it may be junk. You haven't indicated if that call failed or not. In that case, it is not clear what awful behavior happens if you then call WinHttpReadData. Why waste time chasing phantom cases? Just remove the bogus pathway.
Unless you are using the debugger to examine dwSize, I don't see it being output anywhere. I have to wonder what the difference is between dwSize and dwDownloaded. What is supposed to happen when they are different?
The symptom you report is that an often used operation of a common type generates an exception. The object is a class member that is neither initialized or reset in the function that generates the exception. You might want to examine how this object is used before the call to the function. Is it being locked? Is there a call to GetBuffer/ReleaseBuffer? etc.
You should be able to trace into the CString class and determine the exact cause of the exeption.
|
|
|
|
|
hmmmn
There is this line of code called several lines above:
if ( WinHttpWriteData( hRequest, (void*)m_strXMLMessage.GetBuffer(0), m_strXMLMessage.GetLength (), &dwBytesWritten) )
and no corresponding ReleaseBuffer.
Looking into that...
man, I'm getting cross-eyed. that was m_strXMLMessage and not m_strResponse, which doesn't have a GetBuffer call.
modified on Thursday, March 27, 2008 5:27 PM
|
|
|
|
|
Hi, here's my problem:
I have a pointer to a struct (in C++, using VC++ .NET 2005 with MFC). The struct has been allocated from heap memory and contains many fields that are also allocated from the heap (character arrays, etc).
How can I copy this straight to another struct?
These are the two things I've tried, neither have worked:
This is where oldData is a pointer to a MyStruct that has been allocated from the heap:
struct MyStruct *newData = new MyStruct;<br />
memcpy(newData, oldData, sizeof(struct MyStruct));<br />
memcpy(oldData, newData, sizeof(struct MyStruct));<br />
delete newData;
And:
struct MyStruct newData;<br />
newData = *oldData;<br />
oldData = &newData;
Neither of these methods work. Is there a way to do this or do I have to copy field by field with the proper memory allocations in newData etc?
Thanks!
KR
|
|
|
|
|
It seems like it works if I copy all of the character arrays and heap allocated data separately and then do a memcpy on all the rest. Let me know if anyone knows a better way, please!
Thanks!
KR
|
|
|
|
|
KellyR wrote: Neither of these methods work.
No surprise there, since memcpy() has no way of getting to that other heap data. It only knows about the data in the MyStruct structure.
KellyR wrote: Is there a way to do this or do I have to copy field by field with the proper memory allocations in newData etc?
I would implement an assignemnt operator in the structure:
const MyStruct& operator=( const MyStruct &b )
{
...
return *this;
}
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hi!
How can I realize whether a certain process is running or not?
(I mean the simplest way)
|
|
|
|
|
Usef Marzbani wrote: (I mean the simplest way)
thanks for clarifying that because normally I always look for the most difficult way to do things.
This is the simplest way[^] I know of.
led mike
|
|
|
|
|
Well, who wants to know. Another Process? The Same Process, Why?
Version 1.
I did something years ago like this as follows. It assumes that the name of the Exe was not changed, and that we know where it lives. First try to get the File Attributes. If that works, you know the file exists, and that it still lives were you expected it. Now try to change the Name (to it's own Name). This will fail if it's in use. An exe is typically in use when it's running. (Also ofcourse if someone just opened it in a Binary Editor, but most end users don't have those things anyways).
That's simple, but hardly robust.
Version 2.
As soon as your process starts, create a Globaly Named Object (Mutex, Semaphore) but do not claim exclusive ownership, unless if you want to ensure that only one copy runs at anyone time. To determine later whether the process is running, try to create the same Globaly Named Object, but now with exclusive access. This will fail if the object already exists ( i.e. the process is running).
Version 3.
Read Matt Pietrecks dissertations, and spelunk into the inner workings of the Kernel.
Bram van Kampen
|
|
|
|
|
i have a console apllication *.cpp i am using VC++ 6.0 can any one help be by telling how to import only a *.DLL file step by step
Ahmad Sabry
|
|
|
|
|
If you have the "LIB" file of your DLL, just open the work space (or solution explorer in VS 2005), right click on your project name and add the LIB file.
this way is called "static linking".
else you can use "LoadLibrary()" API, defining the path and name of the DLL.
The second way is called "dynamic linking".
In the second alternative, you must use "GetProcAddress()" API to use functions exported from DLL.
Any way, why don't you use MSDN.
|
|
|
|
|
This will depend on DLL which you wanna use.
Pleas specify more details.
|
|
|
|
|
I realy need to know how can I change alignment in an edit box in run time (I am using MFC).
|
|
|
|
|
Usef Marzbani wrote: I realy need to know how can I change alignment in an edit box in run time
They hide that information in the documentation[^]
led mike
|
|
|
|
|
You know, if Microsoft keeps hiding stuff the way they do, someone is going to need to put together some type of repository where we can get to it all. Sort of a "developer network" type of thing.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Great idea David! But shouldn't you have posted it in the Suggestions forum?
led mike
|
|
|
|
|
void Serialize(CArchive &ar)
{
if (ar.IsStoring()) {
} else {
}
}
Any easy way to do this?
|
|
|
|
|
Short answer: Depends.
The CArchive represents only one file - it doesn't even have to represent a file, it could be a stream, etc.
Do you have one document, but the data in it should be saved into multiple files? Then don;t use the CDocument::Serialize method (I never do!), override the CDocument::OnOpenDocument method instead (and its corresponding save method).
You can then save / load however you like!
"Easy" will depend on just what you want to achieve.
Iain.
Iain Clarke appears because CPallini still cares.
|
|
|
|
|
If you really need to store multiple file into yor unique one, you have to copy every file content (possibly each one prefixed by its length).
You may wrap this behaviour into a serializable class (you may call it CFile , oops, no, wait a moment...).
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
I'm getting a strange error...
if I write:
if (uType == ANNEAL)
{
CAnneal * pOrigAnn = dynamic_cast<CAnneal *> (pOrigItem) ;
if(pOrigAnn != NULL)
{
CAnneal * pAnneal = new CAnneal();
}
...
Everything's fine. But, if I want to use a case instead of an if
switch (uType)
{
case ANNEAL:
CAnneal * pOrigAnn = dynamic_cast<CAnneal *> (pOrigItem) ;
if(pOrigAnn != NULL)
{
CAnneal * pAnneal = new CAnneal();
}
break;
case WHATEVER:
...
I get an error that says "initialization of 'pOrigAnn' is skipped by 'default' label" ... "See declaration of pOrigAnn"
|
|
|
|
|
Beacause you've not included your code inside a block and pOriginAnn is the whole switch block (while its assignment happens only in ANNEAL case.
You may change it to
switch (uType)
{
case ANNEAL:
{
CAnneal * pOrigAnn = dynamic_cast<CAnneal *> (pOrigItem) ;
if(pOrigAnn != NULL)
{
CAnneal * pAnneal = new CAnneal();
}
}
break;
case WHATEVER:
...
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
Interesting...
Thank you!!
|
|
|
|
|
Hi,
So you got the problem..
Thanks,
Suman
|
|
|
|
|
Hi,
Is there any other access of "pOrigAnn" outside of "case ANNEAL" like:
piul wrote:
switch (uType){
case ANNEAL:
CAnneal * pOrigAnn = dynamic_cast<CAnneal *> (pOrigItem);
if(pOrigAnn != NULL){
CAnneal * pAnneal = new CAnneal();
}
break;
case WHATEVER:...
...
break;
default:
...
}
//access pOrigAnn
or somewhere else?
Thanks,
Suman
|
|
|
|
|
Hello everyone,
A little confused after reading C++ FAQ, "Why doesn't delete zero out its operand?"
http://www.research.att.com/~bs/bs_faq2.html#delete-zero
I think the reason why delete can not zero out its operand is because delete can be operate on rvalue, like
delete f(x);
And we can not assign zero to the rvalue (i.e. delete's operand). My understanding correct?
thanks in advance,
George
|
|
|
|