Finding Network Computers

  • Thread starter Thread starter Pal
  • Start date Start date
P

Pal

Hi,
Is there any way to find all my Network computers in wince 5.0 ?
Some thing equalent NetServerEnum on regular windows platform.

Thank you
 
I don't think that there's anything built into the Compact Framework for
that (you should check the help for .NET CF 3.5 -- or whatever version of
the framework your CE5 device has; it could be any one of the three).
WNetEnumResource(), the C API, can be used, if suitable components have been
included in the Windows CE operating system you're running.

Paul T.
 
Thank You Paul,
I tried with below code found on net. I am not sure if I am doing it wrong
or if my device do not support as you mentiond in your reply.

void FindNetworkResource(HWND hWnd)
{
INT nBuffSize = 1024;
TCHAR szRemoteName[256];

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

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

char szHostName[200];
for ( unsigned int i = 0; i < BufferSize/sizeof(NETRESOURCE); i++,
NetResource++ )
{
if ( NetResource->dwUsage == RESOURCEUSAGE_CONTAINER &&
NetResource->dwType == RESOURCETYPE_ANY )
{
if ( NetResource->lpRemoteName )
{
lstrcpy (szRemoteName, NetResource->lpRemoteName);
MessageBox (hWnd, szRemoteName, szAppName, MB_OK);
}
}
}
delete Buffer;
WNetCloseEnum( hEnum );
}
}
Pls suggest.

Thank you for your support.
 
This sure doesn't look like Compact Framework code to me. You might try
posting in a more relevant newsgroup.


--

Chris Tacke, Embedded MVP
OpenNETCF Consulting
Giving back to the embedded community
http://community.OpenNETCF.com



Pal said:
Thank You Paul,
I tried with below code found on net. I am not sure if I am doing it wrong
or if my device do not support as you mentiond in your reply.

void FindNetworkResource(HWND hWnd)
{
INT nBuffSize = 1024;
TCHAR szRemoteName[256];

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

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

char szHostName[200];
for ( unsigned int i = 0; i < BufferSize/sizeof(NETRESOURCE); i++,
NetResource++ )
{
if ( NetResource->dwUsage == RESOURCEUSAGE_CONTAINER &&
NetResource->dwType == RESOURCETYPE_ANY )
{
if ( NetResource->lpRemoteName )
{
lstrcpy (szRemoteName, NetResource->lpRemoteName);
MessageBox (hWnd, szRemoteName, szAppName, MB_OK);
}
}
}
delete Buffer;
WNetCloseEnum( hEnum );
}
}
Pls suggest.

Thank you for your support.


Paul G. Tobey said:
I don't think that there's anything built into the Compact Framework for
that (you should check the help for .NET CF 3.5 -- or whatever version of
the framework your CE5 device has; it could be any one of the three).
WNetEnumResource(), the C API, can be used, if suitable components have
been
included in the Windows CE operating system you're running.

Paul T.
 
Well, what's the result?! It should be obvious to you from reading the help
that your parameters to WNetOpenEnum() are totally wrong... I mean, where
did you get RESOURCE_CONTEXT as the first parameter?!

Paul T.

Pal said:
Thank You Paul,
I tried with below code found on net. I am not sure if I am doing it wrong
or if my device do not support as you mentiond in your reply.

void FindNetworkResource(HWND hWnd)
{
INT nBuffSize = 1024;
TCHAR szRemoteName[256];

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

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

char szHostName[200];
for ( unsigned int i = 0; i < BufferSize/sizeof(NETRESOURCE); i++,
NetResource++ )
{
if ( NetResource->dwUsage == RESOURCEUSAGE_CONTAINER &&
NetResource->dwType == RESOURCETYPE_ANY )
{
if ( NetResource->lpRemoteName )
{
lstrcpy (szRemoteName, NetResource->lpRemoteName);
MessageBox (hWnd, szRemoteName, szAppName, MB_OK);
}
}
}
delete Buffer;
WNetCloseEnum( hEnum );
}
}
Pls suggest.

Thank you for your support.


Paul G. Tobey said:
I don't think that there's anything built into the Compact Framework for
that (you should check the help for .NET CF 3.5 -- or whatever version of
the framework your CE5 device has; it could be any one of the three).
WNetEnumResource(), the C API, can be used, if suitable components have
been
included in the Windows CE operating system you're running.

Paul T.
 
Back
Top