|
Hello Everyone,
I am doing some looking-up of DNS information with the DnsQuery API function. I can recieve A, MX & SOA Fields perfectly from any given hostname.
When I call DnsQuery_A with a wType of DNS_TYPE_LOC, the call succeeds, but I have no way to get the information I need since the Data union in the DNS_RECORD structure returned by the call has no DNS_LOC_DATA structure defined. I have tried casting the union to a DNS_LOC_DATA but I get invalid data.
Could somone point me in the right direction, I have been searching around for most of the day and I can't find any examples of the DNS_LOC_DATA struct in use, and MSDN also doesn't provide any information that is of use.
Thanks For Any Help!
Robert Heffernan
Albury, NSW
My Code Requesting A Field Data
<br />
dsRet = DnsQuery_A(ndDns->cHostname, DNS_TYPE_A, DNS_QUERY_STANDARD, NULL, &drRecords, NULL);<br />
<br />
if(dsRet != NOERROR)<br />
return FALSE;<br />
<br />
My Code Requesting LOC Field Data
<br />
dsRet = DnsQuery_A(ndDns->cHostname, DNS_TYPE_LOC, DNS_QUERY_STANDARD, NULL, &drRecords, NULL);<br />
<br />
if(dsRet != NOERROR)<br />
return FALSE;<br />
<br />
dlLoc = (DNS_LOC_DATA *)&drRecords->Data;
|
|
|
|
|
hi,
I have got an IMDB(In Memory Database) file, and i want to read that data from that file and copy that into database SQL or file using c++. any help?
If this is not the correct forum to ask this question, then i am extremely sorry for that.
Warm Regards,
Mushq
|
|
|
|
|
You question is way too big to answer in a sentence or two. Break your problem up into several smaller ones. Which part are you needing help with?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
In my Dialog (C++) application I kept getting an exception with the following code, define a strucure and creat a memebr variable of Type as per that stucture.
typedef struct <br />
{<br />
CString Name;<br />
CString rxChannel;<br />
CString txChannel;<br />
bool rxChannelDefined;<br />
bool txChannelDefined;<br />
}ACONFIGDATA;
But I got an exception (Bad Prt) when I did:-
m_As[Index].txChannel = chanData;
chanData is a CString.
However if I define the structure as follows:-
typedef struct <br />
{<br />
char Name[40];<br />
char rxChannel[3];<br />
char txChannel[3];<br />
bool rxChannelDefined;<br />
bool txChannelDefined;<br />
}ACONFIGDATA;
And use the following statement, all is fine.
strcpy_s(m_As[Index].txChannel, chanData);
I just want to understand how the exception was caused, please.
|
|
|
|
|
Can you show how you have declared m_As and using it ? Something other than metnioned code might cause problem ?
|
|
|
|
|
Declared as
ACONFIGDATA m_As[256];
But when inspected (via breakpoint) all the CStrings were Bad Prts
|
|
|
|
|
Code seems to be harmless, unless, you are accessing invalid index(out of bounds).
|
|
|
|
|
The index was in range so not that prblem.
|
|
|
|
|
May be you can mail across code. Cant figure out your problem from given info.
|
|
|
|
|
Which object threw the exception - the m_As object or the chanData string variable?
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
When ever I tried to set any of the CString fields;
e.g. m_As[2].txChannel= "13";
The bool fields were OK, just the CString fields; all Bad Pointers!
|
|
|
|
|
If you're using VS2005, try changing your project's properties to use the multi-byte character set.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
hi,
i add a section for my exe file. in my section, i need to create a thread.
because my code in this section is with assembly language in asm block then, i call address of CreateThread api function to create my thtead, and before call, i push necessary parameters. i push address of myThreadFunc lable.
my exe is executed and my tread is created but "don't send" error appears.
is an example or article for my problem?
Zo.Naderi-Iran
|
|
|
|
|
Would this help?
http://win32assembly.online.fr/tut15.html
|
|
|
|
|
thank you , this article was useful for me.
i call PostMessage api function end of myThreadFun.
Zo.Naderi-Iran
|
|
|
|
|
you are welcome
btw, if you didnt check the page; http://win32assembly.online.fr
Iczelion page is great...
|
|
|
|
|
In a vector are stored class pointers;
<br />
class sample1 : public mybase<br />
{<br />
}<br />
<br />
vector<sample1*> vec;<br />
I would like to cast it;
<br />
vector<mybase*> *result = (vector<mybase*>*)&vec;<br />
I got a response previously that it is not possible, but i dont understand why.
Actually i am not sure this is a problem for my core dump.
I have been thinking about; if i have pointer stored inside vector, at the end it
is stored as address to something and the address is the same size in any case. So
if i cast it, there should be no changes, but i still got a core dump (it works for
instance in 20 cases, but then one crashes).
Can someone enlighten me what is wrong (or it is correct and i have problem somewhere else?)?
Thank you...
|
|
|
|
|
It's possible but perverse. Technically there is a chance it will be dangerous; for example an explicit specialisation could make the construct unsafe. In practice it could be made to work however.
There is no need to even think about such perversions in your case; a pointer to a derived class can be implicitly cast to a base type. Just use your sample1* s as if they were mybase* s and don't have any casts at all.
Steve
|
|
|
|
|
Why i need it;
http://www.codeproject.com/script/comments/forums.asp?msg=1841069&forumid=1647#xx1841069xx
What i am doing;
i am storing pointer to a vector inside some dispatch table that is stored in a base class for any class i am using.
vector holds further pointers to classes
pointer to vector is stored as void* (to avoid adding #includes to library that i wrote as generic), so i need to
cast it to vector but as i dont have #include to stored class definition the only thing i can cast it to is baseclass*.
when i want to gather its data, i call function in that base class that takes vector pointer
and casts it to vector<baseclass*>*, then i iterate through those class pointers and
gather their data,...
in that process i dont manipulate its content i am just reading what is stored inside and call
stored class* functions.
Unfortunally somewhere in (large and hard to handle) class structure some vector is annoying me
as:
<br />
+ _STL::_Vector_base<serClass *,_STL::allocator<serClass *> > {_M_start=0xcccccccc _M_finish=0x00579264 const serIO::`vftable' _M_end_of_storage={_M_data=0x010cf778 } } _STL::_Vector_base<serClass *,_STL::allocator<serClass *> ><br />
_M_start=0xcccccccc and it crashes.
before that the same freaking code is called around 20 times and it works without any problem.
Whole thing is going on in two processes, sending large class structures via sockets from one to another and vice versa, and is hell to trace so i am trying to theoretically find a problem
-- modified at 3:21 Monday 15th January, 2007
|
|
|
|
|
yeti11 wrote: I have been thinking about; if i have pointer stored inside vector, at the end it
is stored as address to something and the address is the same size in any case. So
if i cast it, there should be no changes, but i still got a core dump (it works for
instance in 20 cases, but then one crashes).
I am not sure what you are trying to accomplish, but if a vector is auto-expanding, any pointers would no longer relate to the current location in memory. This is one reason why pointers are discouraged with STL, and even iterators have to be used cautiously. Both an advantage and disadvantage, STL automatically allocates, and reallocates memory to extend itself.
The iterators/pointers will be valid only as long as the size of the vector remains the same, when you add to the vector, depending on its current size, it could expand to fit the new information, and change memory location.
http://groups.google.com/group/comp.lang.c++/browse_thread/thread/d6fa8209e754aab9/11c794375a7bd8a3%2311c794375a7bd8a3[^]
_________________________
Asu no koto o ieba, tenjo de nezumi ga warau.
Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb)
|
|
|
|
|
I will try to explain it in an answer to Stephen Hewitt, please check it there...
|
|
|
|
|
You can't convert a vector<sample1*>* to a vector<mybase*>* because those two types are not in a base-derived relationship. It's that simple. It doesn't matter what type is contained in the vector.
As has already been stated, the right way is to remove the cast and do the conversion to mybase* on the individual elements as you access them.
|
|
|
|
|
The simple things are where the hell hides
Can you please tell me why? Pointer is a pointer however you turn it... sure if it is object i
understand the reason, but the question is what is the problem if i use it as pointer? Or rather
the question is understanding...
As far as i understand, the only difference between vector<bla*> and vector<some*> is
in casting on [] or at(). And if "bla" is derived from "some" the cast is not a problem.
btw, concerning casting; i simply cant do it other way, at the point where i am needing the cast
i am asking for i have no idea what type is stored inside, the only thing i do know is what is
base class. i dont want to loose general usage of library and coupling it with like 15 classes
that have nothing to do with it and... well it would be a mess.
(i am sorry, i dont want to be annoying but i am not bible kind of guy (god said; thou shall not
cast vectors) i want to understand what i am doing wrong and why.)
|
|
|
|
|
yeti11 wrote: i dont want to loose general usage of library and coupling it with like 15 classes
that have nothing to do with it and... well it would be a mess.
Not necessarily. You can hide the 15 classes within design patterns based on construction and/or behavior as appropriate to the 15 classes. The example given in Wikipedia is a very common one for a bridge, every object class for computer drawing has a "draw" function, at the far end the draw() is generic, you don't care what is being drawn, the information held within allows you to draw almost any shape and add more shapes.
http://en.wikipedia.org/wiki/Bridge_pattern[^]
look at the C++ code for drawing Circles and Squares from the same "shape" class. Is this the type of generic bridge you are trying to accomplish?
yeti11 wrote: i want to understand what i am doing wrong and why
without actually seeing your code, I can't tell you where the error lies for sure. The design via pointers is dangerous because of the STL habit of automatically changing its memory structure. Also pointers are not always held constant between threads, depending on when the pointers are built, and assigned the memory may not be shared between threaded operation calls.
Which brings us back to generic classes to hide implementation. Bridges or Composites[^] and building with other abstraction classes such as Builder[^]
Take a look through the gang-of-four Design Patterns[^] and see if one of those is what you are trying to achieve.
_________________________
Asu no koto o ieba, tenjo de nezumi ga warau.
Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb)
|
|
|
|
|
In class constructors all the variables that i want to have (de)serializable are stored in
a form &m_variable (+type) and then stored in dispatch table as void* (!)
When i call serialization over whole class hirarchy, the only thing i have is void* (!) so
if i want to do anything, i NEED to cast it to something.
At the time of serialization, there is nothing that would shrink/grow array.
I have ways of solving it with redesign, thank you everyone for trying to help, but if i
would want that, i would already do it. Unfortunaly no one is talking about the question;
What is wrong with casting vector holding pointers?
I'll try to reexplain my point; if vector is holding pointers to whatever, it can be casted
as nothing is changed internally (look on template as on freaking macro). in any case holding
WHATEVER pointer, the internal storage per "record" is size of pointer (, address, 4 bytes on
32 bit machine, in memory it is the same).
Please can someone think about what i am saying?
(multithreading is far outside this topic, the problem is not thread related)
|
|
|
|
|