|
Thanks for replying.
But your code retrieves only one IP address. What about IP addresses associated to other network cards?
Sincerely,
Allad
----
Navigator - Your best alternative to Windows Explorer
|
|
|
|
|
Doh! My fault. Then I'm not sure. The function I sent you was the BSD style socket/net API. You need to look at the native Win32 APIs for that - I think what you want to look for is functions to enumeration network connections. Look up WSA, and functions that have Enum in their name.
¡El diablo está en mis pantalones! ¡Mire, mire!
Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
SELECT * FROM User WHERE Clue > 0
0 rows returned
Save an Orange - Use the VCF!
|
|
|
|
|
The best way to grab a list of all the ip addresses attached to your local system is using the IPHelper[^] library. You'll need to include the IPHlpApi.h and winsock2.h header files, then add iphlpapi.lib and ws2_32.lib to your list of import libraries.
MIB_IPADDRTABLE *pIPAddrTable = NULL;
DWORD dwSize = 0;
DWORD dwRetVal = 0;
if (GetIpAddrTable(pIPAddrTable, &dwSize, 0) != ERROR_INSUFFICIENT_BUFFER )
{
printf( "Error getting buffer size." );
}
else
{
pIPAddrTable = ( MIB_IPADDRTABLE * ) malloc ( dwSize );
if ( (dwRetVal = GetIpAddrTable( pIPAddrTable, & dwSize, 0 ) ) != NO_ERROR )
{
printf("GetIpAddrTable failed.\n");
}
for( int i = 0; i < pIPAddrTable->dwNumEntries; i ++ )
{
in_addr add;
in_addr subnet;
ZeroMemory( & add, sizeof( in_addr ) );
ZeroMemory( & subnet, sizeof( in_addr ) );
add.S_un.S_addr = pIPAddrTable->table[ i ].dwAddr;
subnet.S_un.S_addr = pIPAddrTable->table[i].dwMask;
printf("IP Address: %s\n", inet_ntoa( add ) );
printf("IP Mask: %s\n\n", inet_ntoa( subnet ) );
}
free( pIPAddrTable );
}
Gavin Taylor
w: http://www.gavspace.com
|
|
|
|
|
Thank you for your answer.
It is definitely what I was looking for.
Best regards,
Allad
----
Navigator - Your best alternative to Windows Explorer
|
|
|
|
|
|
When will these problems end? Today I tried the EM_SETTEXTEX message for a rich edit contol only to find that it's not defined in my richedit header file. I can't understand this, SETTEXTEX is available in version 2 of the control and even that is not defined :/
Does anybody have an up to date version of this file I could possibly borrow?
|
|
|
|
|
If you are working with VC 6.0 try a new version of the sdk.
When VC6.0 was released, there was no higher version of rtfedit.
You can download the windows sdk from microsoft homepage.
|
|
|
|
|
|
It has taken me 2 days to track down this problem so I aint very happy.
I have created a table within a rich edit control using the new dll version 4.1. For some reason none of the data within the cells was not being displayed. I tracked it down to the rtf \qc command which is supposed to center text. It works in Word and Wordpad, but it aint working in my app.
Strange thing is, when I first updated the control I had it working.
Does anybody know how to correctly center text within a table cell?
|
|
|
|
|
Hi there,
I've got data from the serial port stored in a CString variable,
e.g. 0123;0255;0192 with fixed size and the values are separeted with ';'
Now I need to splitt the values 0123 0255 and so on in other variables in order to make calculations.
My question: Is there an easy way to do this with the advadages of CString or do I need the way I would do in ordinary c-code: for (i=0 ...)
variable[i] = string [i] ... and so on?
|
|
|
|
|
If you are using Visual Studio 2002 or higher, then check out the CString::Tokenize method - you can use this to split the string into sub-strings, and then use _ttoi to convert the string to an int . For example:
CString str = _T("0123;0255;0192");
int nStartPos = 0;
CString strToken = str.Tokenize(_T(";"), nStartPos);
while (!strToken.IsEmpty())
{
int nVal = _ttoi(strToken);
TRACE(_T("Token value: %d\n"), nVal);
strToken = str.Tokenize(_T(";"), nStartPos);
}
HTH.
|
|
|
|
|
Dear Robert,
thanks for good idea. Unfortunately, I'm working under VC++ 6.0 and there is no Tokensize availible.
|
|
|
|
|
OK, well you could use the C strtok function instead, but it's messy (and you'd need to make a copy of the string first), e.g.:
CString str = "0123;0456;0789";
TCHAR* psz = new TCHAR [str.GetLength() + 1];
_tcscpy(psz, str);
TCHAR* pszTok = _tcstok(psz, _T(";"));
while (pszTok != NULL)
{
int nVal = _ttoi(pszTok);
...
pszTok = _tcstok(NULL, _T(";"));
}
delete [] psz;
|
|
|
|
|
I don't think strtok is thread-safe, so be warned!
|
|
|
|
|
Robert Edward Caldecott wrote: I don't think strtok is thread-safe, so be warned!
Is CString itself thread safe ?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
I'm being thick. You can obtain direct access to the CString buffer using CString::GetBuffer if that helps.
|
|
|
|
|
|
Thanks Mike,
this is really working!;)
|
|
|
|
|
I write a MFC app, like Graphic-Suite,only to view Image Infos,you can download my app from here :http://h1.ripway.com/jupiter/JHv2.zip[^]
Problem is when i runned my app,Image Infos Dlg did not appear.
Anyone can help me solute this app....
thanks so much.
|
|
|
|
|
I used MFC appwizard and made a single document interface.
I didn't add anyother codes than this code below in OnDraw function.
I wanted to make a pyramid looking bitmap in size 256*256.
But I had to make the pointer size into 256*256*16 to make it show the size of 256*256.
if i don't, a rectangle with four small boxes of pyramid and a large black box attached to it
appers. why is it?
void CWoosooView::OnDraw(CDC* pDC)
{
CWoosooDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
int size = 256;// the size i want to make
int realsize = size*4;// this is the size i had to pump up.
// i made a pointer and added some values to make a rectangle look like a pyramid.
p = (unsigned char*)malloc(realsize*realsize);// i had to use *4 size all the way.
// below is a code for only one pyramid, but four of them appers. why is it?
for(int y = 0; y<realsize; y++){
="" for(int="" x="0;" x<realsize;x++){
="" if="" (((x="">=0) && (x<(realsize/2)))&&((y>=0) && (y<(realsize/2))))
*(p+realsize*y+x) = (int)(x+y)/4;
else if (((x<realsize) &&="" (x="">=(realsize/2)))&&((y>=0) && (y<(realsize/2))))
*(p+realsize*y+x) = (int)(realsize+(y-x))/4;
else if (((x>=0) && (x<(realsize/2)))&&((y<realsize) &&="" (y="">=(realsize/2))))
*(p+realsize*y+x) = (int)(realsize+(x-y))/4;
else if (((x<realsize) &&="" (x="">=(realsize/2)))&&((y<realsize) &&="" (y="">=(realsize/2))))
*(p+realsize*y+x) = (int)((2*realsize-x-y)/4);
}
}
CBitmap bitmap,bitmap2;
CDC memDC;
memDC.CreateCompatibleDC(pDC);
bitmap.CreateCompatibleBitmap(pDC,realsize,realsize);//realsize = *4 of the wanted size.
bitmap.SetBitmapBits(realsize*realsize,p); // here as well. i used 256*4.
free(p);
memDC.SelectObject(bitmap);
bitmap.DeleteObject();
pDC->BitBlt(0,0,size,size,&memDC,0,0,SRCCOPY);
// so i eventually only displayed the first pyramid of 4 by setting the size of BitBlt to 256*256.
bitmap2.GetBitmapBits(SRCCOPY,bitmap);
memDC.SelectObject(bitmap2);
bitmap2.DeleteObject();
pDC->StretchBlt(256,0,size/2,size/2,&memDC,0,0,size,size,SRCCOPY);
pDC->StretchBlt(384,0,size*2,size*2,&memDC,0,0,size,size,SRCCOPY);
}
woosoo
-- modified at 11:31 Saturday 18th March, 2006
|
|
|
|
|
|
thanks~ but.. what is alpha??
woosoo
-- modified at 9:38 Sunday 19th March, 2006
|
|
|
|
|
Hi,
Wen i open a particular project and try to compile it my msdev crashes and wen i debug it i get the following info:-
Unhandled exception in MSDEV.EXE(MSPDB60.dll)0x0000005 Access Violation
This hapens only for this paricular project .
has anyone of you faced similar problems .
Thanx in Advance
Regards,
FarPointer
|
|
|
|
|
I had a similar problem earlier today. MSDEV crashed when I tried to run my code in the debugger. I tracked the problem down to the initialisation of a basic_string class. For some reason when inisializing the string object the string was too long, even though it was well under the 4294967294 chars specified by MS.
Your project may have a similar problem in that something is being initialised beyond it's memory allocation.
|
|
|
|
|
Well Thanx for showing the interest :-
Actually wat i feel is MSPDB60.dll is for Microsoft-Program-DataBase , something like the linker data overriding the compiler data , etc which gets the msdev enter an infinite loop and leading to stack overflow and crash.
While in your case it was during runing in my case its during compilation this worked fine in another pc .
All i know is iam stuck and need to recreate the whole project(dsz,etc..)
Regards,
FarPointer
|
|
|
|