Solved

Access my network

Posted on 1998-08-14
17
185 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
[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
  • 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
Industry Leaders: 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!

 

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

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

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…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

717 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