Solved

Access my network

Posted on 1998-08-14
17
179 Views
Last Modified: 2010-04-04
How do I do to access my network and list the computers that are on the global network, and if theres shared files , list them too in a file.

Thanks!!
0
Comment
Question by:bert1
  • 6
  • 6
  • 3
  • +2
17 Comments
 

Author Comment

by:bert1
ID: 1362111
Edited text of question
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1362112
Hi bert1,

Q : what sort of network?

Zif.
0
 
LVL 20

Expert Comment

by:Madshi
ID: 1362113
Look at the IShellFolder interface.

(1) Use SHGetSpecialFolderLocation(0,CSIDL_NETWORK,pidl)
(2) Use SHGetDesktopFolder(myDesktopFolderInterface)
(3) Use myDesktopFolderInterface.BindToObject to bind it to the pidl you receive from (1)
(4) Use myDesktopFolderInterface.EnumObjects to enumerate the content of the network neighborhood

Hope this helps...
0
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 

Author Comment

by:bert1
ID: 1362114
Madshi, can you give me an example of code, that should work to run, and write some comments to it... I´m new in Delphi :o)

I didn´t find information about the IShellFolder interface.
Thanks!
0
 
LVL 7

Expert Comment

by:BlackMan
ID: 1362115
Try this...

type
  TNetRecArr: Array[0..9] of TNetResourceA;

procedure Scan(Name: String);
var
 Rec: TNetResourceA;
 Temp: TNetRecArr;
 NEHandle: Integer;
 NEResult: Integer;
 MaxRecs: Integer;
 BufSize: Integer;
begin
  With Rec do
  begin
    dwScope:=RESOURCE_GLOBALNET;
    dwType:=RESOURCETYPE_DISK;
    dwDisplayType:=0;
    dwUsage:=0;
    lpLocalName:='';
    lpRemoteName:=PChar(Name)
    lpComment:='';
    lpProvider:='';
  End;
  CurrentPlace:='';
  NEResult:=WNetOpenEnum(RESOURCE_GLOBALNET,RESOURCETYPE_DISK,0,@Rec,NEHandle);
{ Open enumeration, all resources, only disk, and no printers }
  if NEResult=0 then
  begin
    BufSize:=SizeOf(Temp);
    repeat
      MaxRecs:=10;
      NEResult:=WNetEnumResource(NEHandle,MaxRecs,Temp,BufSize);
      if (NEResult=NO_ERROR) or (NEResult=ERROR_NO_MORE_ITEMS) then
      begin
        For I:=0 to MaxRecs-1 do
          DoSomething(Temp[I]);
      end;
    until NEResult<>NO_ERROR;
    if NEResult=ERROR_NO_MORE_ITEMS then
      WNetCloseEnum(NEHandle);
  end;
end;
0
 
LVL 20

Expert Comment

by:Madshi
ID: 1362116
I'll do if you don't like BlackMan's sources...
(I guess, you have at least Delphi 3?)
0
 
LVL 7

Expert Comment

by:BlackMan
ID: 1362117
Sorry Madshi, I didn't see that you were working on some source...
0
 

Author Comment

by:bert1
ID: 1362118
There where some errors in that code, BalckMan.
Did you try it so it worked for you?
I didnt get it to work...

Madshi if you have a suggestion an example... that works, you are welcome.


0
 

Author Comment

by:bert1
ID: 1362119
I am using Delphi 4
0
 
LVL 7

Expert Comment

by:BlackMan
ID: 1362120
What was you error? Check that Windows is in your Uses clause..
0
 

Author Comment

by:bert1
ID: 1362121
NEResult:=WNetOpenEnum(RESOURCE_GLOBALNET,RESOURCETYPE_DISK,0,@Rec,NEHandle);

NEResult:=WNetEnumResource(NEHandle,MaxRecs,Temp,BufSize);
The error was:
"Types of actual and formal var parameters must be identical"

I think it can have something to do with Delphi 4...
0
 
LVL 20

Expert Comment

by:Madshi
ID: 1362122
BlackMan, doesn't matter, my suggestion does not work anyhow...  :-(

Bert1, I'm sorry, I tested my own suggestion: It seems, that it can enumerate every little file/dir/object/whatever of the whole windows system, but unfortunately not the network neighborhood. Don't know why. Oooh, Bill...
0
 
LVL 7

Expert Comment

by:BlackMan
ID: 1362123
Bert1, I guess you are right about the D4 issue. Try to declare the variables NEHandle, MAxRecs, BufSize as DWORD, I think that will help..
0
 

Author Comment

by:bert1
ID: 1362124
BlackMan, say I will save the computers name (lpLocalName) that are connected to the network in ListBox1 when I press on Button1, with my computer name Bert.

That helped with DWORD... But can you check so you get it working yourself first... and then give me the code... cause I didn´t get it to work with the Scan procedure.

Then it should work for me

Thanks for your help!
0
 

Expert Comment

by:JimmyWhite
ID: 1362125
What kind of network is it ? If it is Novell 4.xx you can download some activex components from Novell which will do almost everything you want. But be carefull because
they also can delete items from the NDS.

 
0
 
LVL 7

Expert Comment

by:BlackMan
ID: 1362126
Okay, Bert1, I can see that my cut'n'paste was to hard - I'll try to fix it..
0
 
LVL 7

Accepted Solution

by:
BlackMan earned 50 total points
ID: 1362127
Ok, here is a (new) cut from a working sample. It enumerates alle the servers in the WORKGROUP workgroup. If you want to enumerate a domain, just specify that domainname.
It then adds the servername to a listbox. If you want to enumerate the resources on the server, just call SCAN with the servername..


Var
  CurrentPlace : String;
  I : Integer;


type
  TNetRecArr = Array[0..9] of TNetResourceA;

procedure tform1.Scan(Name: String);
var
 Rec: TNetResourceA;
 Temp: TNetRecArr;
 NEHandle,
 NEResult,
 MaxRecs,
 BufSize: dword;
begin
  With Rec do
  begin
    dwScope:=RESOURCE_GLOBALNET;
    dwType:=RESOURCETYPE_DISK;
    dwDisplayType:=RESOURCEDISPLAYTYPE_SHARE;
    dwUsage:=0;
    lpLocalName:='';
    lpRemoteName:=PChar(Name);
    lpComment:='';
    lpProvider:='Microsoft Windows Network';
  End;
  CurrentPlace:='';
  NEResult:=WNetOpenEnum(RESOURCE_GLOBALNET,RESOURCETYPE_DISK,0,@Rec,NEHandle);
{ Open enumeration, all resources, only disk, and no printers }
  if NEResult=0 then
  begin
    BufSize:=SizeOf(Temp);
    repeat
      MaxRecs:=10;
      NEResult:=WNetEnumResource(NEHandle,MaxRecs,@Temp,BufSize);
      if (NEResult=NO_ERROR) or (NEResult=ERROR_NO_MORE_ITEMS) then
      begin
      For I:=0 to MaxRecs-1 do
        LB.Items.Add(Temp[I].lpremoteName);
      end;
    until NEResult<>NO_ERROR;
    if NEResult=ERROR_NO_MORE_ITEMS then
      WNetCloseEnum(NEHandle);
  end;
end;


procedure TForm1.Button1Click(Sender: TObject);
begin
  Scan('WORKGROUP');
end;

0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

777 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