Solved

Access my network

Posted on 1998-08-14
17
178 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
 

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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Delphi 10 Seattle Dataset Actions 5 79
How to convert wav to mp3 in delphi 9 174
automatically logging in via bde delphi 3 70
How to renew a Delphi rad-studio licence? 5 49
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
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…
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

864 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now