|
I just came up with something very similiar except that I had the function at the end.
Good job!
Thanks very much!
C++ Newbian
|
|
|
|
|
Hi there,
Can anyone please provide some insight to the below problem?
I am calling:
const hostent* HostInfo =
::gethostbyaddr((const char*)(&binaryIp), sizeof(binaryIp), AF_INET);
binary ip is the correct local ip of a machine on our network. Instead of returning the machine's name, HostInfo->h_name takes on the "xxx.com" name of our company! Any ideas why this is happening?
Thanks!
[b]yte your digital photos with [ae]phid [p]hotokeeper - www.aephid.com.
|
|
|
|
|
Look at HostInfo->h_addr_list instead.
|
|
|
|
|
Thanks but this doesn't work....
HostInfo->h_name is "simrad.com"
HostInfo->h_addr_list[0] is "xxxsimrad.com", where xxx are some funny accented characters...
Any other thoughts?
[b]yte your digital photos with [ae]phid [p]hotokeeper - www.aephid.com.
|
|
|
|
|
Are you looking at HostInfo->h_addr_list[0] in its "raw" format or are you converting it with inet_ntoa()?
in_addr **ip = (in_addr **) HostInfo->h_addr_list;<br />
TRACE("%s\n", inet_ntoa(**ip));
|
|
|
|
|
The code you gave me TRACE()s out the correct ip address. Unfortunately this is no help, because I already know the ip address. I need to determine the host name from the ip address, which should be a string.
Any other thoughts?
Thanks,
[b]yte your digital photos with [ae]phid [p]hotokeeper - www.aephid.com.
|
|
|
|
|
My bad. I got this thread confused with another one. I'm not a network technician so I don't know what all needs to be in place for DNS translation and NAT to work.
Does this help:
char **p = HostInfo->h_aliases;
TRACE("%s\n", *p);
|
|
|
|
|
No it doesn't... I have looked through the whole HostInfo structure in the debugger, with no luck. Thanks anyways though...
[b]yte your digital photos with [ae]phid [p]hotokeeper - www.aephid.com.
|
|
|
|
|
Try this.. it works for me.
struct hostent *hp;
unsigned int addr;
addr = inet_addr("192.168.1.100");
hp = gethostbyaddr((char *)&addr, sizeof(addr), AF_INET);
MessageBox(hp->h_name);
Hope this helps,
Rob
Whoever said nothing's impossible never tried slamming a revolving door!
|
|
|
|
|
Check your company dns for proper reverse lookup records first.
try nslooup
>set type=PTR
>123.12.12.12
Many places don't bother with PTRs.
Brian
|
|
|
|
|
I don't follow... am I supposed to type that into the command prompt or something?
Thanks.
[b]yte your digital photos with [ae]phid [p]hotokeeper - www.aephid.com.
|
|
|
|
|
Test your dns server reverse lookups. If your dns server set to return junk, junk is what you will get.
nslookup shows dns responses.
|
|
|
|
|
hello
i am making a simple program in c++ and am using a simple class of my
own called item.
i have created a pointer to this node as follows:
pnode = new node;
and then i check if it has been created properly:
if (pnode)
...
the problem is that checking if it has been created doesnt work -
if i get rid of the defining line, the program still thinks pnode is
a valid object, even though if i debug the program the value of pnode
is "0xcccccccc" which i think means null.
i have tried using if (pnode == null) and other things but i cant get
this simple check to work.
this is only a simple 16 line program with a simple winmain function, so
can anybody tell me what im doing wrong?
thank you
|
|
|
|
|
sorry, the class is named node, not item.
|
|
|
|
|
Berkut wrote:
the value of pnode is "0xcccccccc" which i think means null.
No, a NULL pointer has a value of 0. The /GZ compiler option sets uninitialized variables to 0xCCCCCCCC.
Does the node class have a default constructor? Unless you've done something to it, the new operator calls a class's default constructor.
Berkut wrote:
i have tried using if (pnode == null)
This should actually be if (pnode == NULL), or better still if (NULL == pnode)
|
|
|
|
|
DavidCrow wrote:
This should actually be if (pnode == NULL), or better still if (NULL == pnode)
Interesting. Is there an explanation for that?
// Afterall I realized that even my comment lines have bugs
|
|
|
|
|
Both (pnode = NULL) and (pnode == NULL) are syntactically correct, but produce entirely different results. By putting the constant on the left of the operator, the compiler guarantees you don't confuse the '=' and '==' operators!
|
|
|
|
|
That makes sense now. Thank you very much.
// Afterall I realized that even my comment lines have bugs
|
|
|
|
|
When a builtin type (int , pointer, etc.) is used for a stack variable, the variable is not initialized to anything. You cannot assume it will be 0 unless you set it to 0. (NULL is zero, BTW.)
In debug mode, the compiler sets uninitialized variables to 0xCC as a debugging aid - if you see data that's 0xCCCCCCCC and it's supposed to be real data, you know that you forgot to initialize it.
Since you want to test against NULL to check for an initialized pointer, do this:
node* pNode = NULL;
--Mike--
Yeah, payin' the bills with my mad programming skillz.
Defraggin' my hard drive for thrills.
Homepage | RightClick-Encrypt | 1ClickPicGrabber
"You have Erica on the brain" - Jon Sagara to me
|
|
|
|
|
I am writing a database program using ADO and Visual C++.
Let me explain my problem.
m_pConn->Open(L"Provider=Microsoft.Jet.OLEDB.4.0;
Data Source=Inventory.mdb;",
L"", L"", adOpenUnspecified );
...
pRs->Open( _variant_t( bstrQuery ),
vNull,
adOpenDynamic,
adLockOptimistic,
adCmdUnknown );
if( m_pRs->Supports( adDelete ) && m_nNoRows > 1 )
{
m_pRs->Delete( adAffectCurrent );
m_pRs->MoveNext();
if( m_pRs->GetADOEOF() )
m_pRs->MovePrevious();
}
CString strFilter = "vField LIKE 'smth%';
m_pRs->Filter = _variant_t( (_bstr_t)strFilter );
//
After I set the filter and I delete a record, if I try to
move to the previous record (even though the record is not
the first) I get an error which suggests that the row where
I am trying to move is either marked for deletion or has
been deleted. Why? The database supports MovePrevious and
I don't use batch mode. This problem occurs only if I
set a filter. The filter works fine too. It selects only
the records that I want it to select.
// Afterall I realized that even my comment lines have bugs
|
|
|
|
|
Hi:
I'm working on a Custom editbox acivex control,my activex have a property called "R2L Readling"(a Check box).when the user set this property the style of editbox will change to "Right to Left Reading order" at Run-Time,i have used the following code to do this:
////////////////////////////////////////////////////////////
ModifyStyleEx(0,WS_EX_RTLREADING|WS_EX_RIGHT|WS_EX_LEFTSCROLLBAR);
InvalidateControl();
////////////////////////////////////////////////////////////
all things work properly but "WS_EX_LEFTSCROLLBAR" doesn't work !!!
in the other hand the left-scrollbar doesn't appear.please help me.
excuse me for bad comments.english isn't my native language.
Best Regards.
|
|
|
|
|
Not all styles can be changed at run-time. You may need to delete and recreate the control. I really have no idea if WS_EX_LEFTSCROLLBAR is one of those or not. Never used it.
Joel Lucsy
|
|
|
|
|
how to make program appear, each time I boot computer, in system tray (like ICQ)?
|
|
|
|
|
One solution is Shell_NotifyIcon().
Kuphryn
|
|
|
|
|
Thanks for answer. Can you explain me in details what is Shell_NotifyIcon() and how use it.
|
|
|
|