LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

MapNetworkDrive using CVI

How can I map (and later-on also disconnect) a network drive programmatically in CVI?
At the moment I launch a batchfile (that contains the command "net use") from within my application. The batchfile prints a status string into a file that is read from my application. It works, but I think it's not very elegant and very sensible for misbehaviour. Is there another way to do this ?
0 Kudos
Message 1 of 4
(3,548 Views)
Hi,

CVI does not have any built in functions to map a network drive. However the Windows SDK provides the function WNetAddConnection2 that you can use to map the drive. This function is defined in winnetwk.h and you need to link to mpr.lib.

You can find more information on the Windows SDK help file. If you don't have a link in CVI's help menu to the Windows SDK help just go to Add/Remov programs a modify the CVI installation to include SDK support.

Let me know if you have any questions.

Regards,

Juan Carlos
N.I.
0 Kudos
Message 2 of 4
(3,548 Views)
Hi,

thanks for your answer. I've tried to follow your suggestion but got the problem, that WNetAddConnection2 ended up in dwResult=67 (ERROR_BAD_NET_NAME) although the remote name I specified is a name that's listed in our company networks (see net.jpg).
I've tried then to use another function from within the SDK called WNetUseConnection. But then I got a general protection fault with dwResult=487 (ERROR_INVALID_ADDRESS).

I've attached a code segment containing both functions. Can you help me in solving my problem?
I've also tried to enumerate the net resources by function to get valid names (syntax...)for getting a hint but did not succeed in here.

Thanks in advance for your help..

Regards,
Manfred
Download All
0 Kudos
Message 3 of 4
(3,548 Views)
Hi again,

I've found the solution to my problem 🐵

I've attached a code segment containing Map/Disconnect a network drive and the error handler.

If you want to, you can place this code also on the sample page. You may also post it to Sheetal, he had the same problem some time ago

Regards..
0 Kudos
Message 4 of 4
(3,548 Views)