|
You could try looking at gethostbyname.
- Aaron
|
|
|
|
|
Aaron
i cannot get that to work..
GetHostAddress("http://www.coderproject.com");
unsigned long DialogClass::GetHostAddress(LPCSTR host)
{
struct hostent *phe;
char *p;
phe = gethostbyname(host);
p = *phe->h_addr_list; // Crash here
return *((unsigned long*)p);
}
any ideas ?
|
|
|
|
|
Try changing:
p = *phe->h_addr_list; to
p = *phe->h_addr;
- Aaron
|
|
|
|
|
Didn't compile it so it may have type-o's...
struct hostent *hp;
unsigned int addr;
struct sockaddr_in name_ip;
if(inet_addr(strDns) == INADDR_NONE)
hp = gethostbyname(strDns);
else
{
addr = inet_addr(strDns);
hp = gethostbyaddr((char *)&addr, sizeof(addr), AF_INET);
}
if(hp == NULL)
{
}
name_ip.sin_addr.s_addr = *((unsigned long*)hp->h_addr);
name_ip.sin_family = AF_INET;
name_ip.sin_port = htons(iPort);
CString strSocketIP = inet_ntoa(name_ip.sin_addr);
Rob
Whoever said nothing's impossible never tried slamming a revolving door!
|
|
|
|
|
Rob,
thanks for that
but
in flow of execution
strDns = "www.codeproject.com";
hp = gethostbyname(strDns); executes fine
name_ip.sin_addr.s_addr = *((unsigned long*)hp->h_addr); // crash occurs
name_ip.sin_family = AF_INET;
name_ip.sin_port = htons(iPort);
any ideas?
|
|
|
|
|
i am using winsock 1.1
if that might be a problem
in the struct hostent *hp;
i only have the following members:
hp->h_addr_list
hp->h_addrtype
hp->h_aliases
hp->h_length
hp->h_name
i do not have a hp->h_addr member
|
|
|
|
|
I'm not 100% sure, I have only had experence in WinSock2.. you may lookup gethostbyname in google or msdn and see if you can find any Winsock 1.1 examples.. you could snoop through the articles here too.. I'm sure it can't be too hard.
If you still have problems let me konw and I'll see what I can find.
Rob
Whoever said nothing's impossible never tried slamming a revolving door!
|
|
|
|
|
I just did a google search and found this right off the bat...
The macro h_addr is defined to be h_addr_list[0] for compatibility with older software.
Rob
Whoever said nothing's impossible never tried slamming a revolving door!
|
|
|
|
|
I have a tree control inserted, in which I assigned an imagelist.
When I insert some items, some of them have images assigned to them, even if I don't assign one to them.
This is how I insert my Item in the tree :
TVINSERTSTRUCT tv;
tv.hParent = m_hRootItem;
tv.hInsertAfter = TVI_SORT;
tv.item.mask = TVIF_TEXT | TVIF_PARAM;
CString sText;
sText.LoadString ( IDS_OBJECT_CONSTRUCTED );
tv.item.pszText = (LPTSTR)(LPCTSTR)sText;
tv.item.lParam = NULL;
m_hMyItem = InsertItem( &tv );
but this item use the an image ( index 0 ) from the image list, even if the item does not have the TVIF_IMAGE and TVIF_SELECTEDIMAGE ...
any insights ?
Thanks.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
Try fully initializing tv by doing this:
TVINSERTSTRUCT tv;
ZeroMemory (&tv, sizeof (tv));
...
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
Thanks, I always forget about that, but, it doesn't seem to do anything special, the item will use the first image in the image list; maybe the tree doesn't like to have items with images and items without.
anyway, I created an "empty" image in the imagelist for those items .
Thanks!
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
Hi Maximilien, when your tree control has an associated image list (as your does), you need to specify -1 for the image index of items that aren't supposed to show an image.
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
|
during execution of the debug build of my .exe I keep getting this in the debug window ( a lot of them):
Warning: no message line prompt for ID 0x800B.
I removed some edit boxes from my dialog, but I also deleted the message map entries for these controls and their variables. Does anyone know what this might be, or how I can find out? Thanks in advance!!!
If it's broken, I probably did it
bdiamond
|
|
|
|
|
It is likely that you have missed the prompt for menu item(s) that you have added (in the resource editor).
These prompts show in the status bar at the bottom of the application when you hover over the menu item(s).
Note: Toolbar items will have the same prompt as their corresponding menu items.
Ant.
|
|
|
|
|
and how do we do to display such promt in the status bar ?
(i know, get the string into the string table, then write it in the correct statusBar Pane...)
But how, could you give me some short code lines (mt problem is more to get smth in the string table actually)
thanks
TOXCCT >>> GEII power
|
|
|
|
|
CString::LoadString
Be sure that resource exist in the string table
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
thanks! that helped a lot!!
If it's broken, I probably did it
bdiamond
|
|
|
|
|
I want to modify the net-data pacekts before they are passed to the applications. can raw socket or winpcap do?
someone said that SPI can do. but it is only for winsock 2. i hope it also work for the lower version winsock such as winsock 1.1.
Thanks.
|
|
|
|
|
Hi There!. I am a newcommer in MFC programming.
How does one parse parameters passed as command line arguments in the Win32 environment? I know i can use lpCmdLine, but how do i do that? Can someone show me an example. By the way I am useing Embedded Visual c++
|
|
|
|
|
The lpCmdLine parameter is an exact copy of the command line passed to your program, including all spaces, quote marks, etc. If you want to treat this as separate arguments, you must split it.
MFC supplies its own WinMain by default; however, you can override this if you wish. If you do so, call AfxWinInit to initialize MFC, and AfxWinTerm before returning. The MFC WinMain is implemented in winmain.cpp .
It's rare to do this. Typically, you instead override InitInstance in your class derived from CWinApp . You can then access the command line from CWinApp 's m_lpCmdLine parameter.
MFC offers the CCommandLineInfo class and the ParseCommandLine function for helping with command lines. To add support for your own options, create a new class which inherits CCommandLineInfo . Then override ParseParam .
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
Thanks.
lpCmdLine is a unsigned short *.
The value i passed in the command line is just a BYTE (0-15). How can i convert lpCmdLine to a BYTE?
Gunnar
|
|
|
|
|
Whether the command line contained one byte or several dozen, lpCmdLine is accessed in the same manner for each. It's simply a pointer to the command-line arguments.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
How should the following be declared
class A
{
public:
B test;
};
class B
{
public:
A test;
};
I thought you just pre-declared class B before class A using the following line:
class B;
What am I doing wrong?
Systems AXIS Ltd - Software for Business ...
|
|
|
|
|
You are declaring class A, that contains a member of class B, that contains a member of class A, that contains.....ad infinitum
Declare the test member as a pointer to class A or B.
Robert-Antonio
"Love without sex is like a fish without antlers"
|
|
|
|