Click here to Skip to main content
15,923,281 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Generalproblem of icons Pin
sarasara09876548-Oct-03 21:39
sarasara09876548-Oct-03 21:39 
GeneralRe: problem of icons Pin
jhwurmbach9-Oct-03 0:27
jhwurmbach9-Oct-03 0:27 
GeneralRe: problem of icons Pin
David Crow9-Oct-03 2:42
David Crow9-Oct-03 2:42 
Questionhow can i get the computer name&ip in local network? Pin
Hellin8-Oct-03 20:28
Hellin8-Oct-03 20:28 
AnswerRe: how can i get the computer name&ip in local network? Pin
twing8-Oct-03 21:25
twing8-Oct-03 21:25 
GeneralRe: how can i get the computer name&ip in local network? Pin
Hellin8-Oct-03 21:47
Hellin8-Oct-03 21:47 
GeneralRe: how can i get the computer name&ip in local network? Pin
twing8-Oct-03 22:05
twing8-Oct-03 22:05 
GeneralRe: how can i get the computer name&ip in local network? Pin
Hellin8-Oct-03 22:10
Hellin8-Oct-03 22:10 
see:
// TODO: Add extra validation here
CString strTemp;
struct hostent *host;

struct in_addr *ptr; // To retrieve the IP Address

DWORD dwScope = RESOURCE_CONTEXT;
NETRESOURCE *NetResource = NULL;
HANDLE hEnum;
WNetOpenEnum( dwScope, NULL, NULL,
NULL, &hEnum );

WSADATA wsaData;
WSAStartup(MAKEWORD(1,1),&wsaData);

if ( hEnum )
{
DWORD Count = 0xFFFFFFFF;
DWORD BufferSize = 2048;
LPVOID Buffer = new char[2048];
WNetEnumResource( hEnum, &Count,
Buffer, &BufferSize );
NetResource = (NETRESOURCE*)Buffer;

char szHostName[200];
unsigned int i;

for ( i = 0;
i < BufferSize/sizeof(NETRESOURCE);
i++, NetResource++ )
{
if ( NetResource->dwUsage ==
RESOURCEUSAGE_CONTAINER &&
NetResource->dwType ==
RESOURCETYPE_ANY )
{
if ( NetResource->lpRemoteName )
{
CString strFullName =
NetResource->lpRemoteName;
if ( 0 ==
strFullName.Left(2).Compare("\\\\") )
strFullName =
strFullName.Right(
strFullName.GetLength()-2);

gethostname( szHostName,
strlen( szHostName ) );
host = gethostbyname(strFullName);

if(host == NULL) continue;
ptr = (struct in_addr *)
host->h_addr_list[0];

// Eg. 211.40.35.76 split up like this.
int a = ptr->S_un.S_un_b.s_b1; // 211
int b = ptr->S_un.S_un_b.s_b2; // 40
int c = ptr->S_un.S_un_b.s_b3; // 35
int d = ptr->S_un.S_un_b.s_b4; // 76

strTemp.Format("%s --> %d.%d.%d.%d",
strFullName,a,b,c,d);
AfxMessageBox(strTemp);
}
}
}

delete Buffer;
WNetCloseEnum( hEnum );
}

WSACleanup();
//*******************************************
I try ,but fail ! thanks all the same !
GeneralRe: how can i get the computer name&ip in local network? Pin
David Crow9-Oct-03 3:18
David Crow9-Oct-03 3:18 
GeneralRe: how can i get the computer name&amp;ip in local network? Pin
Hellin9-Oct-03 14:32
Hellin9-Oct-03 14:32 
GeneralRe: how can i get the computer name&amp;ip in local network? Pin
David Crow9-Oct-03 15:57
David Crow9-Oct-03 15:57 
Generalwhy BOOL and bool coexist? Simply! Pin
twing8-Oct-03 20:08
twing8-Oct-03 20:08 
GeneralRe: why BOOL and bool coexist? Simply! Pin
Anand Paranjpe8-Oct-03 20:26
Anand Paranjpe8-Oct-03 20:26 
GeneralRe: why BOOL and bool coexist? Simply! Pin
twing8-Oct-03 21:32
twing8-Oct-03 21:32 
GeneralRe: why BOOL and bool coexist? Simply! Pin
jhwurmbach8-Oct-03 22:52
jhwurmbach8-Oct-03 22:52 
Generalprevent Windows from paging my executables Pin
Eddie7008-Oct-03 19:15
Eddie7008-Oct-03 19:15 
GeneralRe: prevent Windows from paging my executables Pin
Blake Coverett8-Oct-03 20:56
Blake Coverett8-Oct-03 20:56 
GeneralRe: prevent Windows from paging my executables Pin
David Crow9-Oct-03 15:55
David Crow9-Oct-03 15:55 
GeneralRe: prevent Windows from paging my executables Pin
Blake Coverett9-Oct-03 16:45
Blake Coverett9-Oct-03 16:45 
Generalcall menu item from program Pin
vancouver7778-Oct-03 18:12
vancouver7778-Oct-03 18:12 
GeneralRe: call menu item from program Pin
Terry O'Nolley8-Oct-03 19:03
Terry O'Nolley8-Oct-03 19:03 
GeneralRe: call menu item from program Pin
KaЯl9-Oct-03 3:12
KaЯl9-Oct-03 3:12 
GeneralRe: call menu item from program Pin
sdfdsfa9-Oct-03 6:05
sdfdsfa9-Oct-03 6:05 
GeneralRe: call menu item from program Pin
KaЯl9-Oct-03 6:27
KaЯl9-Oct-03 6:27 
GeneralMsFlexGrid editable Pin
act_x8-Oct-03 17:02
act_x8-Oct-03 17:02 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.