Solved

WNetAddConnection2

Posted on 1997-07-15
7
422 Views
Last Modified: 2013-12-23
The WnetAddConnection2 function fails in my program giving the error - ERROR_NO_NETWORK.

I have set up the machine as a member of an NT domain.
I am also able to run programs such as telnet, ftp and ping.

Is there some other network initialize function that I need
to call before calling WNetAddConnection2?
0
Comment
Question by:hemamundkur
7 Comments
 

Author Comment

by:hemamundkur
ID: 1547249
Edited text of question
0
 
LVL 3

Expert Comment

by:Ikon
ID: 1547250
Did you ask in the programming section?
0
 

Author Comment

by:hemamundkur
ID: 1547251
Adjusted points to 100
0
What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

 

Author Comment

by:hemamundkur
ID: 1547252
Answer to Ikon's clarifications:
Yes. I want to know if there is any C/VC++ network initialize call which I need to make before making the 'WNetConnection2' function call in my program? If not, is there a command line
call like 'net start' or something that I can use?

My program does work when I make 'Client for Microsoft Networks'
my primary network logon.  The error comes when I make 'Windows Logon' as my primary network logon. How ever I want it to work
irrespective of the way the user has logged on.
0
 
LVL 3

Expert Comment

by:vinniew
ID: 1547253
yes.  yes.

I've used WNetAddConnection2 before.  You just need to fill in the resource struct carefully, that's all.

Command Line equivalent:

"net use p: \\myserver\sharedrive"

But, with this you have to have a matching user/password.


0
 

Author Comment

by:hemamundkur
ID: 1547254
Thanks for your reply. The wnetAddConnection2 command does work for me too. But ONLY when I have logged on through the 'Client For microsoft windows' primary logon window.

It does not work when I have NOT logged on through the initial logon dialog box. I am passing the user name and password anyway in the WNetAddConnection2 command. So I don't understand why it
should not work.

Here is my code segment:

NETRESOURCE  netResource;
netResource.dwType = RESOURCETYPE_DISK;
netResource.lpLocalName = "F:";
netResource.lpRemoteName = "\\\\mymachine\\cdrive";
netResource.lpProvider = NULL;
stat = WNetAddConnection2(&netResource,"mypasswd","mylogin",0);

0
 
LVL 4

Accepted Solution

by:
Tomun earned 100 total points
ID: 1547255
Your problem seem to be that you need to log on to an NT Domain.
Under the network properties, the NT Domain settings are under the properties for the Client For Microsoft Networks.
It makes sense that Client For Microsoft Networks should be the
primary logon if you want it to use these settings.

I am on a Win95 only network so I dont need to log on to a domain, and WnetAddConnection2 works perfectly and Im using Windows Logon.

When you use Windows Logon can you still see the network neighborhood correctly ? Does your computer find the browse master ?

A workaround you might want to try is getting TweakUI from microsoft and getting that to log in automatically for you.
You sould still then be able to have you network settings on
Client For Microsoft Networks.

Hope this helps.
0

Featured Post

Zoho SalesIQ

Hassle-free live chat software re-imagined for business growth. 2 users, always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A brief overview to explain gateways, default gateways and static routes OR NO - you CANNOT have two default gateways on the same server, PC or other Windows-based network device. In simple terms a gateway is formed when a computer such as a serv…
Have you ever set up your wireless router at home or in the office to find that you little pop-up bubble in the bottom right-hand corner of Windows read "IP Conflict - One of more computers on the network have been assigned the following IP address"…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

896 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now