|
How to find the DNS that is configured using C++?
|
|
|
|
|
Just how is it that you know the DNS server was configured using C++?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Does GetAddressByName() with NS_DNS namespace give you the addresses you're looking for?
Mark
|
|
|
|
|
hi
CDib is a class which will be used in iamge processing.i read otherwise project, it uses CDib class name, but its corresponging source and head file names are dib.cpp and .h. I would like to know how to realize this. thank you.
whitesky
Li Zhiyuan
22/10/2006
|
|
|
|
|
li zhiyuan wrote: I would like to know how to realize this. thank you
Three posts about the same topic? Why not reply back to one of the people that have tried to help you already?
Your posts are very confusing, what do you want to do with the aforementioned files?
I take it you have two files you would like to rename?
dib.cpp & .h (which isn’t a valid file name)
Going out on a limb it almost sounds like you wan to rename those files to cdib.cpp & cdib.h? Why would you want to do that? Most Coding conventions separate Class name from the file name (mostly to easily distinguish the two).
I'd love to help, but unfortunatley I have prior commitments monitoring the length of my grass. :Andrew Bleakley:
|
|
|
|
|
Same question.You aksed yesterday
|
|
|
|
|
hi!
Could you please recommend some c++ library for networking tasks? I tried BOOST.ASIO, but it is only at the development stage, and IMO there are many bugs there.
thanks!
|
|
|
|
|
oldbam wrote: some c++ library for networking tasks?
http://thefreecountry.com/sourcecode/sockets.shtml[^]
_________________________
Asu no koto o ieba, tenjo de nezumi ga warau.
Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb)
|
|
|
|
|
|
|
Hi,
I want to know my local ip address. I am on a local area network. I have used the following code:
char* hostName=new char[255];
if(::gethostname(hostName,255)==0)
{
hostent* localhost=::gethostbyname(hostName);
ULONG ip=inet_addr(*(localhost->h_addr_list));
in_addr localaddr;
localaddr.S_un.S_addr=ip;
char* localIP=inet_ntoa(localaddr);
CString localAddress(localIP);
AfxMessageBox(localAddress);
}
It always give the 255.255.255.255 as my local address. Can anybody tell me
how to get my own IP. I dont want to use iphelp or any other advanced APIs.
Regards,
Wasif.
|
|
|
|
|
Assuming that you have only one network interface (your eth card) and a loopback interface (127.0.0.1), i think you could try to get the name of the local computer, and then resolve it in an ip address .
<br />
char szMyComputerName[0xFF] = {0},<br />
szMyIpAddress[0xFF] = {0};<br />
DWORD dwSize = 0xFF;<br />
<br />
::GetComputerName(szMyComputerName,&dwSize);<br />
Now all you have to to is to resolve 'szMyComputerName' as you did in your example .
Naturally, if you have more than one network interface (eth card, wireless, etc), you have to enumerate them and then you choose the one you want to work on :
<br />
SOCKET sd = WSASocket(AF_INET, SOCK_DGRAM, 0, 0, 0, 0);<br />
<br />
INTERFACE_INFO InterfaceList[20];<br />
unsigned long nBytesReturned;<br />
<br />
WSAIoctl( sd, SIO_GET_INTERFACE_LIST, 0, 0, &InterfaceList, sizeof(InterfaceList), &nBytesReturned, 0, 0); <br />
<br />
for( int i = 0; i < nBytesReturned / sizeof(INTERFACE_INFO); i++ )<br />
{<br />
printf( "Interface[%d] : %s\n",i, inet_ntoa( ((sockaddr_in *)&(InterfaceList[i].iiAddress))->sin_addr ) )<br />
}<br />
Hope i helped ....
|
|
|
|
|
wasife wrote: ULONG ip=inet_addr(*(localhost->h_addr_list));
in_addr localaddr;
localaddr.S_un.S_addr=ip;
char* localIP=inet_ntoa(localaddr);
replace ur code above with line below:
char* localIP=inet_ntoa(*(LPIN_ADDR)*(localhost->h_addr_list));
It should be work, but I can't tell why ur code doesn't.
wish this could help!
|
|
|
|
|
Try this (works on my machines)
char* hostName=new char[255];
if (0 == ::gethostname(hostName, 255))
{
HOSTENT *pHostent = ::gethostbyname(szTempName);
if (pHostent && pHostent->h_addrtype == AF_INET)
{
in_addr inaddr = *(in_addr *)(pHostent->h_addr_list[0]);
char *pAddStr = ::inet_ntoa(inaddr);
if (pAddStr)
{
AfxMessageBox(pAddStr);
}
}
}
|
|
|
|
|
struct x{<br />
int a;<br />
int b;<br />
int c;<br />
}str;<br />
<br />
void main(void){<br />
size_t distance; <br />
<br />
distance = offsetof(str,a);<br />
printf("Offset of x.c is %lu bytes\n",(unsigned long)distance);<br />
<br />
exit(EXIT_SUCCESS);<br />
}<br />
<br />
<br />
<br />
i tried to test to debug the source code but it is syntax error : ')'
so anyone can solve this problem for me?
~~~@@@###EZRA###@@@~~~
|
|
|
|
|
//try this
struct x
{
int a;
int b;
int c;
};
size_t distance;
distance = offsetof(x,a);
printf("Offset of x.a is %lu bytes\n",(unsigned long)distance);
distance = offsetof(x,b);
printf("Offset of x.b is %lu bytes\n",(unsigned long)distance);
distance = offsetof(x,c);
printf("Offset of x.c is %lu bytes\n",(unsigned long)distance);
// or this
typedef struct x
{
int a;
int b;
int c;
} str;
size_t distance;
// Either str or x can be used as they are the same type here
distance = offsetof(x,a);
printf("Offset of x.a is %lu bytes\n",(unsigned long)distance);
distance = offsetof(str,b);
printf("Offset of str.b is %lu bytes\n",(unsigned long)distance);
distance = offsetof(x,c);
printf("Offset of x.c is %lu bytes\n",(unsigned long)distance);
|
|
|
|
|
EzraYap wrote: ...but it is syntax error...
Where? What error?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
I'v a problem with Insert function. My insert function works for integers but it doesnot work for strings. Although the logic would be same as for integers. Does it goes wrong when you rplace an integer data with string data??
I am not using recursion for it. As there is problem in using recursion.
I am a mere beginner so I m not even using templates as I'v not studied them yet. I work in Visual C++. And my complier is Microsoft Visual C++ 6.0.
Pimra
|
|
|
|
|
|
Hi,
I'm having a problem when I build projects in Visual C++ 2005. Although it's not important, this particular program is a simple VST plugin for audio. The problem is, I can build the program fine the first time, getting this result in the output panel:
1>------ Build started: Project: VST_Plug_in, Configuration: Debug Win32 ------
1>Linking...
1>LINK : c:/temp/VST/PIL_Panner.dll not found or not built by the last incremental link; performing full link
1> Creating library .\Debug/VST_Plug_in.lib and object .\Debug/VST_Plug_in.exp
1>Embedding manifest...
1>Build log was saved at "file://c:\Documents and Settings\Michael_\Desktop\Programming In Windows\VST_plug_in_auto_pan\VST_plug_in_auto_pan\VST_plug_in\VST_Plug_in\Debug\BuildLog.htm"
1>VST_Plug_in - 0 error(s), 0 warning(s)
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
But when it comes to building the project again when I change something (and even if I haven't changed anything!) I get these errors:
1>------ Rebuild All started: Project: VST_Plug_in, Configuration: Debug Win32 ------
1>Deleting intermediate and output files for project 'VST_Plug_in', configuration 'Debug|Win32'
1>Compiling...
1>VST_Plug_in.cpp
1>d:\visual c++\vc\include\string.h(74) : error C2733: second C linkage of overloaded function 'strcpy_s' not allowed
1> d:\visual c++\vc\include\string.h(74) : see declaration of 'strcpy_s'
1>c:\documents and settings\michael_\desktop\programming in windows\vst_plug_in_auto_pan\vst_plug_in_auto_pan\vst_plug_in\vst_plug_in\vst_plug_in.cpp(34) : warning C4244: '=' : conversion from 'double' to 'float', possible loss of data
1>audioeffect.cpp
1>d:\visual c++\vc\include\string.h(74) : error C2733: second C linkage of overloaded function 'strcpy_s' not allowed
1> d:\visual c++\vc\include\string.h(74) : see declaration of 'strcpy_s'
1>audioeffectx.cpp
1>d:\visual c++\vc\include\string.h(74) : error C2733: second C linkage of overloaded function 'strcpy_s' not allowed
1> d:\visual c++\vc\include\string.h(74) : see declaration of 'strcpy_s'
1>vstplugmain.cpp
1>d:\visual c++\vc\include\string.h(74) : error C2733: second C linkage of overloaded function 'strcpy_s' not allowed
1> d:\visual c++\vc\include\string.h(74) : see declaration of 'strcpy_s'
1>Generating Code...
1>Build log was saved at "file://c:\Documents and Settings\Michael_\Desktop\Programming In Windows\VST_plug_in_auto_pan\VST_plug_in_auto_pan\VST_plug_in\VST_Plug_in\Debug\BuildLog.htm"
1>VST_Plug_in - 4 error(s), 1 warning(s)
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========
This problem occurs in several projects - they build fine the first time, then fail the second. I'm not sure what is causing this problem, at a guess it'd be "'Deleting intermediate and output files for project 'VST_Plug_in', configuration 'Debug|Win32'" but then again I'm a beginner so I wouldn't really know. As you can see from the errors, the program has a problem with the strcpy_s function when rebuilding again but I'm not sure why.
If anybody can help it'd be appreciated - it's probably something pretty simple that I'm missing.
thanks,
Michael
|
|
|
|
|
Hi,
It looks like a CRT conflict, perhaps caused by using two different versions of CRT libraries (or headers) in the same scope. For instance, your plugin might have been set to use the static CRT library, while the VST libraries would use a CRT DLL (or the other way round).
You may try to modify this setting under Project Properties at C/C++/Code Generation/Runtime Library.
Usually, you need to have the same code generation / language settings throughout the whole project.
|
|
|
|
|
Hi,
I use a progress bar control and I want to change the drawing color of the progress line, I tried to write as follows but it didnt work:
m_ctlProgress.GetDC()->SelectStockObject(BLACK_BRUSH);
any ideas??
Mohammad
And ever has it been that love knows not its own depth until the hour of separation
|
|
|
|
|
Is this helpful
<br />
m_ctlProgress.SendMessage(PBM_SETBARCOLOR,0,RGB(210,20,120));<br />
m_ctlProgress.SetBkColor(RGB(0,0,0));<br />
|
|
|
|
|
Thanks pal,
You gave me the right answer, and it should work perfectly... but the problem is that I am targeting Windows ce, and this message is not supported under that platform!!!
any other ideas???
Thanks again
Mohammad
And ever has it been that love knows not its own depth until the hour of separation
|
|
|
|
|
If it doesnt helpful for you did you search about it on codeproject if you search I think you can find your problem
|
|
|
|