Visit our Sponsor   Visit our Sponsor
delphi3000.com - the free delphi knowledge platform
delphi3000.com - the free delphi knowledge platform
Have a look at your member-status

connecting people's knowledge


  - Recent ArticlesRSS feed for Recent Articles on delphi3000.com
  - List of All Articles
  - Top Viewed Articles
  - Articles (+Attachem.)
  - Articles Of Interest
  - Categories
  - Top Uploader
  - Search
  - Index

  - My Home
  - Submit an Article
  - My Articles
  - My Personal Data
  - My Bookmarks
  - Activities
  - Login/Logout

  - Sign Up
  - Why Sign Up
  - Newsletter

  - Press
  - Advertise

  - Contact
  - Feedback





Community
Borland
ClubeDelphi
Dr. Bob
UK-BUG
Delphi Meetings
Planeta Delphi







Startblatt.de






Share this article with friendsShare this article with friends
Rate this articleRate this article - to keep the quality of delphi3000.com !
Comment this article or read through previous comments (1)


Mapping network drives with DelphiGo to Christian Kuttler's websiteFormat this article printer-friendly!Bookmark function is only available for registered users!
Product:
Delphi all versions
Category:
Files Operation
Skill Level:
Scoring:
Last Update:
11/16/2001
Search Keys:
delphi delphi3000 article borland vcl code-snippet network-drives mapping-network-drives make-a-network-connection
Times Scored:
5
Visits:
6667
Uploader: Christian Kuttler
Company: Centerparcs Europe Germany
Reference: N/A
 
Question/Problem/Abstract:
How can I mapp a network drive using Delphi
Answer:



function NetUse(LokaleRessource,RemoteRessource: String) : Integer;
{ This routine allows you to connect a network drive.
  Example: NetUse(U:,\\GENTKBF1\SYS connects the local drive u: with the network
  volume SYS from server \\GENTKBF1
  Possible returne values are:

  Value                         Meaning
  ERROR_ACCESS_DENIED         Access is denied.
  ERROR_ALREADY_ASSIGNED The device specified in the lpLocalName parameter is already connected.
  ERROR_BAD_DEV_TYPE         The device type and the resource type do not match.
  ERROR_BAD_DEVICE         The value specified in lpLocalName is invalid.
  ERROR_BAD_NET_NAME         The value specified in the lpRemoteName parameter is not valid or cannot be located.
  ERROR_BAD_PROFILE         The user profile is in an incorrect format.
  ERROR_CANNOT_OPEN_PROFILE The system is unable to open the user profile to process persistent connections.
  ERROR_DEVICE_ALREADY_REMEMBERED An entry for the device specified in lpLocalName is already in the user profile.
  ERROR_EXTENDED_ERROR         A network-specific error occurred. To get a description of the error, use the WNetGetLastError function.
  ERROR_INVALID_PASSWORD The specified password is invalid.
  ERROR_NO_NET_OR_BAD_PATH The operation cannot be performed because either a network component is not started or the specified name cannot be used.
  ERROR_NO_NETWORK         The network is not present.
  }
begin
  Result:= WNetAddConnection(PChar(RemoteRessource),Nil,PChar(LokaleRessource));
end;

function NetUseDelete(LokaleRessource: String) : Integer;
{ This function coses an existing networc connection.
  Example: the function call NetUseDelete('O:') cancels the connection from
  drive O: to the actually used network recource.
  Possible returne values are:

Value                 Meaning
ERROR_BAD_PROFILE The user profile is in an incorrect format.
ERROR_CANNOT_OPEN_PROFILE The system is unable to open the user profile to process persistent connections.
ERROR_DEVICE_IN_USE The device is in use by an active process and cannot be disconnected.
ERROR_EXTENDED_ERROR A network-specific error occurred. To get a description of the error, use the WNetGetLastError function.
ERROR_NOT_CONNECTED The name specified by the lpName parameter is not a redirected device, or the system is not currently connected to the device specified by the parameter.
ERROR_OPEN_FILES There are open files, and the fForce parameter is FALSE
}
begin
  Result:= WNetCancelConnection(PChar(LokaleRessource),True);
end;





Please rate this article!
Skill level:
BeginnerExpert

Useful:
No!Very!

Overall rating:
PoorExcellent



Comments to this article
Write a new comment
dupe article
    Eber Irigoyen (Nov 16 2001 9:11PM)

this issue is already covered:
http://www.delphi3000.com/articles/article_2028.asp
=o(
Respond














 
Sign up to consume product discounts for Bronze memberships !

read more


  Visit our Sponsor

 

  Community Ad of
I. Siticov
 
   














 







     
  Copyright © 2000 - 2007 delphi3000.com - All rights reserved. Terms of use. || Privacy
delphi3000.com is a service by bluestep.com IT-Services GmbH (Vienna)