Solved

WNetAddConnection2

Posted on 1997-07-15
7
432 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

 

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

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

A common practice in small networks is making file sharing easy which works extremely well when intra-network security is not an issue. In essence, everyone, that is "Everyone", is given access to all of the shared files - often the entire C: drive …
Resolve DNS query failed errors for Exchange
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses

627 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