
Help With WNetAddConnection2
Hi,
I am trying to use WNetAddConnection2 to connect to a network printer. When
I try to use it what happens is that the function comes back as successful
but there is no new printer added if I look in settings, printers on the
start menu. It mentions in the docs you have to specify a few paremeters in
the NETRESOURCE structure which I have done. There is one parameter for
localname in the NETRESOURCE structure which is supposed to be a local
device you specify to redirect which seems to be my problem. I have tried
leaving this blank and the function suceeds. The same happens if I put in a
valid port like LPT2, if I put in an invalid port or say an invalid device
like z: it gives and error. I never seem to see a connection to my new
network printer. I have the remotename part of the NETRESOURCE structure as
a shared device name set to \\servername\printername which is how its shared
on our network. Again if you put in an invalid printer name it gives a
correct error. It all seems to be working but where is my printer?. If you
try file run with the same syntax it goes to add the printer to your list
configured printers.
If I try this with a drive map , i.e having localname as say z: and
remotename as \\servername\share it works fine and maps drive z. Is it
possible to use the WNetAddConneciton2 function to effectively map to a
network printer. The docs suggest it is, any assistance would be greatly
appreciated.
Thanks
Neal