Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Accessing XP Machine from a WinCE device through Network

689 views
Skip to first unread message

WinCELearner

unread,
Feb 18, 2009, 5:11:01 AM2/18/09
to
I am developing an application for a WinCE based device and need to access
some files from the Windows XP machine. Would like to access some picture and
media files and display it.
Both WinCE and Windows Machine shall be in the same private network.
Basically something like accessing a shared folder of the XP machine from
the WinCE device.
Can anyone provide some inputs on this?

Thanks in advance..

eric

unread,
Feb 18, 2009, 5:33:07 AM2/18/09
to
You can do that with:

\\<HOST NAME>\<SHARED FOLDER>\<FILE NAME>

for example copy file from command line:

copy \\Asterix\SharedFiles\myFileName.file \RootFolderOnDevice\Folder\

same you can do with CopyFile API from your source code.

eric.

WinCELearner

unread,
Feb 18, 2009, 9:57:01 AM2/18/09
to
Thanks eric for the quick response.
We had tried this option already and it returned I/O error.
Let me explain my doubt clearly.
Suppose I have a shared folder in the XP machine which contains files,for (
eg) pictures.
I need to access and display this pictures from the application running in
WinCE device, not copy them to WinCE device. Basically something like
accessing a network drive.
Do you have any ideas on how to go about this?

Thanks a lot...

Paul G. Tobey [eMVP]

unread,
Feb 18, 2009, 10:13:11 AM2/18/09
to
As with your XP machine, you have to have the file sharing components in
your Windows CE OS (there is no minimum set of things that every CE device
has, so we don't even know that SMB support is in your device; you have to
verify that). You also have to set the device name to a unique NetBIOS
value on your local network (you can do this via the System Control Panel
applet on the CE device), then you have to reboot the CE device. Now you
have a valid NetBIOS name and can access your XP shared folders, assuming
that you have a suitable user name and password which the XP device will
accept. As suggested before, access the file via \\<hostname>\<sharename>
from Explorer the CE device (and note that you CANNOT use the XP device's IP
address; it has to be the name). Does that work? If not, what error does
it return? If it does work, you're ready to go.

Paul T.

"WinCELearner" <WinCEL...@discussions.microsoft.com> wrote in message
news:CE920FCB-489D-4BFA...@microsoft.com...

eric

unread,
Feb 18, 2009, 1:49:25 PM2/18/09
to
It is like Paul said- first check if CIFS/SMB is included into your
wince kernel image.

(Check with GetLastError() after you got an error when accessing the
host folders)

eric.

WinCELearner

unread,
Feb 28, 2009, 4:19:01 AM2/28/09
to
Thanks a lot Eric and Paul for your valuable suggestions.
I added the SMB catalog item in the OS Image and changed the name in the
NETBIOS as you had mentioned.Now when I try to open a picture file
using fopen giving the \\<HOSTNAME>\<SHAREDFOLDER>\File,
I get a popup for the username , password, domain.I am trying to this in a
application for a Set top box where i do not have the keyboard to type in
characters etc,
So is there a possibility to allow access to the host without this Login
screen?
Do we need to make any changes to the Host machine for the access level.
Currently the folder sharing is with full write permission.
Also, please note that I am trying to this with 2 NICs in the host
machine.One for Public internet access and One in the private network with
the STB.I am trying to access the files in the host network through the NIC
for the private network.
So is there something I need to do for this setup.
Please advice.
Thanks in advance for ur help

Paul G. Tobey [eMVP]

unread,
Mar 2, 2009, 11:43:14 AM3/2/09
to
Well, as you might imagine, you *do* need to log in! You could connect to
the shared resource using the WNet functions, where you can specify the user
name and password to use, in your code, rather than trying to do things the
easy way (by ignoring the fact that you're accessing a shared file). If the
share is protected, you must pass it a user name and password. If it's set
to allow anyone, it seems to me that the login dialog shouldn't pop up, but
I don't remember clearly whether I've done that. If you have *no* way to
enter characters on the device, then, obviously, you're going to have to
configure the server to share whatever you need shared with no protection at
all...

No, there shouldn't be anything else that you need to do network-wise, as
long as you can ping devices on the private network from your device.

Paul T.

"WinCELearner" <WinCEL...@discussions.microsoft.com> wrote in message

news:CA78AA7A-7927-4A31...@microsoft.com...

WinCELearner

unread,
Mar 3, 2009, 9:16:10 AM3/3/09
to
Hi Paul,
Thanks for your comments.As per your suggestion, I added the WNet
Functions.

I called the WNetAddConnection3() API with the parameters set as below:

NETRESOURCE nr;
memset(&nr,0,sizeof(nr));
nr.lpRemoteName = TEXT("\\\\WMH643-01"); //computer name to be accessed
nr.lpLocalName = L"share";
nr.dwType = RESOURCETYPE_DISK;

DWORD dwRes = WNetAddConnection3( NULL,&nr,
NULL, // password
NULL, // username
CONNECT_UPDATE_PROFILE);
The result of the API is an error value = 53 (ERROR_BAD_NETPATH)

I have also tried giving valid username and password for
WNetAddConnection3() API but the error is still ERROR_BAD_NETPATH.

I have also changed the NETBIOS name in the WinCE device.

Please give your thoughts on this.

Thanks a lot...

Paul G. Tobey [eMVP]

unread,
Mar 3, 2009, 10:46:28 AM3/3/09
to
The remote name is the computer name AND the share name, \\WMH643-01\share.
You also have to carefully consider your choice of parameters for user name
and password. NULL means something significant to the call and it's
probably not what you think.

I used the following code successfully:

NETRESOURCE res;
res.dwScope = RESOURCE_GLOBALNET;
res.dwType = RESOURCETYPE_DISK;
res.dwDisplayType = RESOURCEDISPLAYTYPE_SHARE;
res.dwUsage = RESOURCEUSAGE_CONNECTABLE;
res.lpLocalName = _T( "actelprj" );
res.lpRemoteName = _T( "\\\\farside\\actelprj" );
res.lpComment = NULL;
res.lpProvider = NULL;

DWORD err;
if ( ( err = WNetAddConnection3( NULL, &res, _T( "" ), _T( "GUEST" ), 0 ) )
==
ERROR_SUCCESS )
{
// Success.
}
else
{
DEBUGMSG( 1, ( TEXT( "Error in WNetAddConnection3 = %d 0x%x\r\n" ),
err, err ) );
}

Paul T.


"WinCELearner" <WinCEL...@discussions.microsoft.com> wrote in message

news:44EFCA1E-BCF6-407A...@microsoft.com...

WinCELearner

unread,
Mar 4, 2009, 9:28:10 AM3/4/09
to
Hi Paul,
Thanks a lot for the timely help and suggestions.After making the
modifications as per suggestions, I was able to mount the Shared drive in the
XP machine in my CE device.I am able to write/read files in the network path.
Currently I am facing some issues with loading a picture file from the
Shared Folderin the C# application running in WinCE device.
I will keep you posted on the progress or issues.
Once again , thanks a lot.

"Paul G. Tobey [eMVP]" wrote:

WinCELearner

unread,
Mar 13, 2009, 11:38:01 AM3/13/09
to
Hi Paul,
Using WNetAddConnection3(), we are able to mount a shared folder of the
network to our WINCE device.
We are also able to perform Read and Write operation using File Operation
APIs.

But we have the following issues:
When i try to read data using the following code

byte[] temp = new byte[1 * 1024]; // 1 KB
FileStream fs = File.Open("file", FileMode.Open,FileAccess.Read);
if (fs != null)
{
fs.Read(temp, 0, temp.Length);
}

Read/Write works fine when the "temp" buffer is small. When the size of the
buffer is increased to 1 MB, "Read" throws the following exception

41706 PID:d1fad0ea TID:f1fb5882 0x91c68ae0: WaitNib 0x3F1C70, timed out
waiting for server response after 10000 ms
41706 PID:d1fad0ea TID:f1fb5882 0x91c68ae0: Error 59 in CORE read, aborting
41706 PID:d1fad0ea TID:f1fb5882 0x91c68ae0: -RDR:ReadFromNet, returning 59
41707 PID:d1fad0ea TID:f1fb5882 0x91c68ae0: +RDR:FileRead, returning 59
41712 PID:f1c68802 TID:f1fb5882 error = 59

42198 PID:f1c68802 TID:f1fb5882 Exception = System.IO.IOException:
IOException

We get the same error when accessing a picture file mounted on \Network\ to
display it in the picture box using the following code

Image picture = new System.Drawing.Bitmap(filename);
pictureBoxObject.Image = picture;

The size of the picture file also than 1 Kilo Bytes as Read worked with 1 KB
buffer.

We thought that Network traffic could be an issue and hence tried to
increase the "TimeOut" to 20 seconds instead of the defalut 10 seconds

Registry settings are
; Redirector settings
[HKEY_LOCAL_MACHINE\Comm\Redir]
"AllowedAuthMethods"=dword:0
"ClearTxtPwdAllowed"=dword:1
; Expose \NETWORK dir for mapped resources
"RegisterFSRoot"=dword:1
"SmbSignature"=dword:0
"ServerTimoutMs"=dword:20000

Even after these changes and giving a SYSGEN in Platform Builder it used to
TimeOut in 10 seconds instead of 20 seconds.

Is it really necessary to increase the TimeOut value?
Are there any limitations on the size of the files to be accessed?

Please help us in undestanding the limitations of WNetAddConnection3().
Thanks in advance.

Paul G. Tobey [eMVP]

unread,
Mar 16, 2009, 1:05:56 PM3/16/09
to
As far as I can tell, it should work as-is. It does for me, at least. 59
is an unexpected network error. That sounds like a problem with the server,
an actual network problem, like you disconnected the cable, the user name or
password being OK at the start, but failing later or something of that sort.

Paul T.

"WinCELearner" <WinCEL...@discussions.microsoft.com> wrote in message

news:C0AD98AE-2123-454E...@microsoft.com...

WinCELearner

unread,
Mar 31, 2009, 10:12:02 AM3/31/09
to
Hi Paul,
We could resolve the issue with the file size by downscaling the
NK.bin by removing some exes which were binded to it. There was no change in
the timeout value or so required.Now we are able to do file operations in the
N/W successfully.Even displaying a picture file or playing a media file from
the Network folder works fine.
But We are facing an issue with respect to the mounted network folder. The
issue is as follows:

The network shared folder gets mounted with the “res.lpLocalName” under
\Network\.
We can access all the files and folders once mounted.
But if we don’t access any of the files/folders under the mounted path for
more than 10 min ,during the next attempt of accessing the mounted path we
get a pop-up requesting for User Credentials (user name and password).
Basically i think the network connection is lost.
Is there any way to avoid this request for User Credentials?

"Paul G. Tobey [eMVP]" wrote:

Paul G. Tobey [eMVP]

unread,
Mar 31, 2009, 11:32:10 AM3/31/09
to
If you make the credentials the default network ID (see the System Control
Panel applet), it won't ask again. It sounds to me like the server is
responsible for you being asked to enter credentials again; that never
happens to me when sharing folders from an ordinary XP Pro box to Windows CE
4.2 or 5.0.

Paul T.

"WinCELearner" <WinCEL...@discussions.microsoft.com> wrote in message

news:870035FB-8252-4C50...@microsoft.com...

WinCELearner

unread,
Apr 1, 2009, 2:32:12 PM4/1/09
to
Hi Paul,
Trying to find what maybe wrong with the XP machine causing the timeout
for 10 mins..actually found another issue.Mounting the network fails when the
public network is removed from the XP machine.Basically the XP machine has 2
ethernet ports, One for Internet access and one for the private network to be
connected to the wince device.Since we use the computer name to connect to
the XP machine, the mounting fails as soon as the public network is
unplugged.This implies that sort of DNS needs to be there for the private
network as well.
Any suggestions with respect to how to resolve the Computer name in the
private network?

Also the disconnect after 10 mins seems to be because of the registry settings
ResourceExpiryInt to default 600 secs that is 10 mins..
we shall change this value to fix the timeout problem..
Thanks a lot..

Paul G. Tobey [eMVP]

unread,
Apr 1, 2009, 2:44:11 PM4/1/09
to
I don't know enough about XP to help with that. I'd try verifying that,
when you have a *PC* on the private network, it also has problems connecting
to the server machine when the public network on that is disconnected. Once
you have that situation, you can ask a pretty good question in an XP
networking group.

Paul T.

"WinCELearner" <WinCEL...@discussions.microsoft.com> wrote in message

news:9DA1B18A-4797-4EEC...@microsoft.com...

0 new messages