Solved

Adding and removing network connections

Posted on 2004-08-05
8
154 Views
Last Modified: 2010-04-05
Hey everyone,

I asked this question in a previous thread, but I was told I must ask one question at a time so here it goes: How to open the "New Connection Wizard" and how to remove already existing connections within Delphi code? I hope this can be classified as one question... :)

Thanks allot for your time!
0
Comment
Question by:Prototype_T-104
[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
  • 2
  • 2
8 Comments
 
LVL 8

Expert Comment

by:BdLm
ID: 11725446
procedure TForm1.ConnectDrive1Click(Sender: TObject);
begin
    WNetConnectionDialog(handle,RESOURCETYPE_DISK);
end;

eg. to connect to e network drive
0
 
LVL 8

Expert Comment

by:BdLm
ID: 11725469
remark:

RESOURCETYPE_PRINTER also available, for Disconnect call WNETDisconnectDialog
 
0
 
LVL 17

Accepted Solution

by:
TheRealLoki earned 145 total points
ID: 11729929
The following is how to make a connection without the dialog

function Tf.Connect( RemoteName, ShareName, UserName, Password: string): boolean;
    var
        NetError: DWORD;
        NetResource: TNetResource;
    begin
        fillChar( NetResource, sizeof( NetResource ), 0 );
        NetResource.dwType := RESOURCETYPE_DISK;
        NetResource.lpLocalName := nil;
        NetResource.lpRemoteName := PChar( RemoteName + ShareName );
        NetResource.lpProvider := nil;
        NetError := WNetAddConnection2( NetResource,
        PChar( Password ), PChar( UserName ), 0 );
        result := NetError = 0;
    end;

        WNetCancelConnection2( PChar( Machine_ + Share_), 0, true );
0
 

Author Comment

by:Prototype_T-104
ID: 11733574
Thanks I will try to implement that,

@BdLm
I want to call the dialog that creates a new connection to the internet. This dialog is also available from the Network Connections folder.
0
 
LVL 17

Expert Comment

by:TheRealLoki
ID: 13341645
I answered the 2nd part of his question correctly, however the first part was only half correct.
I probably should have checked back and followed up on his question but I forgot
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

726 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